Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
README.md
cmd_dspot_tuto.zip
slides.pdf

README.md

dspot-hands-on

The slides and some scripts are avalaible on this repository.

Prerequisites

You must Java8, Maven and an internet connection.

First set up your MAVEN_HOME.

Try DSpot on dhell project

  1. Clone and go in the root directory of the project
git clone https://github.com/STAMP-project/dhell.git
cd dhell
  1. Amplify the test class eu.stamp_project.examples.dhell.HelloAppTest
mvn eu.stamp-project:dspot-maven:amplify-unit-tests \
    -DtargetOneTestClass \
    -Damplifiers=MethodAdd,MethodRemove \
    -Diteration=1 \
    -Dtest=eu.stamp_project.examples.dhell.HelloAppTest \
    -Dcases=testHelloAppDefault
  • -Diteration=1: DSpot will make only one iteration of the three steps: Input Modification, Assertion Generation and Test Selection Criterion.
  • -Damplifiers=MethodAdd,MethodRemove: DSpot will use two input amplifiers (for the input modification).
    1. MethodAdd: duplicate an existing method call.
    2. MethodRemove: Remove an existing method call.
  • -Dtest=eu.stamp_project.examples.dhell.HelloAppTest: amplify the test class eu.stamp_project.examples.dhell.HelloAppTest
  • -Dcases=testHelloAppDefault: amplify the test method named testHelloAppDefault.
  1. You should obtain something like:
======= REPORT =======
PitMutantScoreSelector:
The original test suite kills 12 mutants
The amplification results with 1 new tests
it kills 2 more mutants
  1. Checkout the output in target/dspot/output/

Try DSpot on your own project

  1. Run the assertion amplification with by replace Your.TestClass by the name of an actual test class:
mvn eu.stamp-project:dspot-maven:amplify-unit-tests \
    -DtargetOneTestClass \
    -Dtest=Your.TestClass
  1. Run the amplification with input modification:
mvn eu.stamp-project:dspot-maven:amplify-unit-tests \
    -DtargetOneTestClass \
    -Diteration=1 \
    -Damplifiers=MethodAdd,MethodRemove \
    -Dtest=Your.TestClass

Recall:

  • -Diteration=1: DSpot will make only one iteration of the three steps: Input Modification, Assertion Generation and Test Selection Criterion.
  • -Damplifiers=MethodAdd,MethodRemove: DSpot will use two input amplifiers (for the input modification).
    1. MethodAdd: duplicate an existing method call.
    2. MethodRemove: Remove an existing method call.

Tune amplification's options:

Before making multiple runs of DSpot, we advice you to pre-compute the mutation score of the test class that you want to amplify. In fact, the first thing that DSpot does, is to compute the mutation score of the original test suite, in order to have a base line.

  1. To compute the original mutation score of your test class, type and Your.TestClass by the name of an actual test class:
mvn clean test -DskipTests \
  eu.stamp-project:pitmp-maven-plugin:descartes \
  -DoutputFormats=XML \
  -DtargetTests=Your.TestClass
  1. Find and copy the mutations report in `target/pit-reports/AAAAMMDDHHMM/mutations.xml:
cp target/pit-reports/*/mutations.xml ./mutations.xml
  1. Use the option -Dpath-pit-result=mutations.xml of DSpot to provide the pre-computed mutation score:
mvn eu.stamp-project:dspot-maven:amplify-unit-tests \
  -Dpath-pit-result=mutations.xml \
  -Dtest=Your.TestClass

You should obtain the same output than you had before.

  • Avalaible values for -Damplifiers:

    • MethodAdd
    • MethodRemove
    • TestDataMutator
    • MethodGeneratorAmplifier
    • ReturnValueAmplifier
    • StringLiteralAmplifier
    • NumberLiteralAmplifier
    • BooleanLiteralAmplifier
    • CharLiteralAmplifier
    • AllLiteralAmplifiers
    • NullifierAmplifier
    • None
    • (default: None)
  • Increase the number of iterations: -Diteration=1, -Diteration=2...

  1. Examples:
mvn eu.stamp-project:dspot-maven:amplify-unit-tests \
    -DtargetOneTestClass \
    -Diteration=3 \
    -Damplifiers=TestDataMutator \
    -Dtest=Your.TestClass
mvn eu.stamp-project:dspot-maven:amplify-unit-tests \
    -DtargetOneTestClass \
    -Diteration=2 \
    -Damplifiers=TestDataMutator,MethodGeneratorAmplifier,NullifierAmplifier \
    -Dtest=Your.TestClass

More information on the GitHub of DSpot.

You can’t perform that action at this time.