Skip to content

Commit

Permalink
test: unit testing for diff-test-selection (#980)
Browse files Browse the repository at this point in the history
* test: add some resources for testing

* fix: use now set property to skip checks

* test: add test on CloverExecutor and CloverReader

* test: add test for DiffComputer

* ci: enable mvn test for diff-test-selection

* test: add clover files example

* test: user now the correct path to the report

* test: restore patch.diff, required to run dspot on toy-project
  • Loading branch information
danglotb authored Dec 21, 2020
1 parent d05ea6d commit fa6248a
Show file tree
Hide file tree
Showing 171 changed files with 22,542 additions and 5 deletions.
6 changes: 5 additions & 1 deletion .travis/travis-diff-test-selection.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

DPSOT_VERSION=${1}

cd dspot-diff-test-selection/src/test/resources/tavern
cd dspot-diff-test-selection

mvn test

cd src/test/resources/tavern

mvn clean eu.stamp-project:dspot-diff-test-selection:${DSPOT_VERSION}:list -Dpath-dir-second-version="../tavern-refactor" eu.stamp-project:dspot-maven:${DSPOT_VERSION}:amplify-unit-tests -Dpath-to-test-list-csv=testsThatExecuteTheChange.csv -Dverbose -Dtest-criterion=ChangeDetectorSelector -Damplifiers=NumberLiteralAmplifier -Diteration=2 -Dabsolute-path-to-second-version=../tavern-refactor

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ public void instrumentAndRunTest(String pathToRootOfProject) {
pathToRootOfProject,
"clean",
"org.openclover:clover-maven-plugin:4.4.1:setup",
"test",
"-Drat.skip=true",
"-Djacoco.skip=true",
"-Danimal.sniffer.skip=true"
"test"
);
}

Expand All @@ -60,6 +57,7 @@ private int runGoals(String pathToRootOfProject, String... goals) {
properties.setProperty("findbugs.skip", "true");
properties.setProperty("gpg.skip", "true");
properties.setProperty("jacoco.skip", "true");
properties.setProperty("animal.sniffer.skip", "true");
request.setProperties(properties);

Invoker invoker = new DefaultInvoker();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package eu.stamp_project.diff_test_selection.clover;

import org.junit.Test;

import java.io.File;

import static org.junit.Assert.assertTrue;

public class CloverExectorTest {


@Test
public void test() {

/*
* Test the CloverExecutor : it runs openclover on the test suite
* The oracle is that the folder /target/clover exists
*/
final String pathToRootOfProject = "src/test/resources/tavern";
new CloverExecutor().instrumentAndRunTest(pathToRootOfProject);
assertTrue(new File(pathToRootOfProject + "/target/clover").exists());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package eu.stamp_project.diff_test_selection.clover;

import org.junit.Test;

import java.util.List;
import java.util.Map;

import static org.junit.Assert.assertFalse;

public class CloverReaderTest {

@Test
public void test() {

/*
* Read a clover report and return the coverage
*/

final Map<String, Map<String, Map<String, List<Integer>>>> coverage = new CloverReader().read("src/test/resources/clover_report");
assertFalse(coverage.isEmpty());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package eu.stamp_project.diff_test_selection.diff;

import org.junit.Test;

import java.io.File;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

public class DiffComputerTest {

@Test
public void test() {
final File file = new File("src/test/resources/tavernpatch.diff");
file.delete();
assertFalse(file.exists());
new DiffComputer()
.computeDiffWithDiffCommand(new File("src/test/resources/tavern"), new File("src/test/resources/tavern-refactor"));
assertTrue(file.exists());
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit fa6248a

Please sign in to comment.