@Test public void shouldLookForClassesInTargetDirectories() throws Exception { newDir = new File("tempClassDir"); List<File> buildPaths = asList(newDir); ClasspathProvider classpath = new StandaloneClasspath( buildPaths, FakeEnvironments.systemClasspath() + pathSeparator + newDir.getAbsolutePath()); String classname = "org.fakeco.Foobar"; createClass(classname); builder = new JavaClassBuilder(classpath); JavaClass javaClass = builder.createClass(classname); assertEquals(classname, javaClass.getName()); assertFalse(javaClass.isATest()); }
private void createClass(String classname) throws CannotCompileException, IOException { ClassPool pool = ClassPool.getDefault(); CtClass foobarClass = pool.makeClass(classname); foobarClass.writeFile(newDir.getAbsolutePath()); }