This is a guided unit test generation tool for Java programs based on JavaParser
You can find the value pool initialization process in src/main/java/edu/illinois/cs/test/generator/PoolInit.java file
You can find the test generation process in src/main/java/edu/illinois/cs/test/generator/TestGenerator.java file
Please find the Application.java file in src/main/java/edu/illinois/cs/test
Run the Application.java file
Attention: remember to change the address of the target folder you want to generate its tests
If you want to see the code coverage report by Clover, please check the Clover branch. To check the coverage report, use the following command:
$ mvn clean clover:setup test clover:aggregate clover:clover
The report is the index.html under the target/site/clover directory.
PoolInit pool = new PoolInit("target class address (e.g. src/main/java/edu/illinois/cs/test/)");
TestGenerator tg = new TestGenerator("target class address (e.g. src/main/java/edu/illinois/cs/test/)");
Attention: You can also modify this function to target a specific class
public void MethodTraverse(String target) {
Path sourcePath = Paths.get(target);
SourceRoot sourceRoot = new SourceRoot(sourcePath);
try {
Files.walk(sourcePath)
.filter(path -> path.toString().endsWith(".java"))
.forEach(path -> {
try {
CompilationUnit cu = parse(path.toFile());
visit(cu, null);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
});
} catch (IOException e) {
e.printStackTrace();
}
}
For instance, if you want to generate tests for Entities class, you can change ".java" to the filename of the class
The tool mainly focuses on Jsoup project, so it may have some other undesired bugs when you try to run it on other projects
For more information, please see the report