Hey guys,
Let’s say I’m writing a unit test (well, I am):
@Test
public void testWeb() throws Exception {
Project project = ProjectBuilder.builder().build();
project.getPlugins().apply(WarPlugin.class);
project.getPlugins().apply(RebelPlugin.class);
// Configure the rebel plugin
RebelDslMain rebelExtension = (RebelDslMain) project.getExtensions().getByName(RebelPlugin.REBEL_EXTENSION_NAME);
// [set some configuration properties on my extension]
// HERE .. here i want to somehow say "run this project" (or at least, finish the configuration phase)
RebelGenerateTask task = (RebelGenerateTask) project.getTasks().getByName(RebelPlugin.GENERATE_REBEL_TASK_NAME);
// execute the task
task.generate();
// [ a bunch of asserts that i want to actually test]
}
My problem is that, although i can “run” my task by hand (by calling it’s @TaskAction method “generate()” by hand), my task is not totally configured as in the real situation, as the project’s “afterEvaluate” method is not called (and my plugin is using that callback to propagate a lot of plugin-specific configuration from the extension class to the task class). Could I simulate this somehow or what would be the right thing for me to do?
Thanks!