1 of 13

Testing patterns

Junior Developer Workshop

Kevin Guillaumond

April 7th, 2017

2 of 13

Reference

xUnit Test Patterns

Gerard Meszaros, 2007

http://xunitpatterns.com/

2

3 of 13

Why do we test?

3

  • Limit number of bugs in production code

  • Catch defects early
    • Programming mistakes
    • Regression

4 of 13

When we find bugs

4

When

Who finds it

Who knows

Time to find the bug

Before check-in

You

1

~ minutes

During code review

Teammate (dev)

Team devs

~ hours

Manual component testing

Teammate (QA)

Whole team

~ days

Manual integration testing

Service Level QA

Team + SL

~ weeks

In production

Client

Everybody

~ weeks / months

5 of 13

Why do we test?

  • Use tests as specification

5

  • Limit number of bugs in production code

  • Catch defects early
    • Programming mistakes
    • Regression

6 of 13

What to test?

6

7 of 13

Goals of test automation

The addition of tests should:

  • Improve the quality of the system
  • Help us understand the system
  • Reduce the risks

The tests should:

  • Be easy to run
  • Be easy to verify
  • Be easy to write
  • Require minimal maintenance

7

8 of 13

Goals of test automation

8

9 of 13

Tools

The xUnit family is a set of testing frameworks for different languages

  • NUnit
  • JUnit
  • RUnit
  • VbUnit

Class <-> Test class

Method <-> Several test methods

9

10 of 13

Code example: simplified French roulette

Bet on a number from 0 to 36

If your number comes up, payout is 35:1

Example: You bet $1 on 7

  • 7 comes up -> You win $35
  • Otherwise -> You lose your $1

10

11 of 13

Links

  • Project on Bitbucket
  • My notes

11

12 of 13

More on testing

  • Design for testability
  • Continuous Integration (CI)
  • Behavior Verification VS State Verification
  • Acceptance testing (FitNesse)
  • ...

12

13 of 13

Questions / discussions

13