Why Testing in a Nutshell

Damien Cassou, Stéphane Ducasse and Luc Fabresse http://stephane.ducasse.free.fr

Goal of the lecture

Tests in a nutshell

Testing Style

" The style here is to write a few lines of code, then a test that should run, or even better, to write a test that won't run, then write the code that will make it run. "

Developers should spend 25-50% of their time developing tests.

But I can’t cover everything!

Whenever you are tempted to type something into a print statement or a debugger expression, write it as a test instead. Martin Fowler

Unit Tests

A Test

A test

A Test

A test

Set TestCase

TestCase subclass: # SetTestCase
    ...
SetTestCase >> testAdd 
  | empty |
  empty := Set new.                      "Context"
  empty add: 5.                             "Stimulus"
  empty add: 5. 
  self assert: empty size = 1.        "Check"

SetTestCase run: #testAdd

Good Tests

/