Skip to content
Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.

Botsing Demo

First, clone this project, then go into botsing-demo directory.

Download Botsing

If required, download the latest version of botsing-reproduction.jar from here. There is already a botsing-reproduction jar in botsing-demo, that will run fine, but may be outdated.

Prepare data for running Botsing

For using Botsing, you need to provide two data:

  • The compiled version of the software under test (SUT): a folder containing all the .jar files required to run the software under test. As an example, you can see applications/LANG-9b.
  • Crash Log: the file with the stack trace. The stack trace should be clean (no error message) and cannot contain any nested exceptions. As an example, you can see crashes/LANG-9b.log.

Run Botsing

Run botsing with the following command:

java -jar <Path_to_botsing-reproduction.jar> -project_cp <Path_to_Directory_with_SUT_jars> -crash_log <Path_to_crash_log> -target_frame <Level_of_target_frame> -Dsearch_budget=<time_in_second> -D<property=value>  

<Path_to_botsing-reproduction.jar> Path to the latest version of the botsing-reproduction jar file.

<Path_to_Directory_with_SUT_jars> Path to the compiled version of the software under test.

<Path_to_crash_log> Path to a file File with the stack trace.

<Level_of_target_frame> This argument indicates that the user wants to replicate the first n lines of the stack trace.

-Dsearch_budget=<time_in_second> Maximum search duration in seconds.

-D<property=value> Since Botsing uses EvoSuite during the search process, the user can set the evosuite properties through Botsing. For more information about the EvoSuite options click here.

As an example, you can run the following sample command in this demo:

java -jar botsing-reproduction-1.0.7.jar -project_cp applications/LANG-9b -crash_log crashes/LANG-9b.log -target_frame 5 -Dsearch_budget=180 -Dtest_dir=results

After running this command, Botsing strives to generate a replicator test, which throws a java.lang.ArrayIndexOutOfBoundsException (as is indicated in crashes/LANG-9b.log) including first 5 frames of this stack trace, for 2 minutes.

Botsing stops searching either when it reaches the replicator test or when its search budget is finished.

The generated test by Botsing

If Botsing achieves to the replicator test, it will save it in the output directory (crash-reproduction-tests by default). If we run this test on the software under test, it throws the same stack trace as the given one.

For instance, one of the result of the sample command, which we mentioned in the previous section, is the following test (The generated test is different everytime):

@Test(timeout = 4000)
 public void test0()  throws Throwable  {
     Locale locale0 = FastDateParser.JAPANESE_IMPERIAL;
     TimeZone timeZone0 = TimeZone.getDefault();
     FastDateParser fastDateParser0 = null;
     fastDateParser0 = new FastDateParser("GMTJST", timeZone0, locale0);

Go to the the generated test directory

cd results

Collect the classpaths

for i in ../applications/LANG-9b/*.jar; do echo -n $i":"; done > classpath.txt

Compile test

javac -cp $(cat classpath.txt):../evosuite-standalone-runtime-1.1.0.jar org/apache/commons/lang3/time/

Run the generated test

java -cp $(cat classpath.txt):../evosuite-standalone-runtime-1.1.0.jar org.junit.runner.JUnitCore org.apache.commons.lang3.time.FastDateParser_ESTest

The test should throw the following exception:

java.lang.ArrayIndexOutOfBoundsException: 4
	at org.apache.commons.lang3.time.FastDateParser.toArray(
	at org.apache.commons.lang3.time.FastDateParser.getDisplayNames(
	at org.apache.commons.lang3.time.FastDateParser$TextStrategy.addRegex(
	at org.apache.commons.lang3.time.FastDateParser.init(
	at org.apache.commons.lang3.time.FastDateParser.<init>(
	at org.apache.commons.lang3.time.FastDateParser_ESTest.test0(

The generated exception reproduces the one present in the original crash log (see crashes/LANG-9b.log). So now you have a new test that reproduces an existing stack trace !

Running Botsing with model seeding

Generate models

To model inference, we need to use botsing-model-generation tool. The input parameters for this tool are:

java -jar botsing-model-generation-1.0.7.jar -project_cp <Path_to_Directory_with_SUT_jars> -project_prefix <prefix_of_classes_for_analysis> -out_dir <directory_to_save_generated_models>

In our example, we can generate the models for LANG-9b by following command:

java -jar botsing-model-generation-1.0.7.jar -project_cp applications/LANG-9b -project_prefix org.apache.commons.lang3 -out_dir models-lang

Run Botsing with the generated models

After model inference, we need to pass the directory of models to botsing by -model parameter. Also, we should set the probability of model usage during the search process by -Dp_object_pool.

For LANG-9b example, we can run the following command:

java -jar botsing-reproduction-1.0.7.jar -project_cp applications/LANG-9b -crash_log crashes/LANG-9b.log -target_frame 10 -Dsearch_budget=180 -model models-lang/models -Dp_object_pool=1.0 -Dtest_dir=results -Dpopulation=50

This Botsing execution should generate a test case, which reproduces all of the ten frames in LANG-9b. For instance, one of the result of the executing Botsing with model seeding for reproducing all of the ten frames of LANG-9b is:

@Test(timeout = 4000)
  public void test0()  throws Throwable  {
      ZoneOffset zoneOffset0 = ZoneOffset.ofHoursMinutesSeconds(0, 0, 1);
      TimeZone timeZone0 = TimeZone.getTimeZone((ZoneId) zoneOffset0);
      Locale locale0 = FastDateParser.JAPANESE_IMPERIAL;
      // Undeclared exception!
      FastDateFormat.getInstance("Gh", timeZone0, locale0);

Compile & execute the generated test:

cd results
javac -cp $(cat classpath.txt):../evosuite-standalone-runtime-1.1.0.jar org/apache/commons/lang3/time/
java -cp $(cat classpath.txt):../evosuite-standalone-runtime-1.1.0.jar org.junit.runner.JUnitCore org.apache.commons.lang3.time.FastDateFormat_ESTest


A tutorial to reproduce Java crashes with Botsing.



No releases published


No packages published