Skip to content

nakhlarafi/coverage-report-gen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Statement and Branch Coverage Generator Using Soot

Instructions to Use the Tool

Prerequisites:

  • Java Development Kit 8
  • Maven
  • Git
  • Soot

Obtaining the Code:

Clone the repository by executing the following command in your terminal:

git clone https://github.com/nakhlarafi/coverage-report-gen.git

Running the Code:

  1. Execute MainDriver.java.
  2. Pass the following arguments:
-helperClassesPath target/classes -classesToInstrumentPath Sample -jsonJarPath lib/json-20231013.jar math.Sort
  • helperClassesPath: Path to the helper class.
  • classesToInstrumentPath: Path to the root folder of the file to be instrumented.
  • jsonJarPath: Path to the JSON jar. The lib folder contains the necessary jar files.
  • The final argument is the package name of the file.

Run configuration

Generating Tests with Randoop

Generate Test Cases:

After setting up Randoop's environment, generating JUnit test cases can be done using this single command. Assuming your current working directory is the root directory of Sample, run:

java -classpath ${RANDOOP_JAR}:Sample/ randoop.main.Main gentests --testclass=math.Sort --time-limit=60 --junit-package-name=math --junit-output-dir=tests

The tests can be found in the tests folder.

Notes on the Randoop Parameters:

  • ${RANDOOP_JAR}: This should be replaced with the path to randoop-all-4.3.2.jar on your computer.
  • gentests: Command to generate tests using Randoop.
  • --testclass: Specifies the class under test.
  • --time-limit: Time limit for test case generation in seconds.
  • --junit-package-name: Package name for the generated test cases.
  • --junit-output-dir: Directory for the generated test cases.

Run the tests

After generating the tests run the tests using Junit. Make sure to make the sootOutput folder as library root.

img.png

Access the results

The generated result can be found in the reports folder. In the folder:

  • methodBranchCounts.txt contains the total branch counts
  • methodStatementCounts.txt contains the total statement counts
  • output.json contains the coverage result

The output.json is structured as below:

{
    "Branch Coverage": {
        "method_signature": {
            "coverage": "percentage",
            "total": "total_branches",
            "executed": "executed_branches"
        },
        ...
    },
    "Statement Coverage": {
        "method_signature": {
            "coverage": "percentage",
            "total": "total_statements",
            "executed": "executed_statements"
        },
        ...
    }
}

We can also find the coverage results as an output when we run it.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages