The NiFi developer documentation does a good job of describing how to unit test 
custom processors, including how to configure a controller service that the 
processor depends on. However, it doesn’t provide information on how to best 
unit test a custom controller service.

The biggest challenge I am having is that my controller service has a couple of 
properties that need to be configured in order to test them. The TestRunner 
class has the ability to add a controller service and to set its properties, 
but in order to create a test runner I need a processor that uses the 
controller service. There doesn’t seem to be a way to create a test runner that 
is just used for a controller service.

We’ve been working around this is to create a processor that depends on the 
controller service, then create a TestRunner for that processor, then create an 
instance of the controller service and apply it to the test runner, then use 
the test runner to set its properties. 

Is this the only way to do this? It feels like a bit of a hack if I am creating 
a controller service that is for another team’s processor’s to use. As a result 
I don’t always have my own processor that depends on the controller service I 
want to test. I can of course create one artificially for the purposes of 
testing, but that seems like a lot of extra work just to test my service 
controller.

Thanks,

-Tim

Reply via email to