Unit Testing

Unit test is codes that exercise a module (exactly one) and compare the result of it to the expected output. The testing should be done in an isolated environment (controlled conditions) where we’ll check the return value of the component against known values or results from previous runs of the same test (regression testing).

It is #recommended testing the subcomponents first before testing on the main module in which we’ll have a composable testing facility. However, don’t test every public method if they are too simple to test as advised by Fowler.

The tips on writing effective Unit Tests is to think of the boundary conditions under which things might go wrong. It includes possible raised #exception. Concentrate our tests there with a mindset of trying to break the test by specifying possible special cases.

Sometimes, we do write some simple tests while debugging. Don’t toss away them. Formalise those tests into the test suit.

With unit testing in mind, developer will consciously design a program that is highly modular#. Regression Testing# could be implemented to further enhance the validity of the written unit tests to see whether they are adhered to the specified requirements.

Links to this page
#test #exception