From 0939f9671b8e1e43b69edf8880adca0aab0cb27a Mon Sep 17 00:00:00 2001 From: Emmanuel Chebbi Date: Sat, 23 Mar 2024 20:21:47 +0100 Subject: [PATCH 01/11] [WIP] compilation OK but tests NOK --- .../PitclipseMutationsResultListener.java | 2 +- .../runner/results/summary/ClassSummary.java | 6 +- .../summary/SummaryResultListener.java | 27 +-- bundles/org.pitest/META-INF/MANIFEST.MF | 5 +- bundles/org.pitest/pom.xml | 4 +- .../pitclipse/runner/MutatorApiOfPitTest.java | 158 +++++++++++------- .../mutations/ListenerTestFixture.java | 3 +- .../SummaryResultListenerTestData.java | 127 +++++++------- 8 files changed, 184 insertions(+), 148 deletions(-) diff --git a/bundles/org.pitest.pitclipse.runner/src/org/pitest/pitclipse/runner/results/mutations/PitclipseMutationsResultListener.java b/bundles/org.pitest.pitclipse.runner/src/org/pitest/pitclipse/runner/results/mutations/PitclipseMutationsResultListener.java index 0da4235a..1e2ab315 100644 --- a/bundles/org.pitest.pitclipse.runner/src/org/pitest/pitclipse/runner/results/mutations/PitclipseMutationsResultListener.java +++ b/bundles/org.pitest.pitclipse.runner/src/org/pitest/pitclipse/runner/results/mutations/PitclipseMutationsResultListener.java @@ -61,7 +61,7 @@ public void handleMutationResult(ClassMutationResults results) { result.getKillingTest().ifPresent(mutation::setKillingTest); mutation.setLineNumber(BigInteger.valueOf(details.getLineNumber())); mutation.setMutatedClass(details.getClassName().asJavaName()); - mutation.setMutatedMethod(details.getMethod().name()); + mutation.setMutatedMethod(details.getMethod()); mutation.setMutator(details.getMutator()); mutation.setSourceFile(details.getFilename()); mutation.setStatus(DetectionStatusCoverter.convert(result.getStatus())); diff --git a/bundles/org.pitest.pitclipse.runner/src/org/pitest/pitclipse/runner/results/summary/ClassSummary.java b/bundles/org.pitest.pitclipse.runner/src/org/pitest/pitclipse/runner/results/summary/ClassSummary.java index fb5084de..957be41b 100644 --- a/bundles/org.pitest.pitclipse.runner/src/org/pitest/pitclipse/runner/results/summary/ClassSummary.java +++ b/bundles/org.pitest.pitclipse.runner/src/org/pitest/pitclipse/runner/results/summary/ClassSummary.java @@ -21,6 +21,7 @@ import java.util.Objects; import org.pitest.classinfo.ClassInfo; +import org.pitest.coverage.CoverageData; import org.pitest.mutationtest.ClassMutationResults; import org.pitest.mutationtest.MutationResult; @@ -43,13 +44,14 @@ private ClassSummary(String className, Coverage lineCoverage, Coverage mutationC this.mutationCoverage = mutationCoverage; } - public static ClassSummary from(ClassMutationResults results, ClassInfo classInfo, int linesCovered) { + public static ClassSummary from(ClassMutationResults results, int numberOfCodeLines, int linesCovered) { Collection mutations = results.getMutations(); int totalMutations = mutations.size(); int survivedMutations = (int) mutations.stream() .filter(m -> !m.getStatus().isDetected()) .count(); - Coverage lineCoverage = Coverage.from(linesCovered, classInfo.getNumberOfCodeLines()); + CoverageData data; + Coverage lineCoverage = Coverage.from(linesCovered, numberOfCodeLines); Coverage mutationCoverage = Coverage.from(totalMutations - survivedMutations, totalMutations); return from(results.getMutatedClass().asJavaName(), lineCoverage, mutationCoverage); diff --git a/bundles/org.pitest.pitclipse.runner/src/org/pitest/pitclipse/runner/results/summary/SummaryResultListener.java b/bundles/org.pitest.pitclipse.runner/src/org/pitest/pitclipse/runner/results/summary/SummaryResultListener.java index 4427c67b..a821f2d6 100644 --- a/bundles/org.pitest.pitclipse.runner/src/org/pitest/pitclipse/runner/results/summary/SummaryResultListener.java +++ b/bundles/org.pitest.pitclipse.runner/src/org/pitest/pitclipse/runner/results/summary/SummaryResultListener.java @@ -19,9 +19,8 @@ import java.util.Collections; import java.util.List; -import org.pitest.classinfo.ClassInfo; import org.pitest.classinfo.ClassName; -import org.pitest.coverage.CoverageDatabase; +import org.pitest.coverage.ReportCoverage; import org.pitest.mutationtest.ClassMutationResults; import org.pitest.mutationtest.MutationResultListener; import org.pitest.pitclipse.runner.results.Dispatcher; @@ -37,7 +36,7 @@ public class SummaryResultListener implements MutationResultListener { private SummaryResult result = SummaryResult.EMPTY; private final Dispatcher dispatcher; - private final CoverageDatabase coverage; + private final ReportCoverage coverage; /** * Creates a new listener that will compute a summary of the whole PIT analysis. @@ -47,7 +46,7 @@ public class SummaryResultListener implements MutationResultListener { * @param coverage * The coverage computed from the tests. */ - public SummaryResultListener(Dispatcher dispatcher, CoverageDatabase coverage) { + public SummaryResultListener(Dispatcher dispatcher, ReportCoverage coverage) { this.dispatcher = dispatcher; this.coverage = coverage; } @@ -59,12 +58,20 @@ public void runStart() { @Override public void handleMutationResult(ClassMutationResults results) { - List classUnderTest = Collections.singletonList(results.getMutatedClass()); - int coveredLines = coverage.getNumberOfCoveredLines(classUnderTest); - for (ClassInfo info : coverage.getClassInfo(classUnderTest)) { - ClassSummary classSummary = ClassSummary.from(results, info, coveredLines); - result = result.update(classSummary); - } + List classesUnderTest = Collections.singletonList(results.getMutatedClass()); + +// long totalNumberOfCoveredLines = classesUnderTest.stream().map(coverage::getCoveredLines).flatMap(Collection::stream).count(); + +// int coveredLines = coverage.getNumberOfCoveredLines(classUnderTest); + for (ClassName classUnderTest : classesUnderTest) { + int numberOfCoveredLines = coverage.getCoveredLines(classUnderTest).size(); + int numberOfLines = coverage.getCodeLinesForClass(classUnderTest).getNumberOfCodeLines(); + ClassSummary classSummary = ClassSummary.from(results, numberOfLines, numberOfCoveredLines); + result = result.update(classSummary); + } +// for (ClassInfo info : coverage.getClassInfo(classesUnderTest)) { +// ClassSummary classSummary = ClassSummary.from(results, info, totalNumberOfCoveredLines); +// } } @Override diff --git a/bundles/org.pitest/META-INF/MANIFEST.MF b/bundles/org.pitest/META-INF/MANIFEST.MF index 5ffd0506..84c567bd 100644 --- a/bundles/org.pitest/META-INF/MANIFEST.MF +++ b/bundles/org.pitest/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: Pitest Bundle-SymbolicName: org.pitest -Bundle-Version: 1.6.8.qualifier +Bundle-Version: 1.15.8.qualifier Bundle-ClassPath: lib/pitest-command-line-javadoc.jar, lib/pitest-command-line-sources.jar, lib/pitest-command-line.jar, @@ -34,7 +34,6 @@ Export-Package: joptsimple, org.pitest.coverage.analysis, org.pitest.coverage.execute, org.pitest.coverage.export, - org.pitest.dependency, org.pitest.extension.common, org.pitest.functional, org.pitest.functional.predicate, @@ -60,7 +59,6 @@ Export-Package: joptsimple, org.pitest.mutationtest.engine.gregor.config, org.pitest.mutationtest.engine.gregor.mutators, org.pitest.mutationtest.engine.gregor.mutators.experimental, - org.pitest.mutationtest.engine.gregor.mutators.rv, org.pitest.mutationtest.execute, org.pitest.mutationtest.filter, org.pitest.mutationtest.incremental, @@ -98,7 +96,6 @@ Export-Package: joptsimple, org.pitest.testapi, org.pitest.testapi.execute, org.pitest.testapi.execute.containers, - org.pitest.testng, org.pitest.util, sun.pitest Bundle-RequiredExecutionEnvironment: JavaSE-1.8 diff --git a/bundles/org.pitest/pom.xml b/bundles/org.pitest/pom.xml index d50966c1..84d08e98 100644 --- a/bundles/org.pitest/pom.xml +++ b/bundles/org.pitest/pom.xml @@ -9,12 +9,12 @@ org.pitest - 1.6.8-SNAPSHOT + 1.15.8-SNAPSHOT eclipse-plugin Wraps Pitest JAR as an Eclipse plug-in - 1.6.8 + 1.15.8 diff --git a/tests/org.pitest.pitclipse.runner.tests/src/org/pitest/pitclipse/runner/MutatorApiOfPitTest.java b/tests/org.pitest.pitclipse.runner.tests/src/org/pitest/pitclipse/runner/MutatorApiOfPitTest.java index 10c1426f..d0acbb0e 100644 --- a/tests/org.pitest.pitclipse.runner.tests/src/org/pitest/pitclipse/runner/MutatorApiOfPitTest.java +++ b/tests/org.pitest.pitclipse.runner.tests/src/org/pitest/pitclipse/runner/MutatorApiOfPitTest.java @@ -41,68 +41,100 @@ private String getPitMutatorsAsString() { } private String getExpectedMutatorsAsString() { - return "INVERT_NEGS\n" - + "RETURN_VALS\n" - + "INLINE_CONSTS\n" - + "MATH\n" - + "VOID_METHOD_CALLS\n" - + "NEGATE_CONDITIONALS\n" - + "CONDITIONALS_BOUNDARY\n" - + "INCREMENTS\n" - + "REMOVE_INCREMENTS\n" - + "NON_VOID_METHOD_CALLS\n" - + "CONSTRUCTOR_CALLS\n" - + "REMOVE_CONDITIONALS_EQ_IF\n" - + "REMOVE_CONDITIONALS_EQ_ELSE\n" - + "REMOVE_CONDITIONALS_ORD_IF\n" - + "REMOVE_CONDITIONALS_ORD_ELSE\n" - + "REMOVE_CONDITIONALS\n" - + "TRUE_RETURNS\n" - + "FALSE_RETURNS\n" - + "PRIMITIVE_RETURNS\n" - + "EMPTY_RETURNS\n" - + "NULL_RETURNS\n" - + "RETURNS\n" - + "EXPERIMENTAL_MEMBER_VARIABLE\n" - + "EXPERIMENTAL_SWITCH\n" - + "EXPERIMENTAL_ARGUMENT_PROPAGATION\n" - + "EXPERIMENTAL_NAKED_RECEIVER\n" - + "EXPERIMENTAL_BIG_INTEGER\n" - + "AOR_1\n" - + "AOR_2\n" - + "AOR_3\n" - + "AOR_4\n" - + "ABS\n" - + "AOD1\n" - + "AOD2\n" - + "CRCR1\n" - + "CRCR2\n" - + "CRCR3\n" - + "CRCR4\n" - + "CRCR5\n" - + "CRCR6\n" - + "OBBN1\n" - + "OBBN2\n" - + "OBBN3\n" - + "ROR1\n" - + "ROR2\n" - + "ROR3\n" - + "ROR4\n" - + "ROR5\n" - + "UOI1\n" - + "UOI2\n" - + "UOI3\n" - + "UOI4\n" - + "REMOVE_SWITCH\n" - + "OLD_DEFAULTS\n" - + "STRONGER\n" - + "ALL\n" - + "DEFAULTS\n" - + "AOR\n" - + "AOD\n" - + "CRCR\n" - + "OBBN\n" - + "ROR\n" - + "UOI\n"; + return "REMOVE_CONDITIONALS_ORDER_IF\n" + + "REMOVE_CONDITIONALS\n" + + "REMOVE_CONDITIONALS_EQUAL_IF\n" + + "TRUE_RETURNS\n" + + "REMOVE_CONDITIONALS_EQUAL_ELSE\n" + + "VOID_METHOD_CALLS\n" + + "PRIMITIVE_RETURNS\n" + + "FALSE_RETURNS\n" + + "NON_VOID_METHOD_CALLS\n" + + "INVERT_NEGS\n" + + "CONDITIONALS_BOUNDARY\n" + + "REMOVE_CONDITIONALS_ORDER_ELSE\n" + + "DEFAULTS\n" + + "EXPERIMENTAL_SWITCH\n" + + "RETURNS\n" + + "EXPERIMENTAL_MEMBER_VARIABLE\n" + + "NULL_RETURNS\n" + + "EXPERIMENTAL_BIG_DECIMAL\n" + + "MATH\n" + + "EXPERIMENTAL_BIG_INTEGER\n" + + "INCREMENTS\n" + + "EXPERIMENTAL_ARGUMENT_PROPAGATION\n" + + "EXPERIMENTAL_NAKED_RECEIVER\n" + + "CONSTRUCTOR_CALLS\n" + + "REMOVE_SWITCH\n" + + "INLINE_CONSTS\n" + + "STRONGER\n" + + "REMOVE_INCREMENTS\n" + + "NEGATE_CONDITIONALS\n" + + "EMPTY_RETURNS\n"; + + +// return "INVERT_NEGS\n" +// + "RETURN_VALS\n" +// + "INLINE_CONSTS\n" +// + "MATH\n" +// + "VOID_METHOD_CALLS\n" +// + "NEGATE_CONDITIONALS\n" +// + "CONDITIONALS_BOUNDARY\n" +// + "INCREMENTS\n" +// + "REMOVE_INCREMENTS\n" +// + "NON_VOID_METHOD_CALLS\n" +// + "CONSTRUCTOR_CALLS\n" +// + "REMOVE_CONDITIONALS_EQ_IF\n" +// + "REMOVE_CONDITIONALS_EQ_ELSE\n" +// + "REMOVE_CONDITIONALS_ORD_IF\n" +// + "REMOVE_CONDITIONALS_ORD_ELSE\n" +// + "REMOVE_CONDITIONALS\n" +// + "TRUE_RETURNS\n" +// + "FALSE_RETURNS\n" +// + "PRIMITIVE_RETURNS\n" +// + "EMPTY_RETURNS\n" +// + "NULL_RETURNS\n" +// + "RETURNS\n" +// + "EXPERIMENTAL_MEMBER_VARIABLE\n" +// + "EXPERIMENTAL_SWITCH\n" +// + "EXPERIMENTAL_ARGUMENT_PROPAGATION\n" +// + "EXPERIMENTAL_NAKED_RECEIVER\n" +// + "EXPERIMENTAL_BIG_INTEGER\n" +// + "AOR_1\n" +// + "AOR_2\n" +// + "AOR_3\n" +// + "AOR_4\n" +// + "ABS\n" +// + "AOD1\n" +// + "AOD2\n" +// + "CRCR1\n" +// + "CRCR2\n" +// + "CRCR3\n" +// + "CRCR4\n" +// + "CRCR5\n" +// + "CRCR6\n" +// + "OBBN1\n" +// + "OBBN2\n" +// + "OBBN3\n" +// + "ROR1\n" +// + "ROR2\n" +// + "ROR3\n" +// + "ROR4\n" +// + "ROR5\n" +// + "UOI1\n" +// + "UOI2\n" +// + "UOI3\n" +// + "UOI4\n" +// + "REMOVE_SWITCH\n" +// + "OLD_DEFAULTS\n" +// + "STRONGER\n" +// + "ALL\n" +// + "DEFAULTS\n" +// + "AOR\n" +// + "AOD\n" +// + "CRCR\n" +// + "OBBN\n" +// + "ROR\n" +// + "UOI\n"; } } diff --git a/tests/org.pitest.pitclipse.runner.tests/src/org/pitest/pitclipse/runner/results/mutations/ListenerTestFixture.java b/tests/org.pitest.pitclipse.runner.tests/src/org/pitest/pitclipse/runner/results/mutations/ListenerTestFixture.java index 69e500ad..33f8d43b 100644 --- a/tests/org.pitest.pitclipse.runner.tests/src/org/pitest/pitclipse/runner/results/mutations/ListenerTestFixture.java +++ b/tests/org.pitest.pitclipse.runner.tests/src/org/pitest/pitclipse/runner/results/mutations/ListenerTestFixture.java @@ -28,7 +28,6 @@ import org.pitest.mutationtest.MutationResult; import org.pitest.mutationtest.MutationStatusTestPair; import org.pitest.mutationtest.engine.Location; -import org.pitest.mutationtest.engine.MethodName; import org.pitest.mutationtest.engine.MutationDetails; import org.pitest.mutationtest.engine.MutationIdentifier; import org.pitest.pitclipse.example.Foo; @@ -48,7 +47,7 @@ class ListenerTestFixture { private static final ObjectFactory JAXB_OBJECT_FACTORY = new ObjectFactory(); public static ClassMutationResults aClassMutationResult() { - Location location = new Location(ClassName.fromClass(Foo.class), MethodName.fromString("doFoo"), "doFoo"); + Location location = new Location(ClassName.fromClass(Foo.class), "doFoo", "doFoo"); MutationIdentifier id = new MutationIdentifier(location, 1, "SomeMutator"); MutationDetails md = new MutationDetails(id, "org/pitest/pitclipse/example/Foo.java", TEST_FACTORY.aString(), 20, TEST_FACTORY.aRandomInt()); diff --git a/tests/org.pitest.pitclipse.runner.tests/src/org/pitest/pitclipse/runner/results/summary/SummaryResultListenerTestData.java b/tests/org.pitest.pitclipse.runner.tests/src/org/pitest/pitclipse/runner/results/summary/SummaryResultListenerTestData.java index 03e14e8c..828da9a4 100644 --- a/tests/org.pitest.pitclipse.runner.tests/src/org/pitest/pitclipse/runner/results/summary/SummaryResultListenerTestData.java +++ b/tests/org.pitest.pitclipse.runner.tests/src/org/pitest/pitclipse/runner/results/summary/SummaryResultListenerTestData.java @@ -16,39 +16,34 @@ package org.pitest.pitclipse.runner.results.summary; -import static com.google.common.base.Predicates.notNull; -import static com.google.common.collect.Collections2.filter; -import static com.google.common.collect.Collections2.transform; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; +import static java.util.stream.Collectors.toSet; import static org.pitest.mutationtest.DetectionStatus.KILLED; import static org.pitest.mutationtest.DetectionStatus.NO_COVERAGE; import static org.pitest.pitclipse.runner.TestFactory.TEST_FACTORY; import java.math.BigInteger; import java.util.Collection; -import java.util.Collections; +import java.util.HashSet; import java.util.Map; +import java.util.Set; +import java.util.stream.Stream; -import org.pitest.classinfo.ClassInfo; import org.pitest.classinfo.ClassName; +import org.pitest.coverage.BlockLocation; import org.pitest.coverage.ClassLine; +import org.pitest.coverage.ClassLines; import org.pitest.coverage.CoverageDatabase; -import org.pitest.coverage.CoverageSummary; -import org.pitest.coverage.InstructionLocation; import org.pitest.coverage.TestInfo; import org.pitest.mutationtest.ClassMutationResults; import org.pitest.mutationtest.DetectionStatus; import org.pitest.mutationtest.MutationResult; import org.pitest.mutationtest.MutationStatusTestPair; import org.pitest.mutationtest.engine.Location; -import org.pitest.mutationtest.engine.MethodName; import org.pitest.mutationtest.engine.MutationDetails; import org.pitest.mutationtest.engine.MutationIdentifier; import org.pitest.pitclipse.example.Foo; import org.pitest.pitclipse.runner.results.summary.SummaryResultListenerTestSugar.SummaryResultWrapper; -import com.google.common.base.Function; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -78,7 +73,7 @@ public static CoverageDatabase fooHasFullLineCoverage() { } private static ClassMutationResults aClassMutationResultForFooWithStatus(DetectionStatus detectionStatus) { - Location location = new Location(ClassName.fromClass(Foo.class), MethodName.fromString("doFoo"), "doFoo"); + Location location = new Location(ClassName.fromClass(Foo.class), "doFoo", "doFoo"); MutationIdentifier id = new MutationIdentifier(location, 1, "SomeMutator"); MutationDetails md = new MutationDetails(id, "org/pitest/pitclipse/example/Foo.java", TEST_FACTORY.aString(), 9, TEST_FACTORY.aRandomInt()); @@ -90,36 +85,31 @@ private static ClassMutationResults aClassMutationResultForFooWithStatus(Detecti private static class CoverageTestData { - public static final CoverageTestData FOO_WITH_FULL_COVERAGE = new CoverageTestData(Foo.class, fooInfo(1), 1); - public static final CoverageTestData FOO_WITH_NO_COVERAGE = new CoverageTestData(Foo.class, fooInfo(1), 0); + public static final CoverageTestData FOO_WITH_FULL_COVERAGE = new CoverageTestData(Foo.class, 1, 1); + public static final CoverageTestData FOO_WITH_NO_COVERAGE = new CoverageTestData(Foo.class, 1, 0); public final ClassName className; - public final ClassInfo classInfo; public final int linesCovered; + public final int totalNumberOfLines; public final StubbedCoverage coverageDatabase; - private CoverageTestData(Class clazz, ClassInfo classInfo, int linesCovered) { + private CoverageTestData(Class clazz, int totalNumberOfLines, int linesCovered) { this.className = ClassName.fromClass(clazz); - this.classInfo = classInfo; this.linesCovered = linesCovered; + this.totalNumberOfLines = totalNumberOfLines; this.coverageDatabase = new StubbedCoverage(this); } - private static ClassInfo fooInfo(int totalLines) { - ClassInfo info = mock(ClassInfo.class); - when(info.getNumberOfCodeLines()).thenReturn(totalLines); - return info; - } } private static class StubbedCoverage implements CoverageDatabase { // DATABASE; - private final Map classInfo; + private final Map classInfo; private final Map classCoverage; private StubbedCoverage(CoverageTestData coverageTestData) { - classInfo = ImmutableMap.of(coverageTestData.className, coverageTestData.classInfo); + classInfo = ImmutableMap.of(coverageTestData.className, coverageTestData.totalNumberOfLines); classCoverage = ImmutableMap.of(coverageTestData.className, coverageTestData.linesCovered); } @@ -128,61 +118,70 @@ private StubbedCoverage() { classCoverage = ImmutableMap.of(); } - @Override - public Collection getClassInfo(Collection classes) { - return filter(transform(classes, classInfoLookup()), notNull()); - } - - @Override - public int getNumberOfCoveredLines(Collection classes) { - int total = 0; - for (ClassName className : classes) { - total += coverageFor(className); - } - return total; - } - - private int coverageFor(ClassName className) { - return classCoverage.getOrDefault(className, 0); - } + @Override + public ClassLines getCodeLinesForClass(ClassName clazz) { + int totalNumberOfLines = classInfo.getOrDefault(clazz, -1); + Set linesNumber = Stream.iterate(1, x -> x + 1).limit(totalNumberOfLines).collect(toSet()); + return new ClassLines(clazz, linesNumber); + } + + @Override + public Set getCoveredLines(ClassName clazz) { + Set lines = new HashSet<>(); + int expectedNbOfLinesCovered = classCoverage.getOrDefault(clazz, -1); + + for (int i = 0; i < expectedNbOfLinesCovered; ++i) { + lines.add(new ClassLine(clazz, i)); + } + return lines; + } + + @Override + public Collection getTestsForBlockLocation(BlockLocation location) { + throw new UnsupportedOperationException("the stub does not implement getTestsForBlockLocation"); + } + +// @Override +// public Collection getClassInfo(Collection classes) { +// return filter(transform(classes, classInfoLookup()), notNull()); +// } +// +// @Override +// public int getNumberOfCoveredLines(Collection classes) { +// int total = 0; +// for (ClassName className : classes) { +// total += coverageFor(className); +// } +// return total; +// } + +// private int coverageFor(ClassName className) { +// return classCoverage.getOrDefault(className, 0); +// } @Override public Collection getTestsForClass(ClassName clazz) { return ImmutableList.of(); } - @Override - public Collection getTestsForClassLine(ClassLine classLine) { - return ImmutableList.of(); - } - @Override public BigInteger getCoverageIdForClass(ClassName clazz) { return TEST_FACTORY.aRandomBigInteger(); } @Override - public Collection getClassesForFile(String sourceFile, String packageName) { + public Collection getClassesForFile(String sourceFile, String packageName) { return ImmutableList.of(); } - @Override - public CoverageSummary createSummary() { - return null; - } +// private Function classInfoLookup() { +// return new Function() { +// @Override +// public ClassInfo apply(ClassName input) { +// return classInfo.get(input); +// } +// }; +// } - private Function classInfoLookup() { - return new Function() { - @Override - public ClassInfo apply(ClassName input) { - return classInfo.get(input); - } - }; - } - - @Override - public Collection getTestsForInstructionLocation(InstructionLocation location) { - return Collections.emptyList(); - } } } From 8bd1957556964e8267baec9fa093ff145b19178a Mon Sep 17 00:00:00 2001 From: Emmanuel CHEBBI Date: Sat, 23 Mar 2024 23:26:51 +0100 Subject: [PATCH 02/11] bump junit5 plugin --- .../org.pitest.pitest-junit5-plugin/.classpath | 15 +-------------- .../META-INF/MANIFEST.MF | 2 +- bundles/org.pitest.pitest-junit5-plugin/pom.xml | 4 ++-- 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/bundles/org.pitest.pitest-junit5-plugin/.classpath b/bundles/org.pitest.pitest-junit5-plugin/.classpath index 4b7e0d2f..49d2148b 100644 --- a/bundles/org.pitest.pitest-junit5-plugin/.classpath +++ b/bundles/org.pitest.pitest-junit5-plugin/.classpath @@ -1,6 +1,6 @@ - + @@ -13,19 +13,6 @@ - - - - - - - - - - - - - diff --git a/bundles/org.pitest.pitest-junit5-plugin/META-INF/MANIFEST.MF b/bundles/org.pitest.pitest-junit5-plugin/META-INF/MANIFEST.MF index 043895a0..450c70ae 100644 --- a/bundles/org.pitest.pitest-junit5-plugin/META-INF/MANIFEST.MF +++ b/bundles/org.pitest.pitest-junit5-plugin/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: pitest-junit5-plugin Bundle-SymbolicName: org.pitest.pitest-junit5-plugin -Bundle-Version: 0.14.0.qualifier +Bundle-Version: 1.2.1 Bundle-ClassPath: lib/pitest-junit5-plugin-sources.jar, lib/pitest-junit5-plugin-javadoc.jar, lib/pitest-junit5-plugin.jar, diff --git a/bundles/org.pitest.pitest-junit5-plugin/pom.xml b/bundles/org.pitest.pitest-junit5-plugin/pom.xml index 61ff96ca..acd942b7 100644 --- a/bundles/org.pitest.pitest-junit5-plugin/pom.xml +++ b/bundles/org.pitest.pitest-junit5-plugin/pom.xml @@ -9,7 +9,7 @@ org.pitest.pitest-junit5-plugin - 0.14.0-SNAPSHOT + 1.2.1 eclipse-plugin Wraps Pitest JUnit 5 Plugin's JAR as an Eclipse plug-in @@ -17,7 +17,7 @@ - 0.14 + 1.2.1 From 6b230a5268ba59a591c9dc47ce9e57cce0136207 Mon Sep 17 00:00:00 2001 From: Emmanuel CHEBBI Date: Sat, 23 Mar 2024 23:27:03 +0100 Subject: [PATCH 03/11] WIP --- .../pageobjects/DurationElapsed.java | 27 ++++++++++++++ .../pageobjects/NoTestsFoundDialog.java | 2 + .../PitMutationsViewPageObject.java | 37 +++++++++++-------- .../pageobjects/ViewOpenedCondition.java | 4 +- .../tests/PitclipseMultipleProjectsTest.java | 3 ++ .../tests/PitclipsePitMutationsViewTest.java | 16 +++++++- 6 files changed, 69 insertions(+), 20 deletions(-) create mode 100644 tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/DurationElapsed.java diff --git a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/DurationElapsed.java b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/DurationElapsed.java new file mode 100644 index 00000000..9a2254e6 --- /dev/null +++ b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/DurationElapsed.java @@ -0,0 +1,27 @@ +package org.pitest.pitclipse.ui.behaviours.pageobjects; + +import org.eclipse.swtbot.swt.finder.waits.DefaultCondition; + +public class DurationElapsed extends DefaultCondition { + + private Long time; + + private long durationInSeconds; + + public DurationElapsed(long duration) { + this.durationInSeconds = duration; + } + + @Override + public boolean test() throws Exception { + if (time == null) { + time = System.currentTimeMillis(); + } + return time + 2000 <= System.currentTimeMillis(); + } + + @Override + public String getFailureMessage() { + return "Failed to wait for " + durationInSeconds + " s"; + } +} \ No newline at end of file diff --git a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/NoTestsFoundDialog.java b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/NoTestsFoundDialog.java index 58b53042..cb85606b 100644 --- a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/NoTestsFoundDialog.java +++ b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/NoTestsFoundDialog.java @@ -31,7 +31,9 @@ public NoTestsFoundDialog(SWTWorkbenchBot bot) { public void assertAppears() { SWTBotShell shell = bot.shell("Pitclipse"); shell.activate(); + bot.waitUntil(new DurationElapsed(500)); bot.label("No tests found"); + bot.waitUntil(new DurationElapsed(500)); bot.button("OK").click(); bot.waitUntil(Conditions.shellCloses(shell)); diff --git a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/PitMutationsViewPageObject.java b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/PitMutationsViewPageObject.java index 9cbca2ff..18c4db07 100644 --- a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/PitMutationsViewPageObject.java +++ b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/PitMutationsViewPageObject.java @@ -67,9 +67,10 @@ public SWTBotView getView() { SWTBotView mutationsView = bot.viewByTitle("PIT Mutations"); mutationsView.show(); mutationsView.setFocus(); + // // Make sure the 'PIT Mutations' view is opened - // this should not be required anymore - // bot.waitUntil(new ViewOpenedCondition(bot, "PIT Mutations")); + // + bot.waitUntil(new ViewOpenedCondition(bot, "PIT Mutations")); return mutationsView; } @@ -157,12 +158,13 @@ private MutationsTree(ImmutableList statuses) { this.statuses = statuses; } - public void select(PitMutation mutation) { + public boolean select(PitMutation mutation) { String status = mutation.getStatus().toString(); for (StatusTree statusTree : statuses) { if (status.equals(statusTree.statusName)) { - statusTree.select(mutation); - return; + if (statusTree.select(mutation)) { + return true; + } } } throw new AssertionFailedError( @@ -187,11 +189,12 @@ private StatusTree(String statusName, ImmutableList projects) { this.projects = projects; } - public void select(PitMutation mutation) { + public boolean select(PitMutation mutation) { for (ProjectTree projectTree : projects) { if (mutation.getProject().equals(projectTree.projectName)) { - projectTree.select(mutation); - return; + if (projectTree.select(mutation)) { + return true; + } } } throw new AssertionFailedError( @@ -218,11 +221,12 @@ private ProjectTree(String projectName, ImmutableList packages) { this.packages = packages; } - public void select(PitMutation mutation) { + public boolean select(PitMutation mutation) { for (PackageTree packageTree : packages) { if (mutation.getPkg().equals(packageTree.packageName)) { - packageTree.select(mutation); - return; + if (packageTree.select(mutation)) { + return true; + } } } throw new AssertionFailedError( @@ -249,11 +253,12 @@ private PackageTree(String packageName, ImmutableList classes) { this.classes = classes; } - public void select(PitMutation mutation) { + public boolean select(PitMutation mutation) { for (ClassTree classTree : classes) { if (mutation.getClassName().equals(classTree.className)) { - classTree.select(mutation); - return; + if (classTree.select(mutation)) { + return true; + } } } throw new AssertionFailedError( @@ -280,12 +285,12 @@ private ClassTree(String className, ImmutableList projects) { this.mutations = projects; } - public void select(PitMutation mutation) { + public boolean select(PitMutation mutation) { for (MutationTree mutationTree : mutations) { if (mutation.getLineNumber() == mutationTree.lineNumber && mutation.getMutation().equals(mutationTree.mutation)) { mutationTree.select(); - return; + return true; } } throw new AssertionFailedError( diff --git a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/ViewOpenedCondition.java b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/ViewOpenedCondition.java index 873d182b..0fb4b5c5 100644 --- a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/ViewOpenedCondition.java +++ b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/ViewOpenedCondition.java @@ -3,11 +3,11 @@ import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; import org.eclipse.swtbot.swt.finder.waits.DefaultCondition; -class ViewOpenedCondition extends DefaultCondition { +public class ViewOpenedCondition extends DefaultCondition { private SWTWorkbenchBot bot; private String viewTitle; - + public ViewOpenedCondition(SWTWorkbenchBot bot, String viewTitle) { this.bot = bot; this.viewTitle = viewTitle; diff --git a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipseMultipleProjectsTest.java b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipseMultipleProjectsTest.java index b09aa6df..6e8c9e4c 100644 --- a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipseMultipleProjectsTest.java +++ b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipseMultipleProjectsTest.java @@ -21,6 +21,7 @@ import org.junit.runner.RunWith; import org.pitest.pitclipse.core.PitCoreActivator; import org.pitest.pitclipse.core.preferences.PitPreferences; +import org.pitest.pitclipse.ui.behaviours.pageobjects.DurationElapsed; import org.pitest.pitclipse.ui.behaviours.pageobjects.PitPreferenceSelector; /** @@ -66,12 +67,14 @@ public void removeLaunchConfigurations() throws CoreException { public void testExecutionMode() throws CoreException { try { PitPreferenceSelector selector = PAGES.getWindowsMenu().openPreferences().andThen(); + bot.waitUntil(new DurationElapsed(200)); assertEquals(PROJECT_ISOLATION, selector.getPitExecutionMode()); selector.close(); runProjectTest(FOO_BAR_PROJECT); // only the classes in the project is mutated coverageReportGenerated(2, 100, 100, 3, 3); selector = PAGES.getWindowsMenu().openPreferences().andThen(); + bot.waitUntil(new DurationElapsed(200)); selector.setPitExecutionMode(WORKSPACE); selector.close(); runProjectTest(FOO_BAR_PROJECT); diff --git a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipsePitMutationsViewTest.java b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipsePitMutationsViewTest.java index cda857e7..c20ac044 100644 --- a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipsePitMutationsViewTest.java +++ b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipsePitMutationsViewTest.java @@ -1,5 +1,7 @@ package org.pitest.pitclipse.ui.tests; +import static org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory.withTitle; +import static org.eclipse.swtbot.eclipse.finder.waits.Conditions.waitForEditor; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -10,6 +12,7 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; +import org.pitest.pitclipse.ui.behaviours.pageobjects.DurationElapsed; import org.pitest.pitclipse.ui.behaviours.pageobjects.PitMutationsViewPageObject; import org.pitest.pitclipse.ui.behaviours.steps.PitMutation; import org.pitest.pitclipse.ui.behaviours.steps.PitclipseSteps; @@ -47,12 +50,21 @@ public void selectMutationOpensTheClassAtTheRightLineNumber() throws CoreExcepti coverageReportGenerated(2, 80, 0, 6, 0); PitclipseSteps pitclipseSteps = new PitclipseSteps(); PitMutation mutation = fromMutationLine( - "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 7 | negated conditional"); + "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 7 | removed conditional - replaced equality check with false"); + final PitMutationsViewPageObject pitMutationsView = new PitMutationsViewPageObject(bot); + pitMutationsView.getView(); + bot.waitUntil(new DurationElapsed(200)); pitclipseSteps.doubleClickMutationInMutationsView(mutation); + + bot.waitUntil(waitForEditor(withTitle(FOO_CLASS + ".java"))); + bot.waitUntil(new DurationElapsed(200)); pitclipseSteps.mutationIsOpened(FOO_CLASS + ".java", 7); mutation = fromMutationLine( - "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Bar | 7 | negated conditional"); + "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Bar | 7 | removed conditional - replaced equality check with false"); pitclipseSteps.doubleClickMutationInMutationsView(mutation); + + bot.waitUntil(waitForEditor(withTitle(BAR_CLASS + ".java"))); + bot.waitUntil(new DurationElapsed(200)); pitclipseSteps.mutationIsOpened(BAR_CLASS + ".java", 7); } From 8acf7f006a4a1a5db0b0bba348ea078d1fdeca24 Mon Sep 17 00:00:00 2001 From: Emmanuel CHEBBI Date: Tue, 26 Mar 2024 21:25:56 +0100 Subject: [PATCH 04/11] tests OK --- .../old-cucumber/j06_mutations_view.feature | 14 +-- .../pageobjects/NoTestsFoundDialog.java | 2 - .../pageobjects/RunConfigurationSelector.java | 2 + .../ui/behaviours/pageobjects/RunMenu.java | 1 + .../ui/tests/PitclipseOptionsTest.java | 31 +----- ...clipseRunConfigurationMutationTabTest.java | 98 ++----------------- .../ui/tests/PitclipseUiRunnerTest.java | 2 +- 7 files changed, 25 insertions(+), 125 deletions(-) diff --git a/tests/org.pitest.pitclipse.ui.tests/old-cucumber/j06_mutations_view.feature b/tests/org.pitest.pitclipse.ui.tests/old-cucumber/j06_mutations_view.feature index 5a248edd..e81b8cd1 100644 --- a/tests/org.pitest.pitclipse.ui.tests/old-cucumber/j06_mutations_view.feature +++ b/tests/org.pitest.pitclipse.ui.tests/old-cucumber/j06_mutations_view.feature @@ -13,8 +13,8 @@ Feature: Mutation view shows analysis results Then a coverage report is generated with 2 classes tested with overall coverage of 80% and mutation coverage of 0% And the mutation results are | status | project | package | class | line | mutation | - | SURVIVED | project1 | foo.bar | foo.bar.Bar | 9 | negated conditional | - | SURVIVED | project1 | foo.bar | foo.bar.Foo | 9 | negated conditional | + | SURVIVED | project1 | foo.bar | foo.bar.Bar | 9 | removed conditional - replaced equality check with false | + | SURVIVED | project1 | foo.bar | foo.bar.Foo | 9 | removed conditional - replaced equality check with false | | NO_COVERAGE | project1 | foo.bar | foo.bar.Bar | 10 | Replaced integer addition with subtraction | | NO_COVERAGE | project1 | foo.bar | foo.bar.Bar | 10 | replaced int return with 0 for foo/bar/Bar::f | | NO_COVERAGE | project1 | foo.bar | foo.bar.Foo | 10 | Replaced integer addition with subtraction | @@ -23,7 +23,7 @@ Feature: Mutation view shows analysis results Scenario: Selecting a mutation opens the class in question at the right line number When the following mutation is selected | status | project | package | class | line | mutation | - | SURVIVED | project1 | foo.bar | foo.bar.Foo | 9 | negated conditional | + | SURVIVED | project1 | foo.bar | foo.bar.Foo | 9 | removed conditional - replaced equality check with false | Then the file "Foo.java" is opened at line number 9 Scenario: Using the stronger mutators yields more mutation results @@ -32,10 +32,10 @@ Feature: Mutation view shows analysis results Then a coverage report is generated with 2 classes tested with overall coverage of 80% and mutation coverage of 0% And the mutation results are | status | project | package | class | line | mutation | - | SURVIVED | project1 | foo.bar | foo.bar.Bar | 9 | negated conditional | | SURVIVED | project1 | foo.bar | foo.bar.Bar | 9 | removed conditional - replaced equality check with false | - | SURVIVED | project1 | foo.bar | foo.bar.Foo | 9 | negated conditional | + | SURVIVED | project1 | foo.bar | foo.bar.Bar | 9 | removed conditional - replaced equality check with true | | SURVIVED | project1 | foo.bar | foo.bar.Foo | 9 | removed conditional - replaced equality check with false | + | SURVIVED | project1 | foo.bar | foo.bar.Foo | 9 | removed conditional - replaced equality check with true | | NO_COVERAGE | project1 | foo.bar | foo.bar.Bar | 10 | Replaced integer addition with subtraction | | NO_COVERAGE | project1 | foo.bar | foo.bar.Bar | 10 | replaced int return with 0 for foo/bar/Bar::f | | NO_COVERAGE | project1 | foo.bar | foo.bar.Foo | 10 | Replaced integer addition with subtraction | @@ -52,14 +52,14 @@ Feature: Mutation view shows analysis results # And the mutation results are # | status | project | package | class | line | mutation | # | SURVIVED | project1 | foo.bar | foo.bar.Bar | 9 | Substituted 1 with 0 | -# | SURVIVED | project1 | foo.bar | foo.bar.Bar | 9 | negated conditional | +# | SURVIVED | project1 | foo.bar | foo.bar.Bar | 9 | removed conditional - replaced equality check with false | # | SURVIVED | project1 | foo.bar | foo.bar.Bar | 9 | removed call to java/util/ArrayList::size | # | SURVIVED | project1 | foo.bar | foo.bar.Bar | 9 | removed conditional - replaced equality check with false | # | SURVIVED | project1 | foo.bar | foo.bar.Bar | 9 | removed conditional - replaced equality check with true | # | SURVIVED | project1 | foo.bar | foo.bar.Bar | 12 | Substituted 0 with 1 | # | SURVIVED | project1 | foo.bar | foo.bar.Bar | 12 | replaced return of integer sized value with (x == 0 ? 1 : 0) | # | SURVIVED | project1 | foo.bar | foo.bar.Foo | 9 | Substituted 1 with 0 | -# | SURVIVED | project1 | foo.bar | foo.bar.Foo | 9 | negated conditional | +# | SURVIVED | project1 | foo.bar | foo.bar.Foo | 9 | removed conditional - replaced equality check with false | # | SURVIVED | project1 | foo.bar | foo.bar.Foo | 9 | removed call to java/util/ArrayList::size | # | SURVIVED | project1 | foo.bar | foo.bar.Foo | 9 | removed conditional - replaced equality check with false | # | SURVIVED | project1 | foo.bar | foo.bar.Foo | 9 | removed conditional - replaced equality check with true | diff --git a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/NoTestsFoundDialog.java b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/NoTestsFoundDialog.java index cb85606b..58b53042 100644 --- a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/NoTestsFoundDialog.java +++ b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/NoTestsFoundDialog.java @@ -31,9 +31,7 @@ public NoTestsFoundDialog(SWTWorkbenchBot bot) { public void assertAppears() { SWTBotShell shell = bot.shell("Pitclipse"); shell.activate(); - bot.waitUntil(new DurationElapsed(500)); bot.label("No tests found"); - bot.waitUntil(new DurationElapsed(500)); bot.button("OK").click(); bot.waitUntil(Conditions.shellCloses(shell)); diff --git a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/RunConfigurationSelector.java b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/RunConfigurationSelector.java index 218514ee..7f9d71a4 100644 --- a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/RunConfigurationSelector.java +++ b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/RunConfigurationSelector.java @@ -29,6 +29,7 @@ import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; import org.eclipse.swtbot.swt.finder.waits.Conditions; import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton; +import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu; import org.eclipse.swtbot.swt.finder.widgets.SWTBotRadio; import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable; @@ -144,6 +145,7 @@ private void activateConfigurationTab(String configurationName, String name) { } public void createRunConfiguration(String configurationName, String projectName, String className) { + System.out.println("RunConfigurationSelector.createRunConfiguration()"); getPitConfigurationItem().contextMenu("New Configuration").click(); bot.textWithLabel("Name:").setText(configurationName); PitRunConfiguration config = new Builder().withName(configurationName).withProjects(projectName) diff --git a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/RunMenu.java b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/RunMenu.java index bf7efba8..45f7b5c5 100644 --- a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/RunMenu.java +++ b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/RunMenu.java @@ -70,6 +70,7 @@ public List runConfigurations() { public void createRunConfiguration(String configurationName, String projectName, String className) { try (RunConfigurationSelector selector = openRunMenu().andThen()) { + System.out.println("RunMenu.createRunConfiguration()"); selector.createRunConfiguration(configurationName, projectName, className); } } diff --git a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipseOptionsTest.java b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipseOptionsTest.java index 2e10a76e..f4016f66 100644 --- a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipseOptionsTest.java +++ b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipseOptionsTest.java @@ -69,34 +69,13 @@ public void defaultOptions() { selector.close(); } - @Test - public void useOldDefaultsMutators() throws CoreException { - // set OLD_DEFAULTS mutators - PAGES.getWindowsMenu().setMutatorGroup(Mutators.OLD_DEFAULTS); - try { - runPackageTest(FOO_BAR_PACKAGE, TEST_PROJECT); - coverageReportGenerated(2, 80, 0, 8, 0); - mutationsAre( "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Bar | 7 | negated conditional\n" + - "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Bar | 10 | replaced return of integer sized value with (x == 0 ? 1 : 0)\n" + - "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 7 | negated conditional\n" + - "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 10 | replaced return of integer sized value with (x == 0 ? 1 : 0)\n" + - "NO_COVERAGE | " + TEST_PROJECT + " | foo.bar | foo.bar.Bar | 8 | Replaced integer addition with subtraction\n" + - "NO_COVERAGE | " + TEST_PROJECT + " | foo.bar | foo.bar.Bar | 8 | replaced return of integer sized value with (x == 0 ? 1 : 0)\n" + - "NO_COVERAGE | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 8 | Replaced integer addition with subtraction\n" + - "NO_COVERAGE | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 8 | replaced return of integer sized value with (x == 0 ? 1 : 0)"); - } finally { - // it's crucial to reset it to the default or we break other tests - PAGES.getWindowsMenu().setMutatorGroup(Mutators.DEFAULTS); - } - } - @Test public void useDefaultMutators() throws CoreException { runPackageTest(FOO_BAR_PACKAGE, TEST_PROJECT); coverageReportGenerated(2, 80, 0, 6, 0); mutationsAre( - "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Bar | 7 | negated conditional\n" + - "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 7 | negated conditional\n" + + "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Bar | 7 | removed conditional - replaced equality check with false\n" + + "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 7 | removed conditional - replaced equality check with false\n" + "NO_COVERAGE | " + TEST_PROJECT + " | foo.bar | foo.bar.Bar | 8 | Replaced integer addition with subtraction\n" + "NO_COVERAGE | " + TEST_PROJECT + " | foo.bar | foo.bar.Bar | 8 | replaced int return with 0 for foo/bar/Bar::f\n" + "NO_COVERAGE | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 8 | Replaced integer addition with subtraction\n" + @@ -111,10 +90,10 @@ public void useStrongerMutators() throws CoreException { runPackageTest(FOO_BAR_PACKAGE, TEST_PROJECT); coverageReportGenerated(2, 80, 0, 8, 0); mutationsAre( - "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Bar | 7 | negated conditional\n" + "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Bar | 7 | removed conditional - replaced equality check with false\n" + - "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 7 | negated conditional\n" + + "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Bar | 7 | removed conditional - replaced equality check with true\n" + "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 7 | removed conditional - replaced equality check with false\n" + + "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 7 | removed conditional - replaced equality check with true\n" + "NO_COVERAGE | " + TEST_PROJECT + " | foo.bar | foo.bar.Bar | 8 | Replaced integer addition with subtraction\n" + "NO_COVERAGE | " + TEST_PROJECT + " | foo.bar | foo.bar.Bar | 8 | replaced int return with 0 for foo/bar/Bar::f\n" + "NO_COVERAGE | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 8 | Replaced integer addition with subtraction\n" + @@ -188,7 +167,7 @@ public void launchConfigWithTargetClass() { // NOSONAR // run test and confirm result is as expected PAGES.getRunMenu().runPitWithConfiguration(TEST_CONFIG_NAME); coverageReportGenerated(1, 80, 0, 3, 0); - mutationsAre( "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 7 | negated conditional\n" + + mutationsAre( "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 7 | removed conditional - replaced equality check with false\n" + "NO_COVERAGE | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 8 | Replaced integer addition with subtraction\n" + "NO_COVERAGE | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 8 | replaced int return with 0 for foo/bar/Foo::f"); } diff --git a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipseRunConfigurationMutationTabTest.java b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipseRunConfigurationMutationTabTest.java index 06d373db..877477cc 100644 --- a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipseRunConfigurationMutationTabTest.java +++ b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipseRunConfigurationMutationTabTest.java @@ -80,23 +80,6 @@ public void selectNoMutator() { // NOSONAR "NO_COVERAGE | " + TEST_PROJECT + " | foo.bar | foo.bar.Bar | 7 | negated conditional"); } - @Test - public void useOldDefaultsMutatorsGroup() { // NOSONAR - // set OLD_DEFAULTS mutators - PAGES.getRunMenu().setMutatorGroup(TEST_CONFIG_NAME, Mutators.OLD_DEFAULTS); - // run test and confirm result is as expected - PAGES.getRunMenu().runPitWithConfiguration(TEST_CONFIG_NAME); - coverageReportGenerated(TESTED_CLASSES, COVERAGE, 0, 8, 0); - mutationsAre( "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 7 | negated conditional\n" + - "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 10 | replaced return of integer sized value with (x == 0 ? 1 : 0)\n" + - "NO_COVERAGE | " + TEST_PROJECT + " | foo.bar | foo.bar.Bar | 7 | negated conditional\n" + - "NO_COVERAGE | " + TEST_PROJECT + " | foo.bar | foo.bar.Bar | 8 | Replaced integer addition with subtraction\n" + - "NO_COVERAGE | " + TEST_PROJECT + " | foo.bar | foo.bar.Bar | 8 | replaced return of integer sized value with (x == 0 ? 1 : 0)\n" + - "NO_COVERAGE | " + TEST_PROJECT + " | foo.bar | foo.bar.Bar | 10 | replaced return of integer sized value with (x == 0 ? 1 : 0)\n" + - "NO_COVERAGE | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 8 | Replaced integer addition with subtraction\n" + - "NO_COVERAGE | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 8 | replaced return of integer sized value with (x == 0 ? 1 : 0)"); - } - @Test public void useDefaultMutatorsGroup() { // NOSONAR // set DEFAULTS mutators @@ -104,8 +87,8 @@ public void useDefaultMutatorsGroup() { // NOSONAR // run test and confirm result is as expected PAGES.getRunMenu().runPitWithConfiguration(TEST_CONFIG_NAME); coverageReportGenerated(TESTED_CLASSES, COVERAGE, 0, 6, 0); - mutationsAre( "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 7 | negated conditional\n" + - "NO_COVERAGE | " + TEST_PROJECT + " | foo.bar | foo.bar.Bar | 7 | negated conditional\n" + + mutationsAre( "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 7 | removed conditional - replaced equality check with false\n" + + "NO_COVERAGE | " + TEST_PROJECT + " | foo.bar | foo.bar.Bar | 7 | removed conditional - replaced equality check with false\n" + "NO_COVERAGE | " + TEST_PROJECT + " | foo.bar | foo.bar.Bar | 8 | Replaced integer addition with subtraction\n" + "NO_COVERAGE | " + TEST_PROJECT + " | foo.bar | foo.bar.Bar | 8 | replaced int return with 0 for foo/bar/Bar::f\n" + "NO_COVERAGE | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 8 | Replaced integer addition with subtraction\n" + @@ -119,10 +102,10 @@ public void useStrongerMutatorsGroup() { // NOSONAR // run test and confirm result is as expected PAGES.getRunMenu().runPitWithConfiguration(TEST_CONFIG_NAME); coverageReportGenerated(TESTED_CLASSES, COVERAGE, 0, 8, 0); - mutationsAre( "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 7 | negated conditional\n" + - "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 7 | removed conditional - replaced equality check with false\n" + - "NO_COVERAGE | " + TEST_PROJECT + " | foo.bar | foo.bar.Bar | 7 | negated conditional\n" + + mutationsAre( "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 7 | removed conditional - replaced equality check with false\n" + + "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 7 | removed conditional - replaced equality check with true\n" + "NO_COVERAGE | " + TEST_PROJECT + " | foo.bar | foo.bar.Bar | 7 | removed conditional - replaced equality check with false\n" + + "NO_COVERAGE | " + TEST_PROJECT + " | foo.bar | foo.bar.Bar | 7 | removed conditional - replaced equality check with true\n" + "NO_COVERAGE | " + TEST_PROJECT + " | foo.bar | foo.bar.Bar | 8 | Replaced integer addition with subtraction\n" + "NO_COVERAGE | " + TEST_PROJECT + " | foo.bar | foo.bar.Bar | 8 | replaced int return with 0 for foo/bar/Bar::f\n" + "NO_COVERAGE | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 8 | Replaced integer addition with subtraction\n" + @@ -150,7 +133,7 @@ public void useAllMutatorsGroup() { // NOSONAR PAGES.getRunMenu().setMutatorGroup(TEST_CONFIG_NAME, Mutators.ALL); // run test and confirm result is as expected PAGES.getRunMenu().runPitWithConfiguration(TEST_CONFIG_NAME); - coverageReportGenerated(TESTED_CLASSES, COVERAGE, 1, 84, 1); + coverageReportGenerated(TESTED_CLASSES, COVERAGE, 5, 20, 1); mutationsAre(getAllMutantsResult()); } @@ -162,94 +145,31 @@ public void checkAllMutants() { // NOSONAR PAGES.getRunMenu().checkAllMutators(TEST_CONFIG_NAME); // run test and confirm result is as expected PAGES.getRunMenu().runPitWithConfiguration(TEST_CONFIG_NAME); - coverageReportGenerated(TESTED_CLASSES, COVERAGE, 1, 84, 1); + coverageReportGenerated(TESTED_CLASSES, COVERAGE, 5, 20, 1); mutationsAre(getAllMutantsResult()); } private String getAllMutantsResult(){ - return "SURVIVED | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 7 | Substituted 1 with -1\n" + - "SURVIVED | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 7 | Substituted 1 with -1\n" + - "SURVIVED | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 7 | Substituted 1 with 0\n" + + return "SURVIVED | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 7 | Substituted 1 with 0\n" + - "SURVIVED | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 7 | Substituted 1 with 0\n" + - "SURVIVED | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 7 | Substituted 1 with 2\n" + "SURVIVED | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 7 | negated conditional\n" + - "SURVIVED | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 7 | not equal to equal\n" + - "SURVIVED | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 7 | not equal to greater or equal\n" + - "SURVIVED | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 7 | not equal to greater than\n" + - "SURVIVED | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 7 | not equal to less or equal\n" + - "SURVIVED | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 7 | not equal to less than\n" + "SURVIVED | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 7 | removed call to java/util/ArrayList::size\n" + "SURVIVED | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 7 | removed conditional - replaced equality check with false\n" + "SURVIVED | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 7 | removed conditional - replaced equality check with true\n" + - "SURVIVED | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 10 | Substituted 0 with -1\n" + - "SURVIVED | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 10 | Substituted 0 with -1\n" + - "SURVIVED | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 10 | Substituted 0 with 1\n" + "SURVIVED | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 10 | Substituted 0 with 1\n" + - "SURVIVED | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 10 | Substituted 0 with 1\n" + - "SURVIVED | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 10 | replaced return of integer sized value with (x == 0 ? 1 : 0)\n" + "KILLED | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 6 | removed call to java/util/ArrayList::\n" + "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 6 | removed call to java/util/ArrayList::\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 7 | Substituted 1 with -1\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 7 | Substituted 1 with -1\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 7 | Substituted 1 with 0\n" + "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 7 | Substituted 1 with 0\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 7 | Substituted 1 with 0\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 7 | Substituted 1 with 2\n" + "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 7 | negated conditional\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 7 | not equal to equal\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 7 | not equal to greater or equal\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 7 | not equal to greater than\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 7 | not equal to less or equal\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 7 | not equal to less than\n" + "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 7 | removed call to java/util/ArrayList::size\n" + "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 7 | removed conditional - replaced equality check with false\n" + "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 7 | removed conditional - replaced equality check with true\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 8 | Decremented (--a) integer local variable number 1\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 8 | Decremented (a--) integer local variable number 1\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 8 | Incremented (++a) integer local variable number 1\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 8 | Incremented (a++) integer local variable number 1\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 8 | Negated integer local variable number 1\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 8 | Replaced integer addition with division\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 8 | Replaced integer addition with modulus\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 8 | Replaced integer addition with multiplication\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 8 | Replaced integer addition with subtraction\n" + "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 8 | Replaced integer addition with subtraction\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 8 | Replaced integer operation by second member\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 8 | Replaced integer operation with first member\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 8 | Substituted 1 with -1\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 8 | Substituted 1 with -1\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 8 | Substituted 1 with 0\n" + "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 8 | Substituted 1 with 0\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 8 | Substituted 1 with 0\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 8 | Substituted 1 with 2\n" + "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 8 | replaced int return with 0 for foo/bar/Bar::f\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 8 | replaced return of integer sized value with (x == 0 ? 1 : 0)\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 10 | Substituted 0 with -1\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 10 | Substituted 0 with -1\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 10 | Substituted 0 with 1\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 10 | Substituted 0 with 1\n" + "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 10 | Substituted 0 with 1\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Bar | 10 | replaced return of integer sized value with (x == 0 ? 1 : 0)\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 8 | Decremented (--a) integer local variable number 1\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 8 | Decremented (a--) integer local variable number 1\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 8 | Incremented (++a) integer local variable number 1\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 8 | Incremented (a++) integer local variable number 1\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 8 | Negated integer local variable number 1\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 8 | Replaced integer addition with division\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 8 | Replaced integer addition with modulus\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 8 | Replaced integer addition with multiplication\n" + "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 8 | Replaced integer addition with subtraction\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 8 | Replaced integer addition with subtraction\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 8 | Replaced integer operation by second member\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 8 | Replaced integer operation with first member\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 8 | Substituted 1 with -1\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 8 | Substituted 1 with -1\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 8 | Substituted 1 with 0\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 8 | Substituted 1 with 0\n" + "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 8 | Substituted 1 with 0\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 8 | Substituted 1 with 2\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 8 | replaced int return with 0 for foo/bar/Foo::f\n" + - "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 8 | replaced return of integer sized value with (x == 0 ? 1 : 0)"; + "NO_COVERAGE | " + TEST_PROJECT + " |foo.bar | foo.bar.Foo | 8 | replaced int return with 0 for foo/bar/Foo::f\n"; } } diff --git a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipseUiRunnerTest.java b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipseUiRunnerTest.java index 229f3346..8a2a668d 100644 --- a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipseUiRunnerTest.java +++ b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipseUiRunnerTest.java @@ -218,7 +218,7 @@ public void multipleLaunchConfigurations() throws CoreException { .choose(FOO_TEST_CLASS_MULTIPLE_LAUNCHES + " (All Mutators)")); // not just 2 mutants, but much more since in this launch // we enabled All Mutators - coverageReportGenerated(1, 0, 0, 20, 0); + coverageReportGenerated(1, 0, 0, 3, 0); @SuppressWarnings("serial") class MyException extends RuntimeException { From dcb5029d70dab8f0dea479b99893fce6d27d4d28 Mon Sep 17 00:00:00 2001 From: Emmanuel CHEBBI Date: Tue, 26 Mar 2024 21:46:14 +0100 Subject: [PATCH 05/11] fix classpath --- .../org.pitest.pitest-junit5-plugin/.classpath | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/bundles/org.pitest.pitest-junit5-plugin/.classpath b/bundles/org.pitest.pitest-junit5-plugin/.classpath index 49d2148b..4b7e0d2f 100644 --- a/bundles/org.pitest.pitest-junit5-plugin/.classpath +++ b/bundles/org.pitest.pitest-junit5-plugin/.classpath @@ -1,6 +1,6 @@ - + @@ -13,6 +13,19 @@ + + + + + + + + + + + + + From 4d6cff274d77e73869915b3d9c790bf4afc5f119 Mon Sep 17 00:00:00 2001 From: Emmanuel CHEBBI Date: Tue, 26 Mar 2024 21:46:33 +0100 Subject: [PATCH 06/11] remove research mutators --- .../org/pitest/pitclipse/core/Mutators.java | 42 +++---------------- 1 file changed, 6 insertions(+), 36 deletions(-) diff --git a/bundles/org.pitest.pitclipse.core/src/org/pitest/pitclipse/core/Mutators.java b/bundles/org.pitest.pitclipse.core/src/org/pitest/pitclipse/core/Mutators.java index b87a6278..0158651d 100644 --- a/bundles/org.pitest.pitclipse.core/src/org/pitest/pitclipse/core/Mutators.java +++ b/bundles/org.pitest.pitclipse.core/src/org/pitest/pitclipse/core/Mutators.java @@ -49,48 +49,18 @@ public enum Mutators { NON_VOID_METHOD_CALLS("Non Void Method Call", "Removes method calls to non void methods. Their return value is replaced by the Java Default Value for that specific type"), PRIMITIVE_RETURNS("Primite Returns", "Replaces int, short, long, char, float and double return values with 0", true), REMOVE_CONDITIONALS("Remove Conditionals", "Removes all conditionals statements such that the guarded statements always execute"), - REMOVE_CONDITIONALS_EQ_IF("Remove Equal Conditionals If", "Remove equal conditions and replace with true, execute if part"), - REMOVE_CONDITIONALS_EQ_ELSE("Remove Equal Conditionals Else", "Remove equal conditions and replace with false, execute else part"), - REMOVE_CONDITIONALS_ORD_IF("Remove Order Checks If", "Remove order conditions and replace with true, execute if part"), - REMOVE_CONDITIONALS_ORD_ELSE("Remove Order Checks Else", "Remove order conditions and replace with false, execute else part"), + REMOVE_CONDITIONALS_EQUAL_IF("Remove Equal Conditionals If", "Remove equal conditions and replace with true, execute if part"), + REMOVE_CONDITIONALS_EQUAL_ELSE("Remove Equal Conditionals Else", "Remove equal conditions and replace with false, execute else part"), + REMOVE_CONDITIONALS_ORDER_IF("Remove Order Checks If", "Remove order conditions and replace with true, execute if part"), + REMOVE_CONDITIONALS_ORDER_ELSE("Remove Order Checks Else", "Remove order conditions and replace with false, execute else part"), REMOVE_INCREMENTS("Remove Increments", "Removes local variable increments"), EXPERIMENTAL_ARGUMENT_PROPAGATION("Experimentation Argument Propagation", "Replaces method call with one of its parameters of matching type"), EXPERIMENTAL_BIG_INTEGER("Experimental Big Integer", "Swaps big integer methods"), + EXPERIMENTAL_BIG_DECIMAL("Experimental Big Integer", "Swaps big decimal methods"), EXPERIMENTAL_NAKED_RECEIVER("Experimental Naked Receiver", "Replaces method call with a naked receiver"), EXPERIMENTAL_MEMBER_VARIABLE("Experimental Member Variable", "Removes assignments to member variables. Can even remove assignments to final members. The members will be initialized with their Java Default Value"), EXPERIMENTAL_SWITCH("Experimental Switch", "Finds the first label within a switch statement that differs from the default label. Mutates the switch statement by replacing the default label (wherever it is used) with this label. All the other labels are replaced by the default one"), - ABS("Negation", "Replaces any use of a numeric variable (local variable, field, array cell) with its negation"), - AOR("Arithmetic Operator Replacement", "Like the Math mutator, replaces binary arithmetic operations for either integer or floating-point arithmetic with another operation"), - AOR_1("Arithmetic Operator Replacement 1", "+ -> -, - -> +, * -> /, / -> *, % -> *"), - AOR_2("Arithmetic Operator Replacement 2", "+ -> *, - -> *, * -> %, / -> %, % -> /"), - AOR_3("Arithmetic Operator Replacement 3", "+ -> /, - -> /, * -> +, / -> +, % -> +"), - AOR_4("Arithmetic Operator Replacement 4", "+ -> %, - -> %, * -> -, / -> -, % -> -"), - AOD("Arithmetic Operator Deletion", "Replaces an arithmetic operation with one of its members"), - AOD1("Arithmetic Operator Deletion 1", "int a = b + c; -> int a = b;"), - AOD2("Arithmetic Operator Deletion 2", "int a = b + c; -> int a = c;"), - CRCR("Constant Replacement", "Like the Inline Constant mutator, mutates inline constant"), - CRCR1("Constant Replacement 1", "Replaces the inline constant c with 1"), - CRCR2("Constant Replacement 2", "Replaces the inline constant c with 0"), - CRCR3("Constant Replacement 3", "Replaces the inline constant c with -1"), - CRCR4("Constant Replacement 4", "Replaces the inline constant c with -c"), - CRCR5("Constant Replacement 5", "Replaces the inline constant c with c+1"), - CRCR6("Constant Replacement 6", "Replaces the inline constant c with c-1"), - OBBN("Bitwise Operator", "Mutates bitwise and (&) and or (|)"), - OBBN1("Bitwise Operator 1", "a & b; -> a | b;"), - OBBN2("Bitwise Operator 2", "a & b; -> a;"), - OBBN3("Bitwise Operator 3", "a & b; -> b;"), - ROR("Relational Operator Replacement", "Replaces a relational operator with another one"), - ROR1("Relational Operator Replacement 1", "< -> <=, <= -> <, > -> <, >= -> <, == -> <, != -> <"), - ROR2("Relational Operator Replacement 2", "< -> >, <= -> >, > -> <=, >= -> <=, == -> <=, != -> <="), - ROR3("Relational Operator Replacement 3", "< -> >=, <= -> >=, > -> >=, >= -> >, == -> >, != -> >"), - ROR4("Relational Operator Replacement 4", "< -> ==, <= -> ==, > -> ==, >= -> ==, == -> >=, != -> >="), - ROR5("Relational Operator Replacement 5", "< -> !=, <= -> !=, > -> !=, >= -> !=, == -> !=, != -> =="), - // XXX REMOVE_SWITCH("",""), no data on the page of pitest - UOI1("Unary Operator Insertion 1", "Inserts a unary operator to a variable call from the variable a to a++"), - UOI2("Unary Operator Insertion 2", "Inserts a unary operator to a variable call from the variable a to a--"), - UOI3("Unary Operator Insertion 3", "Inserts a unary operator to a variable call from the variable a to ++a"), - UOI4("Unary Operator Insertion 4", "Inserts a unary operator to a variable call from the variable a to --a"), - UOI("Unary Operator Insertion", "Inserts a unary operator (increment or decrement) to a variable call. Affects local variables, array variables, fields and parameters"); + REMOVE_SWITCH("Remove Switch","Finds the first switch label that differs from the default label, then replaces the default label with this label, and all other labels are replaced with the default one"); /** * Descriptor which is used to display the name of this mutator in a table From ddc63d329f2a587da5e0d24be76348b9b8e26fde Mon Sep 17 00:00:00 2001 From: Emmanuel CHEBBI Date: Tue, 26 Mar 2024 21:49:07 +0100 Subject: [PATCH 07/11] remove OLD_DEFAULTS group (does not exist anymore) --- .../src/org/pitest/pitclipse/core/Mutators.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/bundles/org.pitest.pitclipse.core/src/org/pitest/pitclipse/core/Mutators.java b/bundles/org.pitest.pitclipse.core/src/org/pitest/pitclipse/core/Mutators.java index 0158651d..ce9494a5 100644 --- a/bundles/org.pitest.pitclipse.core/src/org/pitest/pitclipse/core/Mutators.java +++ b/bundles/org.pitest.pitclipse.core/src/org/pitest/pitclipse/core/Mutators.java @@ -28,7 +28,6 @@ */ public enum Mutators { CUSTOM("Custom mutator data", "This is used for the custom settings of mutators and should not be seen by the user."), - OLD_DEFAULTS("Old defaults", "&Old default Mutators"), DEFAULTS("Defaults", "&Default Mutators"), STRONGER("Stronger defaults", "&Stronger Mutators"), ALL("All", "&All Mutators"), @@ -102,7 +101,6 @@ public static List getMainGroup() { mainGroup.add(DEFAULTS); mainGroup.add(STRONGER); mainGroup.add(ALL); - mainGroup.add(OLD_DEFAULTS); return mainGroup; } From f579dd5a48bf58d5b1dd46b6dfe6cfdcbaf13766 Mon Sep 17 00:00:00 2001 From: Emmanuel CHEBBI Date: Tue, 26 Mar 2024 21:53:33 +0100 Subject: [PATCH 08/11] again --- .../ui/tests/PitclipseRunConfigurationMutationTabTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipseRunConfigurationMutationTabTest.java b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipseRunConfigurationMutationTabTest.java index 877477cc..fcd0953c 100644 --- a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipseRunConfigurationMutationTabTest.java +++ b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipseRunConfigurationMutationTabTest.java @@ -60,7 +60,6 @@ public void clearConsole() { @Test public void pressMutatorGroupButtons() { // NOSONAR - PAGES.getRunMenu().setMutatorGroup(TEST_CONFIG_NAME, Mutators.OLD_DEFAULTS); PAGES.getRunMenu().setMutatorGroup(TEST_CONFIG_NAME, Mutators.DEFAULTS); PAGES.getRunMenu().setMutatorGroup(TEST_CONFIG_NAME, Mutators.STRONGER); PAGES.getRunMenu().setMutatorGroup(TEST_CONFIG_NAME, Mutators.ALL); From d6d0ba28052671a351e906120729275ebde10cbe Mon Sep 17 00:00:00 2001 From: Emmanuel CHEBBI Date: Mon, 1 Apr 2024 23:43:27 +0200 Subject: [PATCH 09/11] cleanup --- .../org/pitest/pitclipse/core/Mutators.java | 4 +- .../runner/results/summary/ClassSummary.java | 3 - .../summary/SummaryResultListener.java | 6 - .../META-INF/MANIFEST.MF | 2 +- .../org.pitest.pitest-junit5-plugin/pom.xml | 2 +- .../pitclipse/runner/MutatorApiOfPitTest.java | 125 +++++------------- .../SummaryResultListenerTestData.java | 30 +---- .../pageobjects/DurationElapsed.java | 27 ---- .../PitMutationsViewPageObject.java | 43 +++--- .../pageobjects/RunConfigurationSelector.java | 1 - .../ui/behaviours/pageobjects/RunMenu.java | 1 - .../pageobjects/ViewOpenedCondition.java | 25 ---- .../tests/PitclipseMultipleProjectsTest.java | 3 - .../tests/PitclipsePitMutationsViewTest.java | 4 - 14 files changed, 57 insertions(+), 219 deletions(-) delete mode 100644 tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/DurationElapsed.java delete mode 100644 tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/ViewOpenedCondition.java diff --git a/bundles/org.pitest.pitclipse.core/src/org/pitest/pitclipse/core/Mutators.java b/bundles/org.pitest.pitclipse.core/src/org/pitest/pitclipse/core/Mutators.java index ce9494a5..978639dd 100644 --- a/bundles/org.pitest.pitclipse.core/src/org/pitest/pitclipse/core/Mutators.java +++ b/bundles/org.pitest.pitclipse.core/src/org/pitest/pitclipse/core/Mutators.java @@ -55,11 +55,11 @@ public enum Mutators { REMOVE_INCREMENTS("Remove Increments", "Removes local variable increments"), EXPERIMENTAL_ARGUMENT_PROPAGATION("Experimentation Argument Propagation", "Replaces method call with one of its parameters of matching type"), EXPERIMENTAL_BIG_INTEGER("Experimental Big Integer", "Swaps big integer methods"), - EXPERIMENTAL_BIG_DECIMAL("Experimental Big Integer", "Swaps big decimal methods"), + EXPERIMENTAL_BIG_DECIMAL("Experimental Big Decimal", "Swaps big decimal methods"), EXPERIMENTAL_NAKED_RECEIVER("Experimental Naked Receiver", "Replaces method call with a naked receiver"), EXPERIMENTAL_MEMBER_VARIABLE("Experimental Member Variable", "Removes assignments to member variables. Can even remove assignments to final members. The members will be initialized with their Java Default Value"), EXPERIMENTAL_SWITCH("Experimental Switch", "Finds the first label within a switch statement that differs from the default label. Mutates the switch statement by replacing the default label (wherever it is used) with this label. All the other labels are replaced by the default one"), - REMOVE_SWITCH("Remove Switch","Finds the first switch label that differs from the default label, then replaces the default label with this label, and all other labels are replaced with the default one"); + REMOVE_SWITCH("Remove Switch", "Finds the first switch label that differs from the default label, then replaces the default label with this label, and all other labels are replaced with the default one"); /** * Descriptor which is used to display the name of this mutator in a table diff --git a/bundles/org.pitest.pitclipse.runner/src/org/pitest/pitclipse/runner/results/summary/ClassSummary.java b/bundles/org.pitest.pitclipse.runner/src/org/pitest/pitclipse/runner/results/summary/ClassSummary.java index 957be41b..599ac16f 100644 --- a/bundles/org.pitest.pitclipse.runner/src/org/pitest/pitclipse/runner/results/summary/ClassSummary.java +++ b/bundles/org.pitest.pitclipse.runner/src/org/pitest/pitclipse/runner/results/summary/ClassSummary.java @@ -20,8 +20,6 @@ import java.util.Collection; import java.util.Objects; -import org.pitest.classinfo.ClassInfo; -import org.pitest.coverage.CoverageData; import org.pitest.mutationtest.ClassMutationResults; import org.pitest.mutationtest.MutationResult; @@ -50,7 +48,6 @@ public static ClassSummary from(ClassMutationResults results, int numberOfCodeLi int survivedMutations = (int) mutations.stream() .filter(m -> !m.getStatus().isDetected()) .count(); - CoverageData data; Coverage lineCoverage = Coverage.from(linesCovered, numberOfCodeLines); Coverage mutationCoverage = Coverage.from(totalMutations - survivedMutations, totalMutations); diff --git a/bundles/org.pitest.pitclipse.runner/src/org/pitest/pitclipse/runner/results/summary/SummaryResultListener.java b/bundles/org.pitest.pitclipse.runner/src/org/pitest/pitclipse/runner/results/summary/SummaryResultListener.java index a821f2d6..f6d41e28 100644 --- a/bundles/org.pitest.pitclipse.runner/src/org/pitest/pitclipse/runner/results/summary/SummaryResultListener.java +++ b/bundles/org.pitest.pitclipse.runner/src/org/pitest/pitclipse/runner/results/summary/SummaryResultListener.java @@ -60,18 +60,12 @@ public void runStart() { public void handleMutationResult(ClassMutationResults results) { List classesUnderTest = Collections.singletonList(results.getMutatedClass()); -// long totalNumberOfCoveredLines = classesUnderTest.stream().map(coverage::getCoveredLines).flatMap(Collection::stream).count(); - -// int coveredLines = coverage.getNumberOfCoveredLines(classUnderTest); for (ClassName classUnderTest : classesUnderTest) { int numberOfCoveredLines = coverage.getCoveredLines(classUnderTest).size(); int numberOfLines = coverage.getCodeLinesForClass(classUnderTest).getNumberOfCodeLines(); ClassSummary classSummary = ClassSummary.from(results, numberOfLines, numberOfCoveredLines); result = result.update(classSummary); } -// for (ClassInfo info : coverage.getClassInfo(classesUnderTest)) { -// ClassSummary classSummary = ClassSummary.from(results, info, totalNumberOfCoveredLines); -// } } @Override diff --git a/bundles/org.pitest.pitest-junit5-plugin/META-INF/MANIFEST.MF b/bundles/org.pitest.pitest-junit5-plugin/META-INF/MANIFEST.MF index 450c70ae..43e93b14 100644 --- a/bundles/org.pitest.pitest-junit5-plugin/META-INF/MANIFEST.MF +++ b/bundles/org.pitest.pitest-junit5-plugin/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: pitest-junit5-plugin Bundle-SymbolicName: org.pitest.pitest-junit5-plugin -Bundle-Version: 1.2.1 +Bundle-Version: 1.2.1.qualifier Bundle-ClassPath: lib/pitest-junit5-plugin-sources.jar, lib/pitest-junit5-plugin-javadoc.jar, lib/pitest-junit5-plugin.jar, diff --git a/bundles/org.pitest.pitest-junit5-plugin/pom.xml b/bundles/org.pitest.pitest-junit5-plugin/pom.xml index acd942b7..854a3929 100644 --- a/bundles/org.pitest.pitest-junit5-plugin/pom.xml +++ b/bundles/org.pitest.pitest-junit5-plugin/pom.xml @@ -9,7 +9,7 @@ org.pitest.pitest-junit5-plugin - 1.2.1 + 1.2.1-SNAPSHOT eclipse-plugin Wraps Pitest JUnit 5 Plugin's JAR as an Eclipse plug-in diff --git a/tests/org.pitest.pitclipse.runner.tests/src/org/pitest/pitclipse/runner/MutatorApiOfPitTest.java b/tests/org.pitest.pitclipse.runner.tests/src/org/pitest/pitclipse/runner/MutatorApiOfPitTest.java index d0acbb0e..56ddf905 100644 --- a/tests/org.pitest.pitclipse.runner.tests/src/org/pitest/pitclipse/runner/MutatorApiOfPitTest.java +++ b/tests/org.pitest.pitclipse.runner.tests/src/org/pitest/pitclipse/runner/MutatorApiOfPitTest.java @@ -41,100 +41,35 @@ private String getPitMutatorsAsString() { } private String getExpectedMutatorsAsString() { - return "REMOVE_CONDITIONALS_ORDER_IF\n" + - "REMOVE_CONDITIONALS\n" + - "REMOVE_CONDITIONALS_EQUAL_IF\n" + - "TRUE_RETURNS\n" + - "REMOVE_CONDITIONALS_EQUAL_ELSE\n" + - "VOID_METHOD_CALLS\n" + - "PRIMITIVE_RETURNS\n" + - "FALSE_RETURNS\n" + - "NON_VOID_METHOD_CALLS\n" + - "INVERT_NEGS\n" + - "CONDITIONALS_BOUNDARY\n" + - "REMOVE_CONDITIONALS_ORDER_ELSE\n" + - "DEFAULTS\n" + - "EXPERIMENTAL_SWITCH\n" + - "RETURNS\n" + - "EXPERIMENTAL_MEMBER_VARIABLE\n" + - "NULL_RETURNS\n" + - "EXPERIMENTAL_BIG_DECIMAL\n" + - "MATH\n" + - "EXPERIMENTAL_BIG_INTEGER\n" + - "INCREMENTS\n" + - "EXPERIMENTAL_ARGUMENT_PROPAGATION\n" + - "EXPERIMENTAL_NAKED_RECEIVER\n" + - "CONSTRUCTOR_CALLS\n" + - "REMOVE_SWITCH\n" + - "INLINE_CONSTS\n" + - "STRONGER\n" + - "REMOVE_INCREMENTS\n" + - "NEGATE_CONDITIONALS\n" + - "EMPTY_RETURNS\n"; - - -// return "INVERT_NEGS\n" -// + "RETURN_VALS\n" -// + "INLINE_CONSTS\n" -// + "MATH\n" -// + "VOID_METHOD_CALLS\n" -// + "NEGATE_CONDITIONALS\n" -// + "CONDITIONALS_BOUNDARY\n" -// + "INCREMENTS\n" -// + "REMOVE_INCREMENTS\n" -// + "NON_VOID_METHOD_CALLS\n" -// + "CONSTRUCTOR_CALLS\n" -// + "REMOVE_CONDITIONALS_EQ_IF\n" -// + "REMOVE_CONDITIONALS_EQ_ELSE\n" -// + "REMOVE_CONDITIONALS_ORD_IF\n" -// + "REMOVE_CONDITIONALS_ORD_ELSE\n" -// + "REMOVE_CONDITIONALS\n" -// + "TRUE_RETURNS\n" -// + "FALSE_RETURNS\n" -// + "PRIMITIVE_RETURNS\n" -// + "EMPTY_RETURNS\n" -// + "NULL_RETURNS\n" -// + "RETURNS\n" -// + "EXPERIMENTAL_MEMBER_VARIABLE\n" -// + "EXPERIMENTAL_SWITCH\n" -// + "EXPERIMENTAL_ARGUMENT_PROPAGATION\n" -// + "EXPERIMENTAL_NAKED_RECEIVER\n" -// + "EXPERIMENTAL_BIG_INTEGER\n" -// + "AOR_1\n" -// + "AOR_2\n" -// + "AOR_3\n" -// + "AOR_4\n" -// + "ABS\n" -// + "AOD1\n" -// + "AOD2\n" -// + "CRCR1\n" -// + "CRCR2\n" -// + "CRCR3\n" -// + "CRCR4\n" -// + "CRCR5\n" -// + "CRCR6\n" -// + "OBBN1\n" -// + "OBBN2\n" -// + "OBBN3\n" -// + "ROR1\n" -// + "ROR2\n" -// + "ROR3\n" -// + "ROR4\n" -// + "ROR5\n" -// + "UOI1\n" -// + "UOI2\n" -// + "UOI3\n" -// + "UOI4\n" -// + "REMOVE_SWITCH\n" -// + "OLD_DEFAULTS\n" -// + "STRONGER\n" -// + "ALL\n" -// + "DEFAULTS\n" -// + "AOR\n" -// + "AOD\n" -// + "CRCR\n" -// + "OBBN\n" -// + "ROR\n" -// + "UOI\n"; + return "REMOVE_CONDITIONALS_ORDER_IF\n" + + "REMOVE_CONDITIONALS\n" + + "REMOVE_CONDITIONALS_EQUAL_IF\n" + + "TRUE_RETURNS\n" + + "REMOVE_CONDITIONALS_EQUAL_ELSE\n" + + "VOID_METHOD_CALLS\n" + + "PRIMITIVE_RETURNS\n" + + "FALSE_RETURNS\n" + + "NON_VOID_METHOD_CALLS\n" + + "INVERT_NEGS\n" + + "CONDITIONALS_BOUNDARY\n" + + "REMOVE_CONDITIONALS_ORDER_ELSE\n" + + "DEFAULTS\n" + + "EXPERIMENTAL_SWITCH\n" + + "RETURNS\n" + + "EXPERIMENTAL_MEMBER_VARIABLE\n" + + "NULL_RETURNS\n" + + "EXPERIMENTAL_BIG_DECIMAL\n" + + "MATH\n" + + "EXPERIMENTAL_BIG_INTEGER\n" + + "INCREMENTS\n" + + "EXPERIMENTAL_ARGUMENT_PROPAGATION\n" + + "EXPERIMENTAL_NAKED_RECEIVER\n" + + "CONSTRUCTOR_CALLS\n" + + "REMOVE_SWITCH\n" + + "INLINE_CONSTS\n" + + "STRONGER\n" + + "REMOVE_INCREMENTS\n" + + "NEGATE_CONDITIONALS\n" + + "EMPTY_RETURNS\n"; } } diff --git a/tests/org.pitest.pitclipse.runner.tests/src/org/pitest/pitclipse/runner/results/summary/SummaryResultListenerTestData.java b/tests/org.pitest.pitclipse.runner.tests/src/org/pitest/pitclipse/runner/results/summary/SummaryResultListenerTestData.java index 828da9a4..63c9e9be 100644 --- a/tests/org.pitest.pitclipse.runner.tests/src/org/pitest/pitclipse/runner/results/summary/SummaryResultListenerTestData.java +++ b/tests/org.pitest.pitclipse.runner.tests/src/org/pitest/pitclipse/runner/results/summary/SummaryResultListenerTestData.java @@ -26,6 +26,7 @@ import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.util.stream.IntStream; import java.util.stream.Stream; import org.pitest.classinfo.ClassName; @@ -127,9 +128,9 @@ public ClassLines getCodeLinesForClass(ClassName clazz) { @Override public Set getCoveredLines(ClassName clazz) { - Set lines = new HashSet<>(); int expectedNbOfLinesCovered = classCoverage.getOrDefault(clazz, -1); + Set lines = new HashSet<>(); for (int i = 0; i < expectedNbOfLinesCovered; ++i) { lines.add(new ClassLine(clazz, i)); } @@ -141,24 +142,6 @@ public Collection getTestsForBlockLocation(BlockLocation location) { throw new UnsupportedOperationException("the stub does not implement getTestsForBlockLocation"); } -// @Override -// public Collection getClassInfo(Collection classes) { -// return filter(transform(classes, classInfoLookup()), notNull()); -// } -// -// @Override -// public int getNumberOfCoveredLines(Collection classes) { -// int total = 0; -// for (ClassName className : classes) { -// total += coverageFor(className); -// } -// return total; -// } - -// private int coverageFor(ClassName className) { -// return classCoverage.getOrDefault(className, 0); -// } - @Override public Collection getTestsForClass(ClassName clazz) { return ImmutableList.of(); @@ -174,14 +157,5 @@ public Collection getClassesForFile(String sourceFile, String packag return ImmutableList.of(); } -// private Function classInfoLookup() { -// return new Function() { -// @Override -// public ClassInfo apply(ClassName input) { -// return classInfo.get(input); -// } -// }; -// } - } } diff --git a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/DurationElapsed.java b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/DurationElapsed.java deleted file mode 100644 index 9a2254e6..00000000 --- a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/DurationElapsed.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.pitest.pitclipse.ui.behaviours.pageobjects; - -import org.eclipse.swtbot.swt.finder.waits.DefaultCondition; - -public class DurationElapsed extends DefaultCondition { - - private Long time; - - private long durationInSeconds; - - public DurationElapsed(long duration) { - this.durationInSeconds = duration; - } - - @Override - public boolean test() throws Exception { - if (time == null) { - time = System.currentTimeMillis(); - } - return time + 2000 <= System.currentTimeMillis(); - } - - @Override - public String getFailureMessage() { - return "Failed to wait for " + durationInSeconds + " s"; - } -} \ No newline at end of file diff --git a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/PitMutationsViewPageObject.java b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/PitMutationsViewPageObject.java index 18c4db07..5c042e57 100644 --- a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/PitMutationsViewPageObject.java +++ b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/PitMutationsViewPageObject.java @@ -67,10 +67,6 @@ public SWTBotView getView() { SWTBotView mutationsView = bot.viewByTitle("PIT Mutations"); mutationsView.show(); mutationsView.setFocus(); - // - // Make sure the 'PIT Mutations' view is opened - // - bot.waitUntil(new ViewOpenedCondition(bot, "PIT Mutations")); return mutationsView; } @@ -158,13 +154,13 @@ private MutationsTree(ImmutableList statuses) { this.statuses = statuses; } - public boolean select(PitMutation mutation) { + public void select(PitMutation mutation) { String status = mutation.getStatus().toString(); for (StatusTree statusTree : statuses) { if (status.equals(statusTree.statusName)) { - if (statusTree.select(mutation)) { - return true; - } + statusTree.select(mutation); + return; + } } throw new AssertionFailedError( @@ -189,12 +185,14 @@ private StatusTree(String statusName, ImmutableList projects) { this.projects = projects; } - public boolean select(PitMutation mutation) { + /** + * @return + */ + public void select(PitMutation mutation) { for (ProjectTree projectTree : projects) { if (mutation.getProject().equals(projectTree.projectName)) { - if (projectTree.select(mutation)) { - return true; - } + projectTree.select(mutation); + return; } } throw new AssertionFailedError( @@ -221,12 +219,11 @@ private ProjectTree(String projectName, ImmutableList packages) { this.packages = packages; } - public boolean select(PitMutation mutation) { + public void select(PitMutation mutation) { for (PackageTree packageTree : packages) { if (mutation.getPkg().equals(packageTree.packageName)) { - if (packageTree.select(mutation)) { - return true; - } + packageTree.select(mutation); + return; } } throw new AssertionFailedError( @@ -253,12 +250,11 @@ private PackageTree(String packageName, ImmutableList classes) { this.classes = classes; } - public boolean select(PitMutation mutation) { + public void select(PitMutation mutation) { for (ClassTree classTree : classes) { if (mutation.getClassName().equals(classTree.className)) { - if (classTree.select(mutation)) { - return true; - } + classTree.select(mutation); + return; } } throw new AssertionFailedError( @@ -285,12 +281,15 @@ private ClassTree(String className, ImmutableList projects) { this.mutations = projects; } - public boolean select(PitMutation mutation) { + /** + * @return + */ + public void select(PitMutation mutation) { for (MutationTree mutationTree : mutations) { if (mutation.getLineNumber() == mutationTree.lineNumber && mutation.getMutation().equals(mutationTree.mutation)) { mutationTree.select(); - return true; + return; } } throw new AssertionFailedError( diff --git a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/RunConfigurationSelector.java b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/RunConfigurationSelector.java index 7f9d71a4..250fba8a 100644 --- a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/RunConfigurationSelector.java +++ b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/RunConfigurationSelector.java @@ -145,7 +145,6 @@ private void activateConfigurationTab(String configurationName, String name) { } public void createRunConfiguration(String configurationName, String projectName, String className) { - System.out.println("RunConfigurationSelector.createRunConfiguration()"); getPitConfigurationItem().contextMenu("New Configuration").click(); bot.textWithLabel("Name:").setText(configurationName); PitRunConfiguration config = new Builder().withName(configurationName).withProjects(projectName) diff --git a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/RunMenu.java b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/RunMenu.java index 45f7b5c5..bf7efba8 100644 --- a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/RunMenu.java +++ b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/RunMenu.java @@ -70,7 +70,6 @@ public List runConfigurations() { public void createRunConfiguration(String configurationName, String projectName, String className) { try (RunConfigurationSelector selector = openRunMenu().andThen()) { - System.out.println("RunMenu.createRunConfiguration()"); selector.createRunConfiguration(configurationName, projectName, className); } } diff --git a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/ViewOpenedCondition.java b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/ViewOpenedCondition.java deleted file mode 100644 index 0fb4b5c5..00000000 --- a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/ViewOpenedCondition.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.pitest.pitclipse.ui.behaviours.pageobjects; - -import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; -import org.eclipse.swtbot.swt.finder.waits.DefaultCondition; - -public class ViewOpenedCondition extends DefaultCondition { - - private SWTWorkbenchBot bot; - private String viewTitle; - - public ViewOpenedCondition(SWTWorkbenchBot bot, String viewTitle) { - this.bot = bot; - this.viewTitle = viewTitle; - } - - @Override - public boolean test() throws Exception { - return bot.viewByTitle(viewTitle).isActive(); - } - - @Override - public String getFailureMessage() { - return "The view '" + viewTitle + "' did not open"; - } -} \ No newline at end of file diff --git a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipseMultipleProjectsTest.java b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipseMultipleProjectsTest.java index 6e8c9e4c..b09aa6df 100644 --- a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipseMultipleProjectsTest.java +++ b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipseMultipleProjectsTest.java @@ -21,7 +21,6 @@ import org.junit.runner.RunWith; import org.pitest.pitclipse.core.PitCoreActivator; import org.pitest.pitclipse.core.preferences.PitPreferences; -import org.pitest.pitclipse.ui.behaviours.pageobjects.DurationElapsed; import org.pitest.pitclipse.ui.behaviours.pageobjects.PitPreferenceSelector; /** @@ -67,14 +66,12 @@ public void removeLaunchConfigurations() throws CoreException { public void testExecutionMode() throws CoreException { try { PitPreferenceSelector selector = PAGES.getWindowsMenu().openPreferences().andThen(); - bot.waitUntil(new DurationElapsed(200)); assertEquals(PROJECT_ISOLATION, selector.getPitExecutionMode()); selector.close(); runProjectTest(FOO_BAR_PROJECT); // only the classes in the project is mutated coverageReportGenerated(2, 100, 100, 3, 3); selector = PAGES.getWindowsMenu().openPreferences().andThen(); - bot.waitUntil(new DurationElapsed(200)); selector.setPitExecutionMode(WORKSPACE); selector.close(); runProjectTest(FOO_BAR_PROJECT); diff --git a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipsePitMutationsViewTest.java b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipsePitMutationsViewTest.java index c20ac044..2e24ea19 100644 --- a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipsePitMutationsViewTest.java +++ b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipsePitMutationsViewTest.java @@ -12,7 +12,6 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; -import org.pitest.pitclipse.ui.behaviours.pageobjects.DurationElapsed; import org.pitest.pitclipse.ui.behaviours.pageobjects.PitMutationsViewPageObject; import org.pitest.pitclipse.ui.behaviours.steps.PitMutation; import org.pitest.pitclipse.ui.behaviours.steps.PitclipseSteps; @@ -53,18 +52,15 @@ public void selectMutationOpensTheClassAtTheRightLineNumber() throws CoreExcepti "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 7 | removed conditional - replaced equality check with false"); final PitMutationsViewPageObject pitMutationsView = new PitMutationsViewPageObject(bot); pitMutationsView.getView(); - bot.waitUntil(new DurationElapsed(200)); pitclipseSteps.doubleClickMutationInMutationsView(mutation); bot.waitUntil(waitForEditor(withTitle(FOO_CLASS + ".java"))); - bot.waitUntil(new DurationElapsed(200)); pitclipseSteps.mutationIsOpened(FOO_CLASS + ".java", 7); mutation = fromMutationLine( "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Bar | 7 | removed conditional - replaced equality check with false"); pitclipseSteps.doubleClickMutationInMutationsView(mutation); bot.waitUntil(waitForEditor(withTitle(BAR_CLASS + ".java"))); - bot.waitUntil(new DurationElapsed(200)); pitclipseSteps.mutationIsOpened(BAR_CLASS + ".java", 7); } From 277ff301c1105ada22d90b05a19db7dab59593c9 Mon Sep 17 00:00:00 2001 From: Emmanuel CHEBBI Date: Tue, 2 Apr 2024 00:03:38 +0200 Subject: [PATCH 10/11] cleanup --- .../behaviours/pageobjects/PitMutationsViewPageObject.java | 6 ------ .../ui/behaviours/pageobjects/RunConfigurationSelector.java | 1 - 2 files changed, 7 deletions(-) diff --git a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/PitMutationsViewPageObject.java b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/PitMutationsViewPageObject.java index 5c042e57..79661700 100644 --- a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/PitMutationsViewPageObject.java +++ b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/PitMutationsViewPageObject.java @@ -185,9 +185,6 @@ private StatusTree(String statusName, ImmutableList projects) { this.projects = projects; } - /** - * @return - */ public void select(PitMutation mutation) { for (ProjectTree projectTree : projects) { if (mutation.getProject().equals(projectTree.projectName)) { @@ -281,9 +278,6 @@ private ClassTree(String className, ImmutableList projects) { this.mutations = projects; } - /** - * @return - */ public void select(PitMutation mutation) { for (MutationTree mutationTree : mutations) { if (mutation.getLineNumber() == mutationTree.lineNumber && diff --git a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/RunConfigurationSelector.java b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/RunConfigurationSelector.java index 250fba8a..218514ee 100644 --- a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/RunConfigurationSelector.java +++ b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/RunConfigurationSelector.java @@ -29,7 +29,6 @@ import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot; import org.eclipse.swtbot.swt.finder.waits.Conditions; import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton; -import org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu; import org.eclipse.swtbot.swt.finder.widgets.SWTBotRadio; import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell; import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable; From 57c202a343ba34522207900066483f8a0e1ab423 Mon Sep 17 00:00:00 2001 From: Emmanuel CHEBBI Date: Tue, 2 Apr 2024 19:25:49 +0200 Subject: [PATCH 11/11] cleanup --- .../ui/behaviours/pageobjects/PitMutationsViewPageObject.java | 1 - .../pitclipse/ui/tests/PitclipsePitMutationsViewTest.java | 2 -- 2 files changed, 3 deletions(-) diff --git a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/PitMutationsViewPageObject.java b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/PitMutationsViewPageObject.java index 79661700..bedf35c1 100644 --- a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/PitMutationsViewPageObject.java +++ b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/behaviours/pageobjects/PitMutationsViewPageObject.java @@ -160,7 +160,6 @@ public void select(PitMutation mutation) { if (status.equals(statusTree.statusName)) { statusTree.select(mutation); return; - } } throw new AssertionFailedError( diff --git a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipsePitMutationsViewTest.java b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipsePitMutationsViewTest.java index 2e24ea19..77db2dea 100644 --- a/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipsePitMutationsViewTest.java +++ b/tests/org.pitest.pitclipse.ui.tests/src/org/pitest/pitclipse/ui/tests/PitclipsePitMutationsViewTest.java @@ -50,8 +50,6 @@ public void selectMutationOpensTheClassAtTheRightLineNumber() throws CoreExcepti PitclipseSteps pitclipseSteps = new PitclipseSteps(); PitMutation mutation = fromMutationLine( "SURVIVED | " + TEST_PROJECT + " | foo.bar | foo.bar.Foo | 7 | removed conditional - replaced equality check with false"); - final PitMutationsViewPageObject pitMutationsView = new PitMutationsViewPageObject(bot); - pitMutationsView.getView(); pitclipseSteps.doubleClickMutationInMutationsView(mutation); bot.waitUntil(waitForEditor(withTitle(FOO_CLASS + ".java")));