This repository contains code for the following research tools:
Head to the
Wiki for detailed tutorials!
Pankti transforms production workloads into test cases. The test generation pipeline consists of four phases:
If you use this code for academic research, please cite: "Production Monitoring to Improve Test Suites", In IEEE Transactions on Reliability, 2021.
@article{arXiv-2012.01198,
title = {Production Monitoring to Improve Test Suites},
journal = {IEEE Transactions on Reliability},
year = {2021},
doi = {10.1109/TR.2021.3101318},
author = {Deepika Tiwari and Long Zhang and Martin Monperrus and Benoit Baudry},
}
pankti-extract leverages Spoon to statically analyze Java applications in order to find relevant methods for test generation. The output is a list of methods that meet the following criteria:
To run pankti-extract,
cd /path/to/pankti/pankti-extract/
mvn clean install
java -jar target/pankti-extract-<version>-jar-with-dependencies.jar /path/to/maven/project
-h
(--help
) for usage, -v
(--void
) to include methods that return void/path/to/pankti/pankti-extract/
called extracted-methods-\<project-name>.csv.method.json
files)
python find-pseudo-tested.py /path/to/method/list/from/step5.csv /space/separated/paths/to/descartes/method.json
outputs a CSV with the list of methods that are candidates for instrumentation.
pankti-instrument is a Glowroot (download) plugin that serializes objects for instrumented methods that are invoked. pankti-instrument uses the Plugin API of Glowroot to instrument the methods extracted from pankti-extract.
To run pankti-instrument,
cd /path/to/pankti/pankti-instrument/
python instrument.py <path/to/instrumentation/candidates/from/previous/phase>.csv
se.kth.castor.pankti.instrument.plugins
. These aspect classes are also included in ./src/main/resources/META-INF/glowroot.plugin.json
mvn clean install
<pankti-instrument-<version>-jar-with-dependencies.jar
to /path/to/glowroot/plugins/
Execute the application with a workload, using Glowroot as a javaagent.\
java -javaagent:/path/to/glowroot/glowroot.jar -jar <project-jar>.jar <cli-args>
\
The serialized objects for invoked methods are saved at /tmp/pankti-object-data/
.
Additionally, a list of invoked methods is generated at /tmp/pankti-object-data/invoked-methods.csv
.
pankti-generate creates test classes for an application from the collected object profiles.\ It takes as input the path to the Java + Maven project, a CSV file with a list of invoked methods, and the path to the directory containing objects serialized as XML.
To run pankti-generate,
cd /path/to/pankti/pankti-generate/
mvn clean install
java -jar target/pankti-generate-<version>-jar-with-dependencies.jar /path/to/project /path/to/invoked/methods.csv /path/to/directory/with/objects/
The output is in a directory at /path/to/pankti/pankti-generate/output/generated/<project-name>/
. Generated test classes are placed in appropriate package directories. The naming convention followed is Test\<ClassName>PanktiGen.java. Resource files for long XML strings are created at /path/to/pankti/pankti-generate/output/generated/object-data
.
Rick transforms production workloads into tests that use mocks. In addition to some functionalities and implementation shared with pankti, it supports the instrumentation of methods that can be mocked within a test. It also handles the generation of these mocks with data collected from production.
cd pankti/
mvn clean install
To extract methods under test (MUTs) and mockable methods:
cd pankti/pankti-extract/
java -jar target/pankti-extract-<version>-jar-with-dependencies.jar /path/to/maven/project
./extracted-methods-<project>.csv
To instrument MUTs and mockable methods:
cd pankti/pankti-instrument/
python3 instrument-mock.py ../pankti-extract/extracted-methods-<project>.csv
python3 instrument-mock.py ../pankti-extract/extracted-methods-<project>.csv fully.qualified.name.of.CUT
se.kth.castor.pankti.instrument.plugins
./src/main/resources/META-INF/glowroot.plugin.json
mvn clean install
<pankti-instrument-<version>-jar-with-dependencies.jar
to /path/to/glowroot/plugins/
To execute the target project:
java -javaagent:/path/to/glowroot/glowroot.jar <project-jar-and-options>
/tmp/pankti-object-data/
/tmp/pankti-object-data/invoked-methods.csv
To generate tests:
cd pankti/rick/
java -jar target/rick-<version>-jar-with-depdendencies.jar /path/to/maven/project/ /tmp/pankti-object-data/invoked-methods.csv /tmp/pankti-object-data/
Test*PanktiGen.java
) are at ./output/generated/<project>