Defects4J is a collection of reproducible bugs and a supporting infrastructure with the goal of advancing software engineering research.
Defects4J contains 438 bugs from the following open-source projects:
Identifier | Project name | Number of bugs |
---|---|---|
Chart | JFreeChart | 26 |
Closure | Closure compiler | 176 |
Lang | Apache commons-lang | 65 |
Math | Apache commons-math | 106 |
Mockito | Mockito | 38 |
Time | Joda-Time | 27 |
Each bug has the following properties:
- Issue filed in the corresponding issue tracker, and issue tracker identifier mentioned in the fixing commit message.
- Fixed in a single commit.
- Minimized: the Defects4J maintainers manually pruned out irrelevant changes in the commit (e.g., refactorings or feature additions).
- Fixed by modifying the source code (as opposed to configuration files, documentation, or test files).
- A triggering test exists that failed before the fix and passes after the fix -- the test failure is not random or dependent on test execution order.
The (b)uggy and (f)ixed program revisions are labelled with <id>b
and
<id>f
, respectively (<id>
is an integer).
A number of additional bugs are available in "work-in-progress" status. These bugs meet the same properties as the ones above, but have only been minimized by one of the maintainers. Metadata and patch content can potentially change before these bugs are migrated into the master repository. These bugs may be used in experiments, but should not be considered as "stable" as the bugs in the master repository. If you use these bugs, please ackowledge their "beta status" in any publications.
Branch commons-compress-collections:
Identifier | Project name | Number of bugs |
---|---|---|
Collections | Apache commons-collections | 28 |
Compress | Apache commons-compress | 47 |
Branch additional-projects-4:
Identifier | Project name | Number of bugs |
---|---|---|
Cli | Apache commons-cli | 40 |
Codec | Apache commons-codec | 18 |
Csv | Apache commons-csv | 16 |
Gson | Google Gson | 18 |
JacksonCore | Jackson JSON parser | 26 |
JacksonDatabind | Jackson data bindings | 112 |
JacksonXml | Jackson XML extension | 6 |
JxPath | Apache commons-jxpath | 22 |
Jsoup | jsoup HTML Parser | 93 |
- Java 1.7
- Git >= 1.9
- SVN >= 1.8
- Perl >= 5.0.10
All bugs have been reproduced and triggering tests verified, using the latest version of Java 1.7. Note that using Java 1.8+ might result in unexpected failing tests on a fixed program version. The next major release of Defects4J will be compatible with Java 8.
All required Perl modules are listed in cpanfile
. On many Unix platforms,
these required Perl modules are installed by default. If this is not the case,
you can use cpan (or a cpan wrapper) to install them. For example, if you have
cpanm installed, you can automatically install all modules by running:
cpanm --installdeps .
Defects4J generates and executes tests in the timezone America/Los_Angeles
.
If you are using the bugs outside of the Defects4J framework, set the TZ
environment variable to America/Los_Angeles
and export it.
-
Clone Defects4J:
git clone https://github.com/rjust/defects4j
-
Initialize Defects4J (download the project repositories and external libraries, which are not included in the git repository for size purposes and to avoid redundancies):
cd defects4j
./init.sh
-
Add Defects4J's executables to your PATH:
export PATH=$PATH:"path2defects4j"/framework/bin
-
Check installation:
defects4j info -p Lang
-
Get information for a specific project (commons lang):
defects4j info -p Lang
-
Get information for a specific bug (commons lang, bug 1):
defects4j info -p Lang -b 1
-
Checkout a buggy source code version (commons lang, bug 1, buggy version):
defects4j checkout -p Lang -v 1b -w /tmp/lang_1_buggy
-
Change to the working directory, compile sources and tests, and run tests:
cd /tmp/lang_1_buggy
defects4j compile
defects4j test
-
The scripts in
framework/test/
are examples of how to use Defects4J, which you might find useful as inspiration when you are writing your own scripts that use Defects4J.
Use framework/bin/defects4j
to execute any of the following commands:
Command | Description |
---|---|
info | View configuration of a specific project or summary of a specific bug |
checkout | Checkout a buggy or a fixed project version |
compile | Compile sources and developer-written tests of a buggy or a fixed project version |
test | Run a single test method or a test suite on a buggy or a fixed project version |
mutation | Run mutation analysis on a buggy or a fixed project version |
coverage | Run code coverage analysis on a buggy or a fixed project version |
monitor.test | Monitor the class loader during the execution of a single test or a test suite |
export | Export version-specific properties such as classpaths, directories, or lists of tests |
Use defects4j export -p <property_name> [-o output_file]
in the working
directory to export a version-specific property:
Property | Description |
---|---|
classes.modified | Classes (source files) modified by the bug fix |
cp.compile | Classpath to compile and run the project |
cp.test | Classpath to compile and run the developer-written tests |
dir.src.classes | Source directory of classes (relative to working directory) |
dir.bin.classes | Target directory of classes (relative to working directory) |
dir.src.tests | Source directory of tests (relative to working directory) |
dir.bin.tests | Target directory of test classes (relative to working directory) |
tests.all | List of all developer-written test classes |
tests.relevant | List of relevant tests classes (a test class is relevant if, when executed, the JVM loads at least one of the modified classes) |
tests.trigger | List of test methods that trigger (expose) the bug |
The test execution framework for generated test suites (framework/bin
)
provides the following scripts:
Script | Description |
---|---|
defects4j | Main script, described above |
run_bug_detection | Determine the real fault detection rate |
run_mutation | Determine the mutation score |
run_coverage | Determine code coverage ratios (statement and branch coverage) |
run_evosuite | Generate test suites using EvoSuite |
run_randoop | Generate test suites using Randoop |
We welcome your contributions to Defects4J! The bug-mining README details the bug-mining process.
- Scripts and annotations for evaluating APR techniques
- Patches generated with the Nopol, jGenProg, and jKali APR systems
- Repair actions and patterns for Defects4J v1.2.0
-
"Defects4J: A Database of Existing Faults to Enable Controlled Testing Studies for Java Programs" René Just, Darioush Jalali, and Michael D. Ernst, ISSTA 2014 [download].
-
"Are Mutants a Valid Substitute for Real Faults in Software Testing?" René Just, Darioush Jalali, Laura Inozemtseva, Michael D. Ernst, Reid Holmes, and Gordon Fraser, FSE 2014 [download].
-
"Challenges in Using Search-Based Test Generation to Identify Real Faults in Mockito" Gregory Gay. SSBSE 2016 [download].
Documentation for any script or module is available as HTML documentation.
The directory structure of Defects4J is as follows:
defects4j
|
|--- project_repos: The version control repositories of the provided projects.
|
|--- major: The Major mutation framework.
|
|--- framework: Libraries and executables of the core, test execution,
| and bug-mining frameworks.
|
|--- bin: Command line interface to Defects4J.
|
|--- bug-mining: Bug-mining framework.
|
|--- core: The modules of the core framework.
|
|--- lib: Libraries used in the core framework.
|
|--- util: Util scripts used by Defects4J.
|
|--- projects: Project-specific resource files.
|
|--- test: Scripts to test the framework.
Defects4J uses a semantic versioning scheme (major
.minor
.patch
):
Change | major |
minor |
patch |
---|---|---|---|
Addition/Deletion of bugs | X | ||
New/upgraded internal or external tools | X | ||
Fixes and documentation changes | X |
MIT License, see license.txt
for more information.