From 4ade61967699a8fa4d24159e0e689500978e850d Mon Sep 17 00:00:00 2001 From: Martin Monperrus Date: Mon, 4 Nov 2019 09:46:25 +0100 Subject: [PATCH] doc: improve the example in the first tutorial (#916) --- README.md | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 2dad4b693..34d615589 100644 --- a/README.md +++ b/README.md @@ -41,16 +41,38 @@ After having downloaded DSpot (see the previous section), you can run the provid 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` +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: + +```diff +@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: -This example is an implementation of the function `chartAt(s, i)` (in `src/test/resources/test-projects/`), which -returns the char at the index _i_ in the String _s_. -In this example, DSpot amplifies the tests of `chartAt(s, i)` with the `FastLiteralAmplifier,`, which modifies literals inside the test and the generation of assertions. +```diff +@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 +} +``` + +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/`). -The result of the amplification of charAt consists of 6 new tests, as shown in the output below. These new tests are -written to the output folder specified by configuration property `outputDirectory` (`./target/dspot/output/`). ``` Initial instruction coverage: 30 / 34