Unit testing

Some parts of the examination require implementing methods adhering to a given specification. Consider an example:

Figure 340. Recommended reading Slide presentation Create comment in forum

Figure 341. Test categories Slide presentation Create comment in forum
  • Unit test: Test individual methods, classes and packages in isolation.

  • Integration Test: Test a group of associated components/classes.

  • Acceptance / Functional Test: Operate on a fully integrated system, testing against the user interface.

  • Regression Test: Ensure system integrity after (implementation) change.

  • Load test: Responsiveness vs. system load.


Figure 342. Example: Computing prime numbers Slide presentation Create comment in forum

Informal problem specification:

A prime number is a whole number greater than 1 whose only factors are 1 and itself.

Examples: 2, 3, 5, 7, 11, 13, 17, 23, ...


Figure 343. Unit test principle Slide presentation Create comment in forum

Figure 344. Test driven development Slide presentation Create comment in forum

First write tests, then implement.


Figure 345. Steps in Unit Testing Slide presentation Create comment in forum
  1. Specify but not yet implement classes / methods.

  2. Write skeleton (dummy) implementations.

  3. Write corresponding unit tests.

  4. Implement skeleton.

  5. Test your implementation.