Application testing
In addition to the normal unit tests for individual functions or other small units of behavior, Apex simplifies the task of integration testing of the entire application directly on the command line of your development machine, or within your IDE without the need to set up an entire Hadoop cluster, which can be a tedious process. When developing Apex applications, it is very important to use this mechanism so that bugs can be discovered and corrected early in the development process.
As described in Chapter 2, Getting Started with Application Development, a single JUnit test is encapsulated in a method of the test class (SampleApplicationTest
in this case), which is annotated with @Test
. But there is a bit more to this test due to its dependence on external servers, namely, ZooKeeper and Kafka. To facilitate this, we use the testing library from https://github.com/chbatey/kafka-unit, specifically the KafkaUnit
and KafkaUnitRule
classes:
private final String testTopicData...