-
Notifications
You must be signed in to change notification settings - Fork 28
What is a Unit Test?
Home -> User Guide -> General User Guide -> About Unit Testing
The term unit test has no standard definition. Different people have different ideas in mind when they use the term.
Cobol-check is mainly concerned with supporting existing (legacy) mainframe applications. In the mainframe world, a unit of code is usually considered to be a load module - what other people call an executable. IBM's zUnit product, for unit-testing mainframe programs, considers a load module as the "unit" to be tested. Reference: IBM: z/OS Automated Unit Testing Framework (zUnit) Overview.
Mainframers use the term compilation unit to refer to the set of sources that are compiled together, and the term run unit to refer to the set of object-code artifacts that are executed together. They generally do not think in terms of testing finer-grained subsets of code in isolation, as we do with other languages on other platforms. The reason is the system was never designed to allow bits and pieces of procedural-language programs to run separately from the program of which they are a part.
When unit testing code in Java, C#, Python, Ruby, and other object-oriented languages, we consider a single method to be a unit, and a single logical path through that method to be a suitable unit test case. For functional languages and general languages that have functional programming features, like JavaScript or F#, a module or a single function might be considered a unit of code.
Unit test code can invoke a single method or function alone, and check the result of the call. Cobol does not offer a built-in way to do the equivalent: To invoke a single paragraph alone, and check the result of the perform.
One of the main design goals of cobol-check is to enable mainframe Cobol programmers to test (check) individual paragraphs in Cobol programs in isolation, without having to execute the entire program. This is conceptually similar to checking a single Java method, although the implementation of Cobol paragraphs is different from the implementation of Java methods.
Michael Feathers came up with a list of characteristics that indicate a test case is not a unit test A Set of Unit Testing Rules (Michael Feathers). He writes:
A test is not a unit test if:
- It talks to the database
- It communicates across the network
- It touches the file system
- It can't run at the same time as any of your other unit tests
- You have to do special things to your environment (such as editing config files) to run it.