Unit testing in Design Studio does not need to be implemented to complete a cartridge, although it is highly recommended for these reasons:
Unit testing contributes to building quality code.
Unit testing provides repeatable tests for regression.
You can test the processor outside of the ASAP system because the interfaces and generative classes of the Java processor are all independent of the ASAP system and its classes (the generated InputBeans and output are not tied to ASAP). To run the processor, a TestCase
is generated once (with a sample test based on information at the time of creation), after which the developer owns it and can extend it.
The unit test framework initiates all tests in test subfolder. Unit testing is implemented as a JUnit test. JUnit tests can optionally be run with the JDT Debugger.
The TestCase
simulates the proxy for each individual test, and:
Creates an implementation of the interfaces, either the real implementation or a stubbed test implementation.
Generates input and output beans.
Invokes the processor.
The TestCase
is a JUnitTestCase
. Each TestCase
can contain many tests, and each test is defined by a no-parameter method beginning with "test".
The generated TestCase
has a framework that provides a test. The test runs based on input files, which find the data and test criteria for a particular test. This framework enables developers to create simple files to define new tests. This works for any standard type of test where you pass in data and check the request to ensure it was sent as expected, and that the returned exit type is the one you expected. Also, this allows for a simple, standard response to be used inside the test.
Sample test classes are provided for simulating IExit
and ILogger
. A base output class provides the methods required for output classes.
Running Unit Tests with the JDT Debugger
Understanding Unit Test Property Files