Giter Club home page Giter Club logo

stamp-project / dspot Goto Github PK

View Code? Open in Web Editor NEW
114.0 25.0 28.0 27.74 MB

Automatically detect and generate missing assertions for Junit test cases (also known as test amplification)

Home Page: https://dspot-demo.stamp-project.eu/

License: GNU Lesser General Public License v3.0

Java 61.10% HTML 19.42% Shell 0.20% Dockerfile 0.10% Python 1.87% JavaScript 15.70% CSS 0.81% Perl 0.78% Pug 0.01%
test-amplification coverage junit test-automation dspot inria h2020 hacktoberfest java

dspot's Introduction

DSpot DSpot CI codecov Maven Central

DSpot is a tool that generates missing assertions in JUnit tests. DSpot takes as input a Java project with an existing test suite. DSpot generates new test cases from existing ones and write them on disk. DSpot supports Java projects built with Maven and Gradle (see the --automatic-builder option)

DSpot ecosystem:

Getting started

Demo site

Meet our demonstration website at https://dspot-demo.stamp-project.eu/.

Prerequisites

You need Java and Maven. The environment variable JAVA_HOME must point to a valid JDK installation (and not a JRE). DSpot uses the environment variable MAVEN_HOME, ensure that this variable points to your maven installation. Example:

export MAVEN_HOME=path/to/maven/

Releases

We advise you to start by downloading the latest release, see https://github.com/STAMP-project/dspot/releases.

Usage

First Tutorial

After having downloaded DSpot (see the previous section), you can run the provided example by running eu.stamp_project.Main from your IDE, or with

java -jar target/dspot-LATEST-jar-with-dependencies.jar --example

replacing LATEST by the latest version of DSpot, e.g. 2.2.1 would give dspot-2.2.1-jar-with-dependencies.jar

Given a test case as input, with --amplifiers=None, DSpot only adds assertions in the test, for example:

@Test
void test() {
  Tacos tacos = new Tacos();
  Benjamin benjamin = new Benjamin();
  benjamin.eat(tacos);
  assertFalse(benjamin.isHungry());
+  assertTrue(benjamin.isHappy());  // new assertion
}

With some amplifiers, eg --amplifiers=AllAmplifiers, DSpot modifies the setup of the input test and adds assertions in your code, for example:

@Test
void test() {
  Tacos tacos = new Tacos();
  Benjamin benjamin = new Benjamin();
-  benjamin.eat(tacos); // removed method call
-  assertFalse(benjamin.isHungry());
+  assertTrue(benjamin.isHungry());
+  assertFalse(benjamin.isHappy()); // new assertion
}

The modified test is lastly given to a selector, eg --test-selector=PitMutantScoreSelector, that determines if it improves the test suite and should be kept.

The amplification process is illustrated in the figure below. Note that amplified tests are further modified by subsequent iterations determined by for example --iteration=10.

Application loop

When an amplification is successful, DSpot outputs the improvement on the console and the result of the amplification (the new tests) are written to the output folder specified by configuration property outputDirectory (default to ./target/dspot/output/).

Initial instruction coverage: 30 / 34
88.24%
Amplification results with 5 amplified tests.
Amplified instruction coverage: 34 / 34
100.00%

Want to know more? Read the full articles:

Command Line Usage

You can then execute DSpot by using:

java -jar /path/to/dspot-LATEST-jar-with-dependencies.jar --absolute-path-to-project-root <path>

Amplify a specific test class

java -jar /path/to/dspot-*-jar-with-dependencies.jar eu.stamp_project.Main --absolute-path-to-project-root <path> --test my.package.TestClass

Amplify specific test classes according to a regex

java -jar /path/to/dspot-LATEST-jar-with-dependencies.jar --absolute-path-to-project-root <path> --test my.package.*
java -jar /path/to/dspot-LATEST-jar-with-dependencies.jar --absolute-path-to-project-root <path> --test my.package.Example*

Amplify a specific test method from a specific test class

java -jar /path/to/dspot-LATEST-jar-with-dependencies.jar --absolute-path-to-project-root <path> --test my.package.TestClass --cases testMethod

Command line options

Full list of command line options
Usage: eu.stamp_project.Main [-hvV] [--allow-path-in-assertions] [--clean] [--dev-friendly] [--example]
                             [--execute-test-parallel] [--generate-new-test-class] [--gregor-mode]
                             [--keep-original-test-methods] [--only-input-amplification] [--restful] [--smtp-auth]
                             [--target-one-test-class] [--use-maven-to-exe-test] [--use-working-directory]
                             [--absolute-path-to-project-root=<absolutePathToProjectRoot>]
                             [--absolute-path-to-second-version=<absolutePathToSecondVersionProjectRoot>]
                             [--automatic-builder=<automaticBuilder>] [--cache-size=<cacheSize>]
                             [--collector=<collector>] [--delta=<delta>] [--descartes-mutators=<descartesMutators>]
                             [--descartes-version=<descartesVersion>] [--excluded-classes=<excludedClasses>]
                             [--excluded-test-cases=<excludedTestCases>] [--full-classpath=<dependencies>]
                             [-i=<nbIteration>] [--input-ampl-distributor=<inputAmplDistributor>]
                             [--jvm-args=<JVMArgs>] [--maven-home=<mavenHome>]
                             [--maven-pre-goals-test-execution=<preGoalsTestExecution>]
                             [--max-test-amplified=<maxTestAmplified>] [--mongo-colname=<mongoColName>]
                             [--mongo-dbname=<mongoDbName>] [--mongo-url=<mongoUrl>]
                             [--nb-parallel-exe-processors=<numberParallelExecutionProcessors>]
                             [--output-path=<outputDirectory>] [--path-pit-result=<pathPitResult>]
                             [--path-to-additional-classpath-elements=<additionalClasspathElements>]
                             [--path-to-test-list-csv=<pathToTestListCSV>] [--pit-filter-classes-to-keep=<filter>]
                             [--pit-output-format=<pitOutputFormat>] [--pit-version=<pitVersion>]
                             [--random-seed=<seed>] [--relative-path-to-classes=<pathToClasses>]
                             [--relative-path-to-source-code=<pathToSourceCode>]
                             [--relative-path-to-test-classes=<pathToTestClasses>]
                             [--relative-path-to-test-code=<pathToTestSourceCode>] [--repo-branch=<repoBranch>]
                             [--repo-slug=<repoSlug>] [-s=<selector>] [--smtp-host=<smtpHost>]
                             [--smtp-password=<smtpPassword>] [--smtp-port=<smtpPort>] [--smtp-tls=<smtpTls>]
                             [--smtp-username=<smtpUsername>] [--system-properties=<systemProperties>]
                             [--target-module=<targetModule>] [--time-out=<timeOutInMs>] [--with-comment=<withComment>]
                             [-a=<amplifiers>[,<amplifiers>...]]... [-c=<testCases>[,<testCases>...]]...
                             [-t=<testClasses>[,<testClasses>...]]...
  -a, --amplifiers=<amplifiers>[,<amplifiers>...]
                             Specify the list of amplifiers to use. By default, DSpot does not use any amplifiers
                               (None) and applies only assertion amplification. Valid values:
                               MethodDuplicationAmplifier, MethodRemove, FastLiteralAmplifier,
                               MethodAdderOnExistingObjectsAmplifier, ReturnValueAmplifier, StringLiteralAmplifier,
                               NumberLiteralAmplifier, BooleanLiteralAmplifier, CharLiteralAmplifier,
                               AllLiteralAmplifiers, NullifierAmplifier, ArrayAmplifier, None Default value: None
      --absolute-path-to-project-root=<absolutePathToProjectRoot>
                             Specify the path to the root of the project. This path must be absolute.We consider as
                               root of the project folder that contain the top-most parent in a multi-module project.
      --absolute-path-to-second-version=<absolutePathToSecondVersionProjectRoot>
                             When using the ChangeDetectorSelector, you must specify this option. It should have for
                               value the path to the root of the second version of the project. It is recommended to
                               give an absolute path
      --allow-path-in-assertions
                             If enabled, DSpot will generate assertions for values that seems like to be paths. Default
                               value: false
      --automatic-builder=<automaticBuilder>
                             Specify the automatic builder to be used. Valid values: Maven, Gradle Default value: Maven
  -c, --cases, --test-cases, --test-methods=<testCases>[,<testCases>...]
                             Specify the test cases to amplify.By default, DSpot selects all the tests methods.
      --cache-size=<cacheSize>
                             Specify the size of the memory cache in terms of the number of store entries Default
                               value: 10000
      --clean                If enabled, DSpot will remove the out directory if exists, else it will append the results
                               to the exist files. Default value: false
      --collector=<collector>
                             Set a collector: MongodbCollector to send info to Mongodb at end process, NullCollector
                               which does nothing.Valid values: NullCollector, MongodbCollector Default value:
                               NullCollector
      --delta=<delta>        Specify the delta value for the assertions of floating-point numbers. If DSpot generates
                               assertions for float, it uses Assert.assertEquals(expected, actual, delta). It specifies
                               the delta value. Default value: 0.1
      --descartes-mutators=<descartesMutators>
                             Specify the list of descartes mutators to be used separated by comma. Please refer to the
                               descartes documentation for more details: https://github.
                               com/STAMP-project/pitest-descartes
      --descartes-version=<descartesVersion>
                             Specify the version of pit-descartes to use. Default value: 1.2.4
      --dev-friendly         Amplifies the test cases in a way that is easy for developers to read and understand.
                               Default value: false
      --example              Run the example of DSpot and leave.
      --excluded-classes=<excludedClasses>
                             Specify the full qualified name of excluded test classes. Each qualified name must be
                               separated by a comma ','. These classes won't be amplified, nor executed during the
                               mutation analysis, if the PitMutantScoreSelector is used.This option can be valued by a
                               regex.
      --excluded-test-cases=<excludedTestCases>
                             Specify the list of test cases to be excluded. Each is the name of a test case, separated
                               by a comma ','.
      --execute-test-parallel
                             If enabled, DSpot will execute the tests in parallel. For JUnit5 tests it will use the
                               number of given processors (specify 0 to take the number of available core processors).
                               For JUnit4 tests, it will use the number of available CPU processors (given number of
                               processors is ignored). Default value: false
      --full-classpath=<dependencies>
                             Specify the classpath of the project. If this option is used, DSpot won't use an
                               AutomaticBuilder (e.g. Maven) to clean, compile and get the classpath of the project.
                               Please ensure that your project is in a good shape, i.e. clean and correctly compiled,
                               sources and test sources.
      --generate-new-test-class
                             Enable the creation of a new test class. Default value: false
      --gregor-mode          Enable the gregor engine for Pit Mutant Score Selector. Default value: false
  -h, --help                 Show this help message and exit.
  -i, --iteration=<nbIteration>
                             Specify the number of amplification iterations. A larger number may help to improve the
                               test criterion (e.g. a larger number of iterations may help to kill more mutants). This
                               has an impact on the execution time: the more iterations, the longer DSpot runs. Default
                               value: 1
      --input-ampl-distributor=<inputAmplDistributor>
                             Specify an input amplification distributor.Valid values: RandomInputAmplDistributor,
                               TextualDistanceInputAmplDistributor, SimpleInputAmplDistributor Default value:
                               RandomInputAmplDistributor
      --jvm-args=<JVMArgs>   Specify JVM args to use when executing the test, PIT or other java process. This arguments
                               should be a list, separated by a comma ',', e.g. jvmArgs=Xmx2048m,-Xms1024m',-Dis.admin.
                               user=admin,-Dis.admin.passwd=$2pRSid#
      --keep-original-test-methods
                             If enabled, DSpot keeps original test methods of the amplified test class. Default value:
                               false
      --maven-home=<mavenHome>
                             Specify the maven home directory. If it is not specified DSpot will first look in both
                               MAVEN_HOME and M2_HOME environment variables. If these variables are not set, DSpot will
                               look for a maven home at default locations /usr/share/maven/, /usr/local/maven-3.3.9/
                               and /usr/share/maven3/.
      --maven-pre-goals-test-execution=<preGoalsTestExecution>
                             Specify pre goals to run before executing test with maven.It will be used as follow: the
                               elements, separated by a comma,must be valid maven goals and they will be placed just
                               before the "test" goal, e.g.--maven-pre-goals-test-execution preGoal1,preGoal2 will give
                               "mvn preGoal1 preGoal2 test"
      --max-test-amplified=<maxTestAmplified>
                             Specify the maximum number of amplified tests that dspot keeps (before generating
                               assertion). Default value: 200
      --mongo-colname=<mongoColName>
                             If valid mongo-url and a mongo-dbname are provided, DSpot will submit result to the
                               provided collection name.. Default value: AmpRecords
      --mongo-dbname=<mongoDbName>
                             If a valid mongo-url is provided, DSpot will submit result to the database indicated by
                               this name. Default value: Dspot
      --mongo-url=<mongoUrl> If valid url, DSpot will submit to Mongodb database. Default value: mongodb://localhost:
                               27017
      --nb-parallel-exe-processors=<numberParallelExecutionProcessors>
                             Specify the number of processor to use for the parallel execution.0 will make DSpot use
                               all processors available. Default value: 0
      --only-input-amplification
                             Only apply input amplification. Default value: false
      --output-path, --output-directory=<outputDirectory>
                             specify a path folder for the output. Default value: target/dspot/output/
      --path-pit-result=<pathPitResult>
                             Specify the path to the .xml or .csv of the original result of Pit Test. If you use this
                               option the selector will be forced to PitMutantScoreSelector.
      --path-to-additional-classpath-elements=<additionalClasspathElements>
                             Specify additional classpath elements (e.g. a jar files). Elements of this list must be
                               separated by a comma ','.
      --path-to-test-list-csv=<pathToTestListCSV>
                             Enable the selection of the test to be amplified from a csv file. This parameter is a path
                               that must point to a csv file that list test classes and their test methods in the
                               following format: test-class-name;test-method-1;test-method-2;test-method-3;... If this
                               parameter is used, DSpot will ignore the value used in the parameter test and cases It
                               is recommended to use an absolute path.
      --pit-filter-classes-to-keep=<filter>
                             Specify the filter of classes to keep used by PIT. This allow you restrict the scope of
                               the mutation done by PIT. If this is not specified, DSpot will try to build on the fly a
                               filter that takes into account the largest number of classes, e.g. the topest package.
      --pit-output-format=<pitOutputFormat>
                             Specify the Pit output format.Valid values: XML, CSV Default value: XML
      --pit-version=<pitVersion>
                             Specify the version of PIT to use. Default value: 1.4.0
      --random-seed=<seed>   Specify a seed for the random object (used for all randomized operation). Default value: 23
      --relative-path-to-classes=<pathToClasses>
                             Specify the relative path from --absolute-path-to-project-root/--target-module
                               command-line options that points to the folder that contains binaries of the source (.
                               class). Default value: target/classes/
      --relative-path-to-source-code=<pathToSourceCode>
                             Specify the relative path from --absolute-path-to-project-root/--target-module
                               command-line options that points to the folder that contains sources (.java). Default
                               value: src/main/java/
      --relative-path-to-test-classes=<pathToTestClasses>
                             Specify the relative path from --absolute-path-to-project-root/--target-module
                               command-line options that points to the folder that contains binaries of the test source
                               (.class). Default value: target/test-classes/
      --relative-path-to-test-code=<pathToTestSourceCode>
                             Specify the relative path from --absolute-path-to-project-root/--target-module
                               command-line options that points to the folder that contains test sources (.java).
                               Default value: src/test/java/
      --repo-branch=<repoBranch>
                             Branch name of the submitted repo, This is used by mongodb as a identifier for analyzed
                               repo's submitted data. Default value: UnknownBranch
      --repo-slug=<repoSlug> Slug of the repo for instance Stamp/Dspot. This is used by mongodb as a identifier for
                               analyzed repo's submitted data. Default value: UnknownSlug
      --restful              If true, DSpot will enable restful mode for web Interface. It will look for a pending
                               document in Mongodb with the corresponding slug and branch provided instead of creating
                               a completely new one. Default value: false
  -s, --test-selector, --test-criterion=<selector>
                             Specify the test adequacy criterion to be maximized with amplification. Valid values:
                               PitMutantScoreSelector, JacocoCoverageSelector, TakeAllSelector, ChangeDetectorSelector,
                               ExtendedCoverageSelector Default value: PitMutantScoreSelector
      --smtp-auth            Enable this if the smtp host server require auth. Default value: false
      --smtp-host=<smtpHost> Host server name. Default value: smtp.gmail.com
      --smtp-password=<smtpPassword>
                             Password for Gmail, used for submit email at end-process. Default value: Unknown
      --smtp-port=<smtpPort> Host server port. Default value: 587
      --smtp-tls=<smtpTls>   Enable this if the smtp host server require secure tls transport. Default value: false
      --smtp-username=<smtpUsername>
                             Username for Gmail, used for submit email at end-process. Default value: [email protected]
      --system-properties=<systemProperties>
                             Specify system properties. This value should be a list of couple property=value, separated
                               by a comma ','. For example, systemProperties=admin=toto,passwd=tata. This defines two
                               system properties.
  -t, --test=<testClasses>[,<testClasses>...]
                             Fully qualified names of test classes to be amplified. If the value is all, DSpot will
                               amplify the whole test suite. You can also use regex to describe a set of test classes.
                               By default, DSpot selects all the tests classes.
      --target-module=<targetModule>
                             Specify the module to be amplified. This value must be a relative path from value
                               specified by --absolute-path-to-project-root command-line option. If your project is
                               multi-module, you must use this property because DSpot works at module level.
      --target-one-test-class
                             Enable this option will make DSpot computing the mutation score of only one test class
                               (the first pass through --test command line option). Default value: false
      --time-out=<timeOutInMs>
                             Specify the timeout value of the degenerated tests in millisecond. Default value: 10000
      --use-maven-to-exe-test
                             If enabled, DSpot will use maven to execute the tests. Default value: false
      --use-working-directory
                             Enable this option to change working directory with the root of the project. Default
                               value: false
  -v, --verbose              Enable verbose mode of DSpot. Default value: false
  -V, --version              Print version information and exit.
      --with-comment=<withComment>
                             Enable comment on amplified test: details steps of the amplification. Valid values: All,
                               Amplifier, Coverage, None. Default value: None

For options that take list, the used separator is a comma ,, whatever the platform you use.

Maven plugin usage

You can execute DSpot using the maven plugin. For more details, see the dedicated README.

Each command line options is translated into an option for the maven plugin. You must prefix each of them with -D. Examples:

* `--test my.package.MyTestClass1:my.package.MyTestClass2` gives `-Dtest=my.package.MyTestClass1,my.package.MyTestClass2`
* `--output-path output` gives `-Doutput-path=output` 

Configuration

Amplifiers (-a | --amplifiers)

By default, DSpot uses no amplifier because the simplest amplification that can be done is the generation of assertions on existing tests, i.e. it will improve the oracle and the potential of the test suite to capture bugs.

However, DSpot provide different kind of Amplifier:

  • StringLiteralAmplifier: modifies string literals: remove, add and replace one random char, generate random string and empty string. It also replaces the existing string by the system path separator (e.g. : on Linux) and the system line separator (e.g. \n on Linux).
  • NumberLiteralAmplifier: modifies number literals: replace by boundaries (e.g. Integer_MAX_VALUE for int), increment and decrement values
  • CharLiteralAmplifier: modifies char literals: replace by random char and special chars: '\0' and . It also replaces the existing char by the previous and next one, i.e. it computes codechar + 1 and codechar - 1. For example, we have b, it resuls with b + 1 = c and b - 1 = a
  • BooleanLiteralAmplifier: modifies boolean literals: negate the value
  • ArrayLiteralAmplifier: modifies array literals: remove and add element in literal, replace literal with empty literal and null
  • AllLiteralAmplifiers: combines all literals amplifiers, i.e. StringLiteralAmplifier, NumberLiteralAmplifier, CharLiteralAmplifier, BooleanLiteralAmplifier and ArrayLiteralAmplifier
  • MethodDuplicationAmplifier: duplicates an existing method call
  • MethodRemove: removes an existing method call
  • MethodAdderOnExistingObjectsAmplifier: adds a method call, and generate required parameter
  • ReplacementAmplifier: replaces a local variable by a generated one
  • FastLiteralAmplifier: a faster amplifier for the literals
  • NullifierAmplifier: replaces value with null
  • ArrayAmplifier: replaces value of arrays
  • ReturnValueAmplifier: creates objects based on the returned value by existing method call
  • None: do nothing

If you only want to use these amplifiers and not generate assertions, use --only-input-amplification.

Test Selectors (-s | --test-selector | --test-criterion)

In DSpot, test selectors can be seen as a fitness: it measures the quality of amplified, and keeps only amplified tests that are worthy according to this selector.

The The default selector is PitMutantScoreSelector. This selector is based on PIT, which is a tool to computation mutation analysis. DSpot will keep only tests that increase the mutation score.

Following the list of available test selectors:

  • PitMutantScoreSelector: uses PIT to computes the mutation score, and selects amplified tests that kill mutants that was not kill by the original test suite.
  • JacocoCoverageSelector: uses JaCoCo to compute instruction coverage and executed paths (the order matters). Selects test that increase the coverage and has unique executed path.
  • ExtendedCoverageSelector: uses JaCoCo to compute instruction coverage. Selects tests that cover more instructions than the original test suite on any line of the code under test.
  • TakeAllSelector: keeps all amplified tests not matter the quality.
  • ChangeDetectorSelector: runs against a second version of the same program, and selects amplified tests that fail. This selector selects only amplified test that are able to show a difference of a behavior betweeen two versions of the same program.

Input Ampl Distributor

In DSpot, the Input Ampl Distributor is a way to select the amplified test methods after the input amplification. It allows to keep interesting and discard unwanted amplified test method.

For now, there are three implementations of the Input Ampl Distributor:

  • RandomInputAmplDistributor: This distributor selects randonly amplified test methods.
  • TextualDistanceInputAmplDistributor: This distributor selects by maximize their distance of string representation among all the input amplified test methods. The number of amplified selected test methods is specified by the command line option --max-test-amplified.
  • SimpleInputAmplDistributor: This distributor selects a fair number of amplified test method per Amplifier per test methods, if possible. The total budget is specified by the command line option ``--max-test-amplified`, and is the total number of amplified test methods to keep, i.e. it will be divide by the number of Amplifiers and by the number of test methods to be amplified. Example: We have 2 Amplifiers. We apply them to 2 test methods. For each test methods, amplifiers generate 4 new test methods, totally 8 amplified test methods. If the budget is 6, it will select: 3 amplified test methods per amplifier, and 2 for one test method and 2 for the other.

Supported Test Frameworks

DSpot supports:

  • JUnit3
  • JUnit4
  • JUnit5

and

  • Google Truth assertions

However, DSpot detects the used test framework at test class level.

Please, do not amplify test classes that mix test frameworks (test methods in JUnit4 and JUnit5 within the same test class.)

If you have such test class, please amplify the different test framework separately.

Supported JDKs & Build Tools

DSpot runs with the following Java versions:

  • Java 1.8
  • Java 11
  • Java 16 (used as JDK, not tested if it can support Java 16 language features)

It can amplify tests of projects built with:

  • Maven 3.6
  • Gradle 7

Minimizing and Prettifying DSpot Amplified Test Cases

With the DSpot Prettifier you can remove redundant assertions from your amplified test cases & give them more expressive names with the help of code2vec and context2vec.

License and Contributions

DSpot is licensed under LGPLv3. Contributors and pull requests are welcome :-). For more information on development, see the dedicated README-developers.md

Acknowledgement

Dspot is funded by EU H2020 research project STAMP.

dspot's People

Contributors

a203336 avatar andrewbwogi avatar bbaudry avatar borisbaldassari avatar bzz avatar danglotb avatar danzone avatar dependabot[bot] avatar henry-lp avatar lacinoire avatar luandrea avatar monperrus avatar nicolabertazzo avatar olibou6 avatar oscarlvp avatar paraita avatar sbihel avatar simonallier avatar spookyvale avatar vmassol avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dspot's Issues

Production of uncompilable code

DSpot produces sometimes uncompilable or failing test cases code.

For instance, after amplifying com.squareup.javapoet.AnnotationSpecTest (from javapoet), and renaming it by com.squareup.javapoet.AmplAnnotationSpecTest, we got two issues:
char[] g() default {0, 0xCAFE, 'z', '€', 'ℕ', '"', '\'', '\t', '\n'};
is transformed into
char[] g() default {0, 0xCAFE, 'z', '?', '?', '"', '\'', '\t', '\n'};
and some Literals contains the name of the class (AnnotationSpecTest), and produce assertions errors.

feature: add support for multi-module Gradle projects

This is probably just a misunderstanding from my side but I can't seem to get Dspot to run on my code.

java -jar target/dspot-1.0.0-jar-with-dependencies.jar -p dspot_scheduling.properties 
00:12 DEBUG: run maven, phase: [clean, test, -DskipTests], timeout -1
00:13 DEBUG: [INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.046 s
[INFO] Finished at: 2017-03-27T15:55:11+02:00
[INFO] Final Memory: 13M/360M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (/home/paraita/src/dspot/tmpDir/tmp). Please verify you invoked Maven from the correct directory. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException

00:13 DEBUG: timeOut init: 1
00:14 DEBUG: all children process kill (pid: 26090)
00:14 DEBUG: timeOut init: 4
00:14 DEBUG: run maven, phase: [eclipse:eclipse], timeout -1
00:15 DEBUG: timeOut init: 1
00:16 DEBUG: all children process kill (pid: 26090)
00:16 INFO: resolveURL dependencies of tmpDir/tmp/pom.xml
Exception in thread "main" java.lang.RuntimeException: java.io.FileNotFoundException: tmpDir/tmp/pom.xml (Aucun fichier ou dossier de ce type)
	at fr.inria.diversify.dspot.support.MavenDependenciesResolver.getMavenProject(MavenDependenciesResolver.java:112)
	at fr.inria.diversify.dspot.support.MavenDependenciesResolver.buildUrls(MavenDependenciesResolver.java:50)
	at fr.inria.diversify.dspot.support.MavenDependenciesResolver.resolveDependencies(MavenDependenciesResolver.java:40)
	at fr.inria.diversify.dspot.AmplificationHelper.getDependenciesOf(AmplificationHelper.java:213)
	at fr.inria.diversify.dspot.DSpot.<init>(DSpot.java:111)
	at fr.inria.stamp.Main.run(Main.java:34)
	at fr.inria.stamp.Main.main(Main.java:22)
Caused by: java.io.FileNotFoundException: tmpDir/tmp/pom.xml (Aucun fichier ou dossier de ce type)
	at java.io.FileInputStream.open0(Native Method)
	at java.io.FileInputStream.open(FileInputStream.java:195)
	at java.io.FileInputStream.<init>(FileInputStream.java:138)
	at java.io.FileReader.<init>(FileReader.java:72)
	at fr.inria.diversify.dspot.support.MavenDependenciesResolver.getMavenProject(MavenDependenciesResolver.java:98)
	... 6 more

I have dspot cloned into /home/paraita/src/dspot and my code to test is in /home/paraita/src/scheduling.
Here is the property file I'm using to tell Dspot where to find my code:

#relative path to the project root from dspot project
project=../scheduling
#relative path to the source project from the project properties
src=../scheduling/scheduler/scheduler-api/src/main
#relative path to the test source project from the project properties
testSrc=../scheduling/scheduler/scheduler-api/src/test
#java version used
javaVersion=7
# (optional) path to the output folder, default to "output_diversify"
outputDirectory=dspot-out/
# (optional) filter on the package name containing tests to be amplified ("example" => "example.*"
#filter=example

I also tried to set absolute paths instead of relatives but I still get the same error.
Could you help me understand this ?
Thanks in advance !

Deployment

  • Deploy sosiefier
  • simplify installation of dspot

repo will be something like stamp-project.github.io/stamp-maven-repository/repository

Do not use build system to run external tool.

For now, we use maven to run Pit. There is a performance problem, because it create a new JVM, and run maven on it.

I suggest to use directly pit, as a dependencies of DSpot, and run it from the same running JVM, we could increase the performance.

Also, I think that #136 should use the tool as dependencies and not using a build system to run it.

default behavior of main

no amplified tests to console.

should write the amplified tests to disk and add in the console output.

21 new tests written in folder <path/to/amplified_tests>

Getting Started Example don't run

mvn exec:java -Dexec.mainClass="fr.inria.stamp.Main" -Dexec.args="--example"
gives an error.
Here is the error message:
java.lang.RuntimeException: java.util.regex.PatternSyntaxException: Unexpected i nternal error near index 1 \ ^ at fr.inria.stamp.Main.runExample(Main.java:106) at fr.inria.stamp.JSAPOptions.parse(JSAPOptions.java:56) at fr.inria.stamp.Main.main(Main.java:21) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl. java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces sorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:282) at java.lang.Thread.run(Thread.java:748) Caused by: java.util.regex.PatternSyntaxException: Unexpected internal error nea r index 1 \ ^

improve readme

  • What is Dspot?
    • goal
    • input
    • output
    • how it works?
  • How to compile and build?
  • API usage (all snippets are tested)
    • snippet1
    • snippet2
  • Command-line usage
  • License

implement dspot for javascript

Motivation: The Javascript ecosystem is very active, and many micro-service architectures use Node.js

What: Implement the core DSpot algorithms for Javascript, on top of typical Javascript unit testing libraries

Output: An implementation of Dspot in Javascript

Hints: As AST manipulation library, one can use UglifyJS or BabelJS

pb with visibility/accessibility in JunitRunner

It seems like the JunitRunner is buggy.

It is not able to run test from commons-lang such as ToStringStyleTest.

The failure is

java.lang.IllegalAccessError: tried to access method org.apache.commons.lang3.builder.ToStringStyle.setContentEnd(Ljava/lang/String;)V from class org.apache.commons.lang3.builder.ToStringStyleTest

Dependencies issues

Hello, I tried to build and run Dspot, but I have dependencies issues.
I checked out sosiefier, to have them.
But, in pom.xml of Dspot we have:

 <dependency>
            <groupId>fr.inria.diversify</groupId>
            <artifactId>profiling</artifactId>
            <version>1.0.0</version>
</dependency>

while in profiling we have fr.inria.diversify.sosiefier as groupId.

I tried to change it to link dependencies but I could find the package fr.inria.diversify.log in TestSelector for instance.

I renamed the package logger from sosifier.profiling into log, but some classes still missing (such as fr.inria.diversify.log.LogReader).

Could please indicate me the way to retrieve those dependencies?

Thanks.

add support for gradle projects

Motivations: For now, DSpot can only be run on maven projects.

What: The task aims at adding a support for projects that use gradle.

Expected changes: It consists of adding an interface above the existing usage of all call to maven and implement same usage with gradle. It will allow the user to specify in the properties file or automatically detected (the pom.xml exists) which tool his project is using.

support more results from pit

Pit produces sometimes a results such as:

QueryParser.java;org.jsoup.select.QueryParse;rorg.pitest.mutationtest.engine.gregor.mutators.ArgumentPropagationMutator;cssNthChild;303;KILLED;org.jsoup.select.CssTest.org.jsoup.select.CssTest

The PitResultParser does not support this kind of results.

clean dependencies?

put diversity-profiling in sosiefier?
rename sosifier?
publish sosifier on maven central?

Tests don't pass

when running the "getting started", tests don't pass.
mvn test fails with
Failed tests: testRunMockito(fr.inria.diversify.dspot.testrunner.MockitoRunnerTest): expected:<5> but was:<0>
test(fr.inria.diversify.dspot.DSpotTest): expected:<1> but was:<2>
testResolveDependencies(fr.inria.diversify.dspot.support.MavenDependenciesResolverTest)
testFilterTests(fr.inria.diversify.dspot.assertGenerator.RemoveBadTestTest): expected:<1> but was:<4>
`Tests in error: ` ` test(fr.inria.diversify.dspot.DSpotMockedTest): java.io.FileNotFoundException: tmpDir/tmp/observations.ser (Aucun fichier ou dossier de ce type)` ` testPitDescartesMode(fr.inria.diversify.mutant.descartes.PitDescartesTest): java.lang.NullPointerException`
Tests run: 47, Failures: 4, Errors: 2, Skipped: 0

Use external Coverage tools

Instead of using our own implementation of coverage, we should use one well implemented.

I suggest Jacoco, which used to compute the coverage of a lot of projects, including DSpot's coverage

Descartes Gradle plugin - Issue while executing pitest with Descartes mutation engine

Hello, I'm facing this issue with Gradle java projects: if I run the task gradle pitest, having configured descartes plugin as described in https://github.com/STAMP-project/pitest-descartes, I got an error. It seems a classpath problem: descartes plugin seems to require pitest 1.2.x library, while gradle pitest plugin requires pitest 1.x library.
Attached a zip file with the test project and the gradle build file: this afternoon I got a classnotfound error on class org.pitest.util.InputstreamLineIterable (it belongs to pitest 1.x... library): pitest 1.2.x actually doesn't have this class, but in fact now I'm facing a different error (a match input error).
What's wrong with my Descartes plugin usage?
gradle-test-projects-descartes.tar.gz

add support for minimization of amplified tests

Motivation: During amplification, there is some neutral test evolution happening. This results in very long and unreadable tests. However, many changes in the amplified test are not required. The goal is minimization is to reduce the size and increase the readability of amplified test cases.

What: Implement a minimization algorithm (such as delta-debugging) to remove useless statements in amplified test cases.

Hints: For instance, useless statement are local variable that are set and never modified such as Object myObject = null; The local variable should be in-lined in this case. For tests that expect an exception, every statement after the exception the one that throws it can be removed.

add support for "mvn stamp:dspot"

Motivation: running Dspot on the command-line is tedious, having a Maven task specific for Stamp would result in suimply calling mvn stamp or mvn amplify on any arbitrary project (For example, "mvn pit" is the same thing for mutation testing

Output: Calling mvn stamp would use a default amplification configuration and the amplified test would be written in target/stamp-amplified

MethodAssertGenerator: makeFailureTest()

Hello, I open this issue to discuss about the makeFailureTest() method.

It builds a try/catch block with a fail statement at the end. That is to say, the oracle is to expect the program to throw an exception, example:

/* amplification of example.TestSuiteExample#test3 */
    @org.junit.Test(timeout = 1000)
    public void test3_cf118_literalMutation136() {
        // AssertGenerator generate try/catch block with fail statement
        try {
            example.Example ex = new example.Example();
            java.lang.String s = "abcd";
            // StatementAdderOnAssert create random local variable
            int vc_17 = 630434226;
            // AssertGenerator add assertion
            org.junit.Assert.assertEquals(vc_17, 630434226);
            // StatementAdderOnAssert create random local variable
            java.lang.String vc_15 = new java.lang.String();
            // AssertGenerator add assertion
            org.junit.Assert.assertEquals(vc_15, "");
            // StatementAdderMethod cloned existing statement
            ex.charAt(vc_15, vc_17);
            // MethodAssertGenerator build local variable
            Object o_10_0 = ex.charAt(s, ((s.length()) - 1));
            junit.framework.TestCase.fail("test3_cf118 should have thrown StringIndexOutOfBoundsException");
        } catch (java.lang.StringIndexOutOfBoundsException eee) {
        }
    }

IHMO, It is a very weak oracle and I would like to have your opinion about it:

Should we discard this case, and just drop the makeFailureTest() method,

or it worth it to have this kind of test cases? (for now DSpot generates a lot of this kind of test cases, maybe we should at least reduce/limit this number).

Dspot: test failures

Issue Type: possible bug
Description: DSpot tests fail when executed with Maven, after a successful compilation.
Reproducibility: always
Severity: major
Tool: DSpot GitHub repository, version 28/08/17
Execution Environment: Linux OpenSuse Tumbleweed
Steps to reproduce:
Following readme.md, I cloned the https://github.com/STAMP-project/dspot.git repository and compiled it using mvn compile
Testing DSpot with mvn test produces test errors. See below attached file. The reason tests fail is that it seems DSpot is looking for a Maven executable at this path: /usr/share/maven3/bin/mvn
Error configuring command-line. Reason: Maven executable not found at: /usr/share/maven3/bin/mvn, but in my Linux distribution is not located there. Is DSpot using MAVEN_HOME environment variable to locate the Maven executable?
Files:
I attach the full log of executing DSpot test:
DSpot_Test_Execution.txt

Relationships: None
Reporter: Yosu Gorroñogoitia [email protected]

prepare demo mixing table + dspot

Motivation: most software engineering demos are boring because there are just log files and source code to look at. adding a physical device in the demo makes much more fun.

What: preparing a demo when what drives the test amplification process using a mixing table. Each knob of the table would be bound to an amplification configuration parameter. The live coverage or mutation score would be impacted in real time and visualized fancily on screen.

Output: A cool DSpot demo that uses mixing table

DescartesInjector repository is missing

must inject

<repositories>
  <repository>
    <id>stamp-maven-repository-mvn-repo</id>
    <url>https://stamp-project.github.io/stamp-maven-repository/</url>
    <snapshots>
        <enabled>true</enabled>
      <updatePolicy>always</updatePolicy>
    </snapshots>
  </repository>
</repositories>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.