Slide 1

Slide 1 text

The Spirit of Testing

Slide 2

Slide 2 text

The Spirit of Testing

Slide 3

Slide 3 text

Testing? I’m bored already http://stockarch.com/images/events/bored-halloween-ghost-6068

Slide 4

Slide 4 text

DON’T

Slide 5

Slide 5 text

Testing should be Appealing http://gossip.whyfame.com/demi-moore-and-whoopi-goldberg-pay-tribute-to-ghost-co-star-patrick-swayze-613

Slide 6

Slide 6 text

“Testing is like sex. If it’s not fun, then you’re doing it wrong” – anonymous

Slide 7

Slide 7 text

http://writingisacompulsion.blogspot.co.uk/2013/10/9-months-in-making-baby-of-thought.html

Slide 8

Slide 8 text

Remember being a kid? https://parentsavvy.com/child-health/?SubtopicId=30014,30017&DocId=1,2954

Slide 9

Slide 9 text

Kids run tests every moment http://www.psychalive.org/category/tantrums-2/ http://www.patrasevents.gr/article/100447-deite-tin-apisteuti-antidrasi-apo-morakia-pou-dokimazoun-lemoni-video

Slide 10

Slide 10 text

They are the best at it http://www.childrensdayton.org/cms/images/a0f6b517aba16ca5/index.html

Slide 11

Slide 11 text

They explore the unknowns http://www.childrensdayton.org/cms/images/a0f6b517aba16ca5/index.html

Slide 12

Slide 12 text

embrace you don’t know either

Slide 13

Slide 13 text

Through tests we sense the unknowns http://www.dailymail.co.uk/news/article-2381456/How-science-spirit-world-really-makes-Ouija-board-dowsing-rods-move.html

Slide 14

Slide 14 text

(re)think Testing

Slide 15

Slide 15 text

you are testing already 
 (even if you are not) http://www.hongkiat.com/blog/developer-habits/

Slide 16

Slide 16 text

you might just need to formalise http://www.wisegeek.org/what-is-procedural-programming.htm

Slide 17

Slide 17 text

to, eventually, forget this (almost) https://twitter.com/fredzen/status/439774520111419392

Slide 18

Slide 18 text

What is not about Task runner Test Runner Testing Platforms Assertion Frameworks IDEs integration http://strongenough-christina.blogspot.co.uk/2012/10/my-tool-belt.html

Slide 19

Slide 19 text

What it is about http://www.sourcecon.com/news/2010/11/19/sourcing-a-passing-fad-or-a-strategic-move/

Slide 20

Slide 20 text

I Build So Consistently share Identify what to automate create a 
 build script make it continuous

Slide 21

Slide 21 text

“[…] On several occasions I've heard the reply, "Yes, we do CI." 
 Of course, I think, "Great!" and then 
 ask a few questions. 
 How much code coverage do you have with your tests? How long does it take to run your builds? What is your average code complexity? How much code duplication do you have?” – Paul Duvall

Slide 22

Slide 22 text

to DTU* or not to DTU*?
 (* Define Tests Upfront: tdd / bdd / acceptance) http://comicsalliance.com/ryan-north-to-be-or-not-to-be-kickstarter-sets-record/

Slide 23

Slide 23 text

any test is better than no tests, but…

Slide 24

Slide 24 text

Confirmation bias http://www.thezerosbeforetheone.com/confirming-my-own-confirmation-bias

Slide 25

Slide 25 text

“it is a byproduct of test-after- development and manifests itself as the tendency for engineers to only write tests that they know pass.” – Paul Bourdeaux 
 http://www.sundoginteractive.com/sunblog/posts/confirmation-bias-in-unit-testing

Slide 26

Slide 26 text

Code Review vs Pairing http://powerbuilder.us/ http://meetingking.com/mini-meetings-or-pair-programming/

Slide 27

Slide 27 text

Error Management http://comicbooks.about.com/od/ghostrid2/ig/Ghost-Rider-Movie-Gallery/Ghost-Rider-Johnny-Blaze.htm

Slide 28

Slide 28 text

Feedback loop http://www.smashingmagazine.com/2013/02/15/designing-great-feedback-loops/

Slide 29

Slide 29 text

Testing is a way to shape your process, not only your workflow

Slide 30

Slide 30 text

what I learned so far

Slide 31

Slide 31 text

@cedmax turning blank files to bugs since 2003

Slide 32

Slide 32 text

webteam @ Shazam

Slide 33

Slide 33 text

When I started testing http://quoteko.com/lego-block.html http://karenchilvers.mycouncillor.org.uk/2013/09/28/planning-applications-week-ending-27th-september-2013/

Slide 34

Slide 34 text

There is actually much more Unit Behaviour Acceptance Usability System Integration Performance UI Security Scalability …

Slide 35

Slide 35 text

How I see it now Automatable !Automatable Feature Code Unit Acceptance Usability Code Review Linting Styleguide Integration QA Testing

Slide 36

Slide 36 text

Testing code IS appealing (or I have some mom issues, pick one) http://gossip.whyfame.com/demi-moore-and-whoopi-goldberg-pay-tribute-to-ghost-co-star-patrick-swayze-613

Slide 37

Slide 37 text

“Egoism is the very essence of a noble soul.” – Friedrich Nietzsche

Slide 38

Slide 38 text

Interlude How I Learned to Stop Worrying and Love the DOM

Slide 39

Slide 39 text

The curious case of Javascript unit testing Unit testing is supposed to test a single atomic “unit” of functionality without dependencies on anything else This is where you start to run into serious dependency problems due to the interrelation HTML and CSS What do you test? Usually how the user interface responds to user input.

Slide 40

Slide 40 text

standard input/output

Slide 41

Slide 41 text

test('htmlEncode', 1, function() {! ! ! var str = '';! ! ! ! equal(! ! ! ! MyApp.htmlEncode(str), ! ! ! ! '<I love working with JS & CSS>'! ! ! );! });

Slide 42

Slide 42 text

the DOM

Slide 43

Slide 43 text

module('audioPlayer', {! ! ! setup: function(){! ! ! ! ! $('')! ! ! ! ! ! ! .appendTo(document.body);! ! ! },! ! ! teardown: function(){! ! ! ! ! document.body.innerHTML = ';! ! ! }!! ! );! ! test('button state', 2, function() {! ! ! var $elm = $('.audio-play'),! ! ! ! ! player = new MyApp.AudioPlayer($elm);! ! ! ! ! ! ok(!$elm.hasClass(‘audio-playing'));! ! ! ! $elm.trigger('click');! ! ! ok($elm.hasClass('audio-playing'));!! ! });

Slide 44

Slide 44 text

Pub/Sub
 (this is easy)

Slide 45

Slide 45 text

test('logout', 1, function() {! ! ! MyApp.subscribe('user:logout', function(){! ! ! ! ! ok(true);! ! ! });! ! ! ! MyApp.setup();! ! ! $('.logout').trigger('click');! });

Slide 46

Slide 46 text

Mocking api

Slide 47

Slide 47 text

test('windows matchmedia', 2, function() {! ! ! ! ! var spy = sinon.spy(window, 'matchMedia');! ! ! ! MyApp.getDeviceOrientation();! ! ! ! ok(spy.calledOnce);! ! ! ok(spy.calledWith('(orientation:portrait)');! ! ! ! spy.restore();! });

Slide 48

Slide 48 text

test('windows matchmedia', 3, function() {! ! ! var stub = sinon.stub(window, 'matchMedia');! ! ! ! window.matchMedia.returns({! ! ! ! ! matches: false! ! ! });! ! ! ! equal(MyApp.getDeviceOrientation(), 'landscape');! ! ! ok(window.matchMedia.calledOnce);! ! ! ok(window.matchMedia! ! ! ! ! .calledWith('(orientation:portrait)');! ! ! stub.restore();! });

Slide 49

Slide 49 text

AJAX

Slide 50

Slide 50 text

test('ajax call', 2, function() {! ! ! var ajaxStub = sinon.stub($, 'ajax');! ! ! ajaxStub.yieldsTo('success', { results: […] });! ! ! ! ! ! ! equal($('#news li').length, 5);! ! ! ! $('.load-more').trigger('click');! ! ! equal($('#news li').length, 10);! ! ! ! ajaxStub.restore();! });

Slide 51

Slide 51 text

Can’t mock? GET CREATIVE!

Slide 52

Slide 52 text

asyncTest('redirect', 1, function() {!! ! ! ! $('window').on('beforeunload', function(e){! ! ! ! ! e.preventDefault();! ! ! ! ! ok(true, 'redirect works');! ! ! ! ! start();! ! ! });! ! ! ! window.location.href = 'newLocation';! });

Slide 53

Slide 53 text

asyncTest('script onload', 2, function() {! ! ! ! ! var oldIB = HTMLElement.prototype.insertBefore,! ! ! ! ! scripts = [];! ! ! ! ! ! HTMLElement.prototype! ! ! ! ! .insertBefore = function(script){! ! ! ! ! ! ! scripts.push(script);! ! ! ! ! };! ! ! ! ! ! MyApp.loadScript('fake_url', function(){! ! ! ! ! ok(true);! ! ! });! ! ! ! ! var script = scripts[0];! ! ! equal(script.src, 'fake_url');! ! ! ! script.onload();! ! ! ! HTMLElement.prototype.insertBefore = oldIB;!! ! });

Slide 54

Slide 54 text

Selenium Hell Automatable !Automatable Feature Code Unit Acceptance Usability Code Review Linting Styleguide Integration Manual Testing http://beginner.worth1000.com/entries/79392/red-fire

Slide 55

Slide 55 text

Back to square one…

Slide 56

Slide 56 text

“…then you’re doing it wrong” http://www.brianorndorf.com/2010/07/reliving-the-summer-of-1990-week-eight.html

Slide 57

Slide 57 text

No content

Slide 58

Slide 58 text

How to do it right?

Slide 59

Slide 59 text

Forget the framework 
 in the short-term

Slide 60

Slide 60 text

Don’t automate something just because you can

Slide 61

Slide 61 text

Can this be automated? Are there technical reasons why this can’t be automated, or practical reasons why automation isn’t the best candidate ! Does this need to be automated? What is the actual benefit in making this an automated test? How would it benefit the the chain of work? How would it benefit the team? Learn when to automate

Slide 62

Slide 62 text

Prioritise
 (business critical vs nice to have)

Slide 63

Slide 63 text

A learning process

Slide 64

Slide 64 text

Programming is magic

Slide 65

Slide 65 text

“Software development is a learning process, working code is a side effect” – Alberto Brandolini

Slide 66

Slide 66 text

Remember being a kid? https://parentsavvy.com/child-health/?SubtopicId=30014,30017&DocId=1,2954

Slide 67

Slide 67 text

“The greatest thing about being a scientist is you never have to grow up” – Neil deGrasse Tyson

Slide 68

Slide 68 text

A scientific method is by definition, repeatable. 
 
 If an experimental result cannot be verified by repetition, it is not scientific.

Slide 69

Slide 69 text

Applying this method to programming is… http://en.wikipedia.org/wiki/Marie_Curie

Slide 70

Slide 70 text

http://en.wikipedia.org/wiki/Marie_Curie The Spirit of Testing [email protected] http://cedmax.com @cedmax

Slide 71

Slide 71 text

http://en.wikipedia.org/wiki/Marie_Curie The Spirit of Testing [email protected] http://cedmax.com @cedmax