Module tests, often referred to as unit tests or component tests, are used to check the in­di­vidu­al com­pon­ents of computer programs. With these tests, you can examine whether in­di­vidu­al parts are func­tion­ing correctly before they are properly in­teg­rated into the overall software concept. These tests are useful, as they enable you to quickly and easily check whether the com­pon­ents are working as the developer intended them to. Module tests are one of the most effective ways to detect as many errors as possible in the earlier stages of the program code.

In general, module tests play an important role in the quality assurance of software. This method is par­tic­u­larly used in agile software de­vel­op­ment, where the goal is to carry out a lot of component tests. This is also the reason they are performed auto­mat­ic­ally. Cor­res­pond­ing programs can execute a number of module tests at the push of a button. Usually, the test program that’s used is written in the same language as the test object itself.

What are module tests used for?

You often hear unit tests being mentioned, since the smallest units of the software are checked. And it just so happens that the smallest units are, in fact, the modules.

It is advisable to check for errors early on in the software de­vel­op­ment process, since they can be quickly and cost-ef­fect­ively rectified in the module test phase. In later phases, rec­ti­fy­ing these mistakes can prove costly. Module tests primarily deal with func­tion­al prop­er­ties. Typically, the developer performs the tests himself and ensures that all the functions are working correctly.

Test en­vir­on­ments with module tests

An important feature of module tests is their ability to be isolated. This test performs a specific function, while all external in­flu­ences, such as com­mu­nic­a­tion with other systems, are excluded. Since in­ter­ac­tions with other com­pon­ents are left out, it is possible to clearly identify any errors that might occur in the isolated module.

Modules are tested in a stan­dalone en­vir­on­ment. This special test en­vir­on­ment has to be created first, which can turn out to be a re­l­at­ively complex and very time-consuming process. Since a module is not self-ex­ecut­able, a 'test harness' is needed in order to perform the testing. The test object can only form an ex­ecut­able program with this test harness in place. In order to create a realistic test en­vir­on­ment, stubs are used to serve as place holders for when the module (to be tested) requires other com­pon­ents to interact with it.

Test frame­works for module tests

The goal of module tests is to detect errors within in­di­vidu­al com­pon­ents. If you want to ensure that a code is correct over the entire de­vel­op­ment period, you have to con­stantly run unit tests. Here, auto­ma­tion is key. There are special software test frame­works that are used to perform module tests. Suitable module test software is available for almost all pro­gram­ming languages. It reads the source code and checks for errors. The test en­vir­on­ment described above produces the tools auto­mat­ic­ally, and the developer focuses on defining the test cases. A detailed list of available test frame­works for in­di­vidu­al pro­gram­ming languages can be found here.

Go to Main Menu