Unit Testing
Mule ESB provides a Test Compatibility Kit (TCK) of unit tests that you can use to test your simple extensions as well as your custom modules and transports. The unit tests are located in the -tests.jar
file, such as mule-core-3.0.0-tests.jar
for Mule version 3.0.0. All unit tests inherit from org.mule.tck.AbstractMuleTestCase.
These unit tests are beneficial for the following reasons:
-
Components tested with a TCK test case ensure that the common behavior of the component is compatible with the Mule framework.
-
Using a TCK test case allows the developer to concentrate on writing tests for specific behavior of their component.
-
Where testing of a method in the Service Component API cannot be tested by the TCK test case, the test cases provides an abstract method for the test, ensuring the developer tests all areas of the component.
-
The TCK provides a default test model that is a simple set of test classes. The developer doesn’t need to worry about writing new test classes for their test cases each time.
-
The abstract test cases in the TCK use JUnit’s
TestCase
, so they are compatible with other test cases.
Following is a description of some of the unit tests in the Mule TCK:
Testing Component | Description |
---|---|
|
A helper test case providing methods for creating test and mock object types. This is the base class for all other abstract TCK classes. |
|
Used to test the common behavior of a connector. This tests dispatching and sending events using mock objects. |
|
Provides tests for all the standard methods defined in the |
|
Used to test the common behavior of a |
|
This is the base class for unit tests that test custom component implementations. Concrete subclasses of this base class include |
|
Used to test transformers. This class defines a number of tests that ensures that the transformer works in single scenarios as well as in round trip scenarios. There are many concrete sub-classes of this abstract class that test specific types of transformers, such as |
|
Tests the creation and disposal of the Mule context. |
|
An abstract test case that provides methods for testing the starting, stopping, pausing, resuming, and disposing of services. |