Instantiate TestRunner
Most unit tests for a Processor or a Controller Service start by creating an instance of
the TestRunner
class. In order to add the necessary classes to your
Processor, you can use the Maven dependency:
<dependency> <groupId>org.apache.nifi</groupId> <artifactId>nifi-mock</artifactId> <version>${nifi version}</version> </dependency>
We create a new TestRunner
by calling the static
newTestRunner
method of the TestRunners
class
(located in the org.apache.nifi.util
package). This method takes a single
argument. That argument can either be the class of the Processor to test or can be an
instance of a Processor.