mkarneim/pojobuilder — Issue #6: Add some environment for doing acceptance tests
Author: mkarneim
Created: 2011-10-29 19:02:46+00:00
State: open

Acceptance test for code generators must run the annotation processor from a JUnit test.

For that we need some environment class that helps with that, e.g. to support the following test:

Environment env;

@Test
public void processorCreatesClassForAnnotatedPojo() throws Exception {
// Given there is an annotated pojo source file
env.addSourceFile("src/test/data/testdata/SimpleAnnotatedPojo.java");

// When the compilation is invoked
boolean success = env.compile();

// Then a new builder class is generated with a matching name
Assert.assertTrue("success", success);
Class newClass = env.findClass("testdata.SimpleAnnotatedPojoBuilder");
Assert.assertNotNull("newClass", newClass);
}