I was wondering what the best way would be to test rules in a plugin.? For instance if my new plugin adds a rule for ‘foobarXXX’, how can I go about in a unit test to test that the correct tasks will be added and configured?
You can unit test this with a ProjectBuilder
. Effectively, the task will be created as soon as it is referenced from the TaskContainer
. Just apply your plugin to the project, access the task, and define your assertions.
1 Like
Oh yeah baby, it works quite nice. Once the rule has been created then you simply can do something like
given:
Task myTestTask = project.tasks.findByName('foobarTask')
expect:
myTestTask instanceof MyRuleInstantiatedTask
in a Spock unittest .