This project generates test prefixes for each bug in Defects4J. A test prefix is defined as the non-assertion statements in a test case that set up a program state to be evaluated. For example:
public class MyClassTest {
@Test
public void addTest() {
int a = 5; // prefix
int b = 3; // prefix cont.
int sum = add(a, b); // prefix cont.
assertEqual(8, sum); // oracle
}
}Defects4J contains both buggy and fixed versions of the same program. This repository uses the buggy program version to generate test prefixes. Specifically, this project uses the gen_tests command from Defects4J with EvoSuite to generate a test suite for each class modified between the buggy and fixed program versions. Then, the OracleRemover class from the Tratto project is used to remove all oracles from the test suite.
Follow the instructions on the Defects4J GitHub page to clone and set up the Defects4J repository. Then, export the Defects4J directory to your path in a local terminal window:
export DEFECTS4J_HOME="path/to/defects4j"The command must be repeated any time a new terminal window is opened. Alternatively, open the script ./script/util/global_variables.sh,
uncomment the line #DEFECTS4J_HOME="path_to_defects4j"and set the DEFECTS4J_HOME variable to the path of the Defects4J repository permanently.
We automate the installation of SDKMan by running the script:
bash ./script/util/init.sh(1) Get a list of all modified classes in Defects4J:
./script/util/modified_classes.sh(2) Generate prefixes for each class in each Defects4J bug:
./script/prefix.sh(Optional) To only generate prefixes for a specific project bug, add the project name and bug id as arguments:
./script/prefix.sh [project-name] [bug-id]For example,
./script/prefix.sh Closure 2