Slide 1

Slide 1 text

@BERMONPAINTER TEST FRAMEWORK SHOWDOWN

Slide 2

Slide 2 text

Types of Tests TESTS. LOTS OF TESTS. • SMOKE TESTS • INTEGRATION TESTS • USER ACCEPTANCE TESTS • REGRESSION TESTS • UNIT TESTS

Slide 3

Slide 3 text

Types of Tests TESTS. LOTS OF TESTS. • SMOKE TESTS • INTEGRATION TESTS • USER ACCEPTANCE TESTS • REGRESSION TESTS • UNIT TESTS

Slide 4

Slide 4 text

Unit Tests TESTS. LOTS OF TESTS. ENSURE YOU BUILD THE THING RIGHT

Slide 5

Slide 5 text

Unit Tests TESTS. LOTS OF TESTS. ENSURE YOU BUILD THE THING RIGHT • code functions as designed

Slide 6

Slide 6 text

Unit Tests TESTS. LOTS OF TESTS. ENSURE YOU BUILD THE THING RIGHT • code functions as designed • run when code it compiled

Slide 7

Slide 7 text

Unit Tests TESTS. LOTS OF TESTS. ENSURE YOU BUILD THE THING RIGHT • code functions as designed • run when code it compiled • run as a suite of tests

Slide 8

Slide 8 text

Unit Tests TESTS. LOTS OF TESTS. ENSURE YOU BUILD THE THING RIGHT • code functions as designed • run when code it compiled • run as a suite of tests • better documentation

Slide 9

Slide 9 text

Unit Tests TESTS. LOTS OF TESTS. ENSURE YOU BUILD THE THING RIGHT • code functions as designed • run when code it compiled • run as a suite of tests • better documentation • uncover bugs pre-QA

Slide 10

Slide 10 text

TDD TDD vs BDD

Slide 11

Slide 11 text

TDD TDD vs BDD 1. Write tests

Slide 12

Slide 12 text

TDD TDD vs BDD 1. Write tests 2. Tests fail

Slide 13

Slide 13 text

TDD TDD vs BDD 1. Write tests 2. Tests fail 3. Write code

Slide 14

Slide 14 text

TDD TDD vs BDD 1. Write tests 2. Tests fail 3. Write code 4. Tests pass

Slide 15

Slide 15 text

TDD TDD vs BDD 1. Write tests 2. Tests fail 3. Write code 4. Tests pass 5. Refactor

Slide 16

Slide 16 text

TDD TDD vs BDD 1. Write tests 2. Tests fail 3. Write code 4. Tests pass 5. Refactor 6. Repeat

Slide 17

Slide 17 text

BDD TDD vs BDD

Slide 18

Slide 18 text

BDD TDD vs BDD 1. Establish goals/vision

Slide 19

Slide 19 text

BDD TDD vs BDD 1. Establish goals/vision 2. Involves team to describe the behavior of an app.

Slide 20

Slide 20 text

BDD TDD vs BDD 1. Establish goals/vision 2. Involves team to describe the behavior of an app 3. Create code based on the behavior descriptions

Slide 21

Slide 21 text

BDD TDD vs BDD 1. Establish goals/vision 2. Involves team to describe the behavior of an app 3. Create code based on the behavior descriptions 4. Automate the testing of your code (feedback/ regression testing)

Slide 22

Slide 22 text

1. Describe Behaviors (STAKEHOLDER + TEAM) ! 2. Write Scenarios/Specs (DEVELOPERS) ! 3. Run Tests (TESTS FAIL) ! 4. Write Code for Tests to Pass ! 5. Run Tests (TESTS PASS) FAIL PASS REFACTOR

Slide 23

Slide 23 text

The hardest single part of building a software system is deciding precisely what to build. ! - Fred Brooks

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

BEHAVIOR DRIVEN DEVELOPMENT FRAMEWORK

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

JavaScript JASMINE ANATOMY function helloWorld() { return “Hello World!”; }

Slide 32

Slide 32 text

Suites JASMINE ANATOMY describe (“Hello World”, function(){ ! . . . ! });

Slide 33

Slide 33 text

Specifications JASMINE ANATOMY describe (“Hello World”, function(){ it(“Says hello to everybody”, function(){ . . . }); });

Slide 34

Slide 34 text

Matchers JASMINE ANATOMY describe (“Hello World”, function(){ it(“Says hello to everybody”, function(){ expect(helloWorld().toEqual(“Hello world!”)); }); });

Slide 35

Slide 35 text

Matchers JASMINE ANATOMY • expect() • toEqual() • toBeTruthy() • toBeFalsy() • toContain() • toBeDefined() • toBeUndefined() • toBeLessThan() • toBeGreaterThan() • toMatch()

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

Utilities JASMINE ANATOMY • beforeEach() • afterEach()

Slide 38

Slide 38 text

beforeEach() JASMINE ANATOMY var runnerWideFoo = []; beforeEach(function () { runnerWideFoo.push('runner'); }); describe('some suite', function () { beforeEach(function () { runnerWideFoo.push('suite'); }); it('should equal bar', function () { expect(runnerWideFoo).toEqual(['runner', 'suite']); }); });

Slide 39

Slide 39 text

afterEach() JASMINE ANATOMY describe('some suite', function () { var suiteWideFoo = 1; afterEach(function () { suiteWideFoo = 0; }); it('should equal 1', function () { expect(suiteWideFoo).toEqual(1); }); it('should equal 0 after', function () { expect(suiteWideFoo).toEqual(0); }); });

Slide 40

Slide 40 text

Spies JASMINE ANATOMY

Slide 41

Slide 41 text

Spies - Matchers JASMINE ANATOMY • toHaveBeenCalled() • toHaveBeenCalledWith() • andCallThrough() • andReturn() • andThrow() • andCallFake()

Slide 42

Slide 42 text

Example

Slide 43

Slide 43 text

Writing Specs BENEFITS & BEST PRACTICES TO GET THE MOST OUT OF JASMINE & BDD

Slide 44

Slide 44 text

Improve team communication BENEFITS

Slide 45

Slide 45 text

Encourages discussions among all team members BENEFITS

Slide 46

Slide 46 text

Better integration & acceptance testing BENEFITS

Slide 47

Slide 47 text

Describe specs, not a sequence of actions BEST PRACTICES

Slide 48

Slide 48 text

Keep specs at a high level BEST PRACTICES

Slide 49

Slide 49 text

Hide complexity in the implementation of the specs BEST PRACTICES

Slide 50

Slide 50 text

Test the most important/risky pieces of the system first BEST PRACTICES

Slide 51

Slide 51 text

Write tests until the remaining risk isn't worth the time & money to address BEST PRACTICES

Slide 52

Slide 52 text

You should not be afraid to delete tests that are no longer providing value, no matter whether you originally planned to keep them or not. We tend to treat tests as these holy creatures that live blameless, irreproachable lives once they have sprung into existence. ! Not so. ! The maintenance required to keep a test running weighs against its value in further development. Sometimes these lines cross, and the test simply becomes a burden on the project. Having the skill and experience to recognize a burdensome test is something we should be bringing to our clients, as well as the fortitude to rewrite it, rethink it, or delete it. ! - Adam Milligan

Slide 53

Slide 53 text

Fin. @BERMONPAINTER