Tomas Petricek
email: t.petricek@kent.ac.uk
twitter: @tomaspetricek
office: S129A
Debugging-oriented period (circa 1940s-1956)
Program checkout involves debugging or testing
Interpretative checking routines and post-
mortem dumps
Demonstration-oriented period (1957-1978)
Testing to show program correctness
Last step in the Waterfall methodology
Can we exhaustively
cover all cases?
Destruction-oriented period (1979-1980s)
Program testing can be used to show the presence of bugs, but never to show their absence (Dijkstra, 1970)
Professional testers focus on finding bugs through tests.
Evaluation-oriented period (1980s-now)
Testing as measurable part of development process
New theories and tools to support testing
Tests for ensuring quality
Tests as a feedback mechanism
1: 2: 3: 4: 5: 6: 7: 8: |
|
Writing Java tests with JUnit
Write @Test
methods and assertEqual
to check results.
Run tests from Eclipse or terminal using Maven
Unit tests are just one, easy to automate kind
How to structure code to make testing easy?
How to test not just functions, but user interfaces
Property testing to specify more than one case
Development methodology
TDD in practice
Red-Green-Refactor
Originated in dynamic languages
Active tests vs. types debate!
Tests as executable user stories (BDD)
Do people really write tests first?
Structuring program logic
Mocking frameworks
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: |
|
Using the Java Mockito mocking framework
Create object using mock
Configure its returns using when
and thenReturn
Use it as a normal object!
How to cover all cases
Random testing
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: |
|
Using the jqwik tool
Mark method as a @Property
Annotate arguments to specify input ranges
Return true
if the
property holds!
Use simpler working implementation (oracle)
Use mathematical property (e.g., average)
Check for more basic facts
Algebraic properties like associativity
Brief history of testing
Debugging-oriented, demonstration-oriented
destruction-oriented & evaluation-oriented
Unit testing and tools
Unit testing library, test runners,
tools for mocking and random testing
Test-driven development
"Scientific" XP development methodology
Done through the red-green-refactor cycle
What you should remember from this lecture
Tomas Petricek
t.petricek@kent.ac.uk | @tomaspetricek
Papers and articles