Unit testing

Unit testing is a process in software development that makes it possible to check for errors in the various components or modules of the software. In databases, those components are stored procedures, functions, triggers, and so on. A view definition, or even a code of queries that applications use, can also be an object for unit testing.

The idea behind unit testing is that for every module of a software system, like class or function, there is a set of tests that invokes that module with a certain input data and checks whether the outcome of the invocation matches the expected result. When a module being tested needs to interact with other systems, those systems can be emulated by the test framework so that the interaction can also be tested.

The set of tests should be big enough to cover as much of the source code of the tested module as possible. This can be achieved when the tests imply invocation of the tested code with all possible logical combinations of values of the input parameters. If the tested module is supposed to be able to react on invalid data, the tests should include that as well. The execution of those tests should be automated, which makes it possible to run the tests each time a new release of the tested module is developed.

All this makes it possible to change the software, and then quickly check whether the new version still satisfies the old requirements. This approach is called regression testing.

There is a technique in software development called test-driven development. It implies writing tests that reflect the requirements of a software component first, and then developing code which satisfies the tests. In the end, the developer will have working code that is covered with tests and good, formally defined functional requirements for the module.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset