diff --git a/README.md b/README.md
index 94a7bdb..d0906ac 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# JUnit 5 Plugin
-Adds support to pitest for JUnit 5 and the Jupiter api.
+Adds support to pitest for JUnit 5 platform test engines, e.g. Jupiter, Cucumber, or Spock.
## Versions
diff --git a/pom.xml b/pom.xml
index 6cdba62..1a1cca2 100755
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
org.pitest
pitest-junit5-plugin
${revision}
-
+
pitest-junit5-plugin
http://pitest.org
JUnit 5 plugin for pitest
@@ -25,6 +25,8 @@
2.7.6
1.9.0
5.0.0
+ 2.3-groovy-4.0
+ 4.0.11
@@ -137,6 +139,25 @@
+
+
+
+ org.spockframework
+ spock-bom
+ ${spock.version}
+ pom
+ import
+
+
+ org.apache.groovy
+ groovy-bom
+ ${groovy.version}
+ pom
+ import
+
+
+
+
org.pitest
@@ -173,6 +194,11 @@
${cucumber.version}
test
+
+ org.spockframework
+ spock-core
+ test
+
@@ -184,6 +210,20 @@
true
+
+ org.codehaus.gmavenplus
+ gmavenplus-plugin
+ 2.1.0
+
+
+
+ generateTestStubs
+ compileTests
+ removeTestStubs
+
+
+
+
org.apache.maven.plugins
maven-surefire-plugin
@@ -191,6 +231,7 @@
**/TestClass*
+ **/TestSpec*
diff --git a/src/test/groovy/org/pitest/junit5/repository/TestSpec.groovy b/src/test/groovy/org/pitest/junit5/repository/TestSpec.groovy
new file mode 100644
index 0000000..614ae43
--- /dev/null
+++ b/src/test/groovy/org/pitest/junit5/repository/TestSpec.groovy
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2023 Björn Kautler
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.pitest.junit5.repository
+
+import spock.lang.Specification
+
+class TestSpec extends Specification {
+ def test() {
+ expect:
+ true
+ }
+}
diff --git a/src/test/groovy/org/pitest/junit5/repository/TestSpecWithAbortingFeature.groovy b/src/test/groovy/org/pitest/junit5/repository/TestSpecWithAbortingFeature.groovy
new file mode 100644
index 0000000..b0743ba
--- /dev/null
+++ b/src/test/groovy/org/pitest/junit5/repository/TestSpecWithAbortingFeature.groovy
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2023 Björn Kautler
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.pitest.junit5.repository
+
+import org.opentest4j.TestAbortedException
+import spock.lang.IgnoreIf
+import spock.lang.Specification
+
+class TestSpecWithAbortingFeature extends Specification {
+ @IgnoreIf({ data.ignore })
+ def test() {
+ expect:
+ false
+
+ where:
+ ignore = true
+ }
+
+ def test2() {
+ expect:
+ throw new TestAbortedException()
+ }
+}
diff --git a/src/test/groovy/org/pitest/junit5/repository/TestSpecWithCleanupSpec.groovy b/src/test/groovy/org/pitest/junit5/repository/TestSpecWithCleanupSpec.groovy
new file mode 100644
index 0000000..a6ea9fd
--- /dev/null
+++ b/src/test/groovy/org/pitest/junit5/repository/TestSpecWithCleanupSpec.groovy
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2023 Björn Kautler
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.pitest.junit5.repository
+
+import spock.lang.Specification
+
+class TestSpecWithCleanupSpec extends Specification {
+ def cleanupSpec() {
+ }
+
+ def aTest() {
+ expect:
+ true
+ }
+
+ def anotherTest() {
+ expect:
+ true
+ }
+}
diff --git a/src/test/groovy/org/pitest/junit5/repository/TestSpecWithDataDrivenFeature.groovy b/src/test/groovy/org/pitest/junit5/repository/TestSpecWithDataDrivenFeature.groovy
new file mode 100644
index 0000000..ba98a31
--- /dev/null
+++ b/src/test/groovy/org/pitest/junit5/repository/TestSpecWithDataDrivenFeature.groovy
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2023 Björn Kautler
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.pitest.junit5.repository
+
+import spock.lang.Specification
+
+class TestSpecWithDataDrivenFeature extends Specification {
+ def test() {
+ expect:
+ true
+
+ where:
+ i = 1
+ }
+}
diff --git a/src/test/groovy/org/pitest/junit5/repository/TestSpecWithFailingCleanupSpec.groovy b/src/test/groovy/org/pitest/junit5/repository/TestSpecWithFailingCleanupSpec.groovy
new file mode 100644
index 0000000..81c43d3
--- /dev/null
+++ b/src/test/groovy/org/pitest/junit5/repository/TestSpecWithFailingCleanupSpec.groovy
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2023 Björn Kautler
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.pitest.junit5.repository
+
+import spock.lang.Specification
+
+class TestSpecWithFailingCleanupSpec extends Specification {
+ def cleanupSpec() {
+ assert false
+ }
+
+ def aTest() {
+ expect:
+ true
+ }
+
+ def anotherTest() {
+ expect:
+ true
+ }
+}
diff --git a/src/test/groovy/org/pitest/junit5/repository/TestSpecWithFailingFeature.groovy b/src/test/groovy/org/pitest/junit5/repository/TestSpecWithFailingFeature.groovy
new file mode 100644
index 0000000..c2bb824
--- /dev/null
+++ b/src/test/groovy/org/pitest/junit5/repository/TestSpecWithFailingFeature.groovy
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2023 Björn Kautler
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.pitest.junit5.repository
+
+import spock.lang.Specification
+
+class TestSpecWithFailingFeature extends Specification {
+ def test() {
+ expect:
+ false
+ }
+}
diff --git a/src/test/groovy/org/pitest/junit5/repository/TestSpecWithFailingSetupSpec.groovy b/src/test/groovy/org/pitest/junit5/repository/TestSpecWithFailingSetupSpec.groovy
new file mode 100644
index 0000000..8e80e8d
--- /dev/null
+++ b/src/test/groovy/org/pitest/junit5/repository/TestSpecWithFailingSetupSpec.groovy
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2023 Björn Kautler
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.pitest.junit5.repository
+
+import spock.lang.Specification
+
+class TestSpecWithFailingSetupSpec extends Specification {
+ def setupSpec() {
+ assert false
+ }
+
+ def aTest() {
+ expect:
+ true
+ }
+
+ def anotherTest() {
+ expect:
+ true
+ }
+}
diff --git a/src/test/groovy/org/pitest/junit5/repository/TestSpecWithIncludedFeature.groovy b/src/test/groovy/org/pitest/junit5/repository/TestSpecWithIncludedFeature.groovy
new file mode 100644
index 0000000..fb87520
--- /dev/null
+++ b/src/test/groovy/org/pitest/junit5/repository/TestSpecWithIncludedFeature.groovy
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2023 Björn Kautler
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.pitest.junit5.repository
+
+import spock.lang.Specification
+
+class TestSpecWithIncludedFeature extends Specification {
+ def test() {
+ expect:
+ true
+ }
+
+ def included() {
+ expect:
+ true
+ }
+}
diff --git a/src/test/groovy/org/pitest/junit5/repository/TestSpecWithInheritedFeature.groovy b/src/test/groovy/org/pitest/junit5/repository/TestSpecWithInheritedFeature.groovy
new file mode 100644
index 0000000..81f4f14
--- /dev/null
+++ b/src/test/groovy/org/pitest/junit5/repository/TestSpecWithInheritedFeature.groovy
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2023 Björn Kautler
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.pitest.junit5.repository
+
+class TestSpecWithInheritedFeature extends TestSpec {
+}
diff --git a/src/test/groovy/org/pitest/junit5/repository/TestSpecWithMixedPassAndFail.groovy b/src/test/groovy/org/pitest/junit5/repository/TestSpecWithMixedPassAndFail.groovy
new file mode 100644
index 0000000..89aad11
--- /dev/null
+++ b/src/test/groovy/org/pitest/junit5/repository/TestSpecWithMixedPassAndFail.groovy
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2023 Björn Kautler
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.pitest.junit5.repository
+
+import spock.lang.Specification
+
+class TestSpecWithMixedPassAndFail extends Specification {
+ def passingTest() {
+ expect:
+ true
+ }
+
+ def passingTest2() {
+ expect:
+ true
+ }
+
+ def failingTest() {
+ expect:
+ false
+ }
+
+ def erroringTest() {
+ expect:
+ throw new RuntimeException()
+ }
+}
diff --git a/src/test/groovy/org/pitest/junit5/repository/TestSpecWithMultiplePassingFeatures.groovy b/src/test/groovy/org/pitest/junit5/repository/TestSpecWithMultiplePassingFeatures.groovy
new file mode 100644
index 0000000..63f7a77
--- /dev/null
+++ b/src/test/groovy/org/pitest/junit5/repository/TestSpecWithMultiplePassingFeatures.groovy
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2023 Björn Kautler
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.pitest.junit5.repository
+
+import spock.lang.Specification
+
+class TestSpecWithMultiplePassingFeatures extends Specification {
+ def testOne() {
+ expect:
+ true
+ }
+
+ def testTwo() {
+ expect:
+ true
+ }
+
+ def testThree() {
+ expect:
+ true
+ }
+}
diff --git a/src/test/groovy/org/pitest/junit5/repository/TestSpecWithSetupSpec.groovy b/src/test/groovy/org/pitest/junit5/repository/TestSpecWithSetupSpec.groovy
new file mode 100644
index 0000000..c37fbd7
--- /dev/null
+++ b/src/test/groovy/org/pitest/junit5/repository/TestSpecWithSetupSpec.groovy
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2023 Björn Kautler
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.pitest.junit5.repository
+
+import spock.lang.Shared
+import spock.lang.Specification
+
+class TestSpecWithSetupSpec extends Specification {
+ @Shared
+ def fail = true
+
+ def setupSpec() {
+ fail = false
+ }
+
+ def aTest() {
+ expect:
+ !fail
+ }
+
+ def anotherTest() {
+ expect:
+ !fail
+ }
+}
diff --git a/src/test/groovy/org/pitest/junit5/repository/TestSpecWithSimpleFeature.groovy b/src/test/groovy/org/pitest/junit5/repository/TestSpecWithSimpleFeature.groovy
new file mode 100644
index 0000000..79828c4
--- /dev/null
+++ b/src/test/groovy/org/pitest/junit5/repository/TestSpecWithSimpleFeature.groovy
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2023 Björn Kautler
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.pitest.junit5.repository
+
+import spock.lang.Specification
+
+class TestSpecWithSimpleFeature extends Specification {
+ def test() {
+ expect:
+ true
+ }
+}
diff --git a/src/test/groovy/org/pitest/junit5/repository/TestSpecWithTags.groovy b/src/test/groovy/org/pitest/junit5/repository/TestSpecWithTags.groovy
new file mode 100644
index 0000000..a14398c
--- /dev/null
+++ b/src/test/groovy/org/pitest/junit5/repository/TestSpecWithTags.groovy
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2023 Björn Kautler
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.pitest.junit5.repository
+
+import spock.lang.Specification
+import spock.lang.Tag
+
+class TestSpecWithTags extends Specification {
+ def testWithoutTag() {
+ expect:
+ true
+ }
+
+ @Tag("foo")
+ def testWithTag() {
+ expect:
+ true
+ }
+
+ @Tag("included")
+ def testWithIncludedTag() {
+ expect:
+ true
+ }
+
+ @Tag("excluded")
+ def testWithExcludedTag() {
+ expect:
+ true
+ }
+}
diff --git a/src/test/groovy/org/pitest/junit5/repository/TestSpecWithoutFeatures.groovy b/src/test/groovy/org/pitest/junit5/repository/TestSpecWithoutFeatures.groovy
new file mode 100644
index 0000000..43d3dd8
--- /dev/null
+++ b/src/test/groovy/org/pitest/junit5/repository/TestSpecWithoutFeatures.groovy
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2023 Björn Kautler
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.pitest.junit5.repository
+
+import spock.lang.Specification
+
+class TestSpecWithoutFeatures extends Specification {
+ def test() {
+ }
+}
diff --git a/src/test/java/org/pitest/junit5/JUnit5TestUnitFinderTest.java b/src/test/java/org/pitest/junit5/JUnit5TestUnitFinderTest.java
index 1cd37db..1f17e48 100644
--- a/src/test/java/org/pitest/junit5/JUnit5TestUnitFinderTest.java
+++ b/src/test/java/org/pitest/junit5/JUnit5TestUnitFinderTest.java
@@ -47,6 +47,20 @@
import org.pitest.junit5.repository.TestClassWithTestFactoryAnnotation;
import org.pitest.junit5.repository.TestClassWithTestTemplateAnnotation;
import org.pitest.junit5.repository.TestClassWithoutAnnotations;
+import org.pitest.junit5.repository.TestSpecWithCleanupSpec;
+import org.pitest.junit5.repository.TestSpecWithAbortingFeature;
+import org.pitest.junit5.repository.TestSpecWithDataDrivenFeature;
+import org.pitest.junit5.repository.TestSpecWithFailingCleanupSpec;
+import org.pitest.junit5.repository.TestSpecWithFailingFeature;
+import org.pitest.junit5.repository.TestSpecWithFailingSetupSpec;
+import org.pitest.junit5.repository.TestSpecWithIncludedFeature;
+import org.pitest.junit5.repository.TestSpecWithInheritedFeature;
+import org.pitest.junit5.repository.TestSpecWithMixedPassAndFail;
+import org.pitest.junit5.repository.TestSpecWithMultiplePassingFeatures;
+import org.pitest.junit5.repository.TestSpecWithSetupSpec;
+import org.pitest.junit5.repository.TestSpecWithSimpleFeature;
+import org.pitest.junit5.repository.TestSpecWithTags;
+import org.pitest.junit5.repository.TestSpecWithoutFeatures;
import org.pitest.testapi.Description;
import org.pitest.testapi.ExecutedInDiscovery;
import org.pitest.testapi.NullExecutionListener;
@@ -68,11 +82,21 @@ void findsAndRunsBasicJupiterTests() {
findsAndRunsNTests(1, TestClassWithTestAnnotation.class);
}
+ @Test
+ void findsAndRunsBasicSpockTests() {
+ findsAndRunsNTests(1, TestSpecWithSimpleFeature.class);
+ }
+
@Test
void findsAndRunsBasicJupiterTestsWhenMultiplePresent() {
findsAndRunsNTests(3, TestClassWithMultiplePassingTests.class);
}
+ @Test
+ void findsAndRunsBasicSpockTestsWhenMultiplePresent() {
+ findsAndRunsNTests(3, TestSpecWithMultiplePassingFeatures.class);
+ }
+
@Test
void descriptionsOfTestsRunDuringDiscoveryMatchThoseOfDiscoveredTests() {
JUnit5TestUnitFinder underTest = basicConfig();
@@ -85,6 +109,18 @@ void descriptionsOfTestsRunDuringDiscoveryMatchThoseOfDiscoveredTests() {
assertThat(runInDiscovery).containsExactlyInAnyOrderElementsOf(discovered);
}
+ @Test
+ void descriptionsOfTestsRunDuringDiscoveryMatchThoseOfDiscoveredSpockTests() {
+ JUnit5TestUnitFinder underTest = basicConfig();
+ List runInDiscovery = run(underTest, TestSpecWithMultiplePassingFeatures.class).started;
+ List discovered = underTest.findTestUnits(TestSpecWithMultiplePassingFeatures.class, new NullExecutionListener())
+ .stream()
+ .map(tu -> tu.getDescription())
+ .collect(Collectors.toList());
+
+ assertThat(runInDiscovery).containsExactlyInAnyOrderElementsOf(discovered);
+ }
+
@Test
void discoveredTestsAreMarkedAsExecuted() {
JUnit5TestUnitFinder underTest = basicConfig();
@@ -94,18 +130,38 @@ void discoveredTestsAreMarkedAsExecuted() {
assertThat(discovered).allMatch(tu -> tu instanceof ExecutedInDiscovery);
}
+ @Test
+ void discoveredSpockTestsAreMarkedAsExecuted() {
+ JUnit5TestUnitFinder underTest = basicConfig();
+ List discovered = underTest.findTestUnits(TestSpecWithMultiplePassingFeatures.class,
+ new NullExecutionListener());
+
+ assertThat(discovered).allMatch(tu -> tu instanceof ExecutedInDiscovery);
+ }
+
@Test
void detectsFailingTests() {
findsAndRunsNTests(1, TestClassWithFailingTest.class);
nTestsFails(1, TestClassWithFailingTest.class);
}
+ @Test
+ void detectsFailingSpockTests() {
+ findsAndRunsNTests(1, TestSpecWithFailingFeature.class);
+ nTestsFails(1, TestSpecWithFailingFeature.class);
+ }
+
@Test
void detectsErroringTestsWhenPassingTestsPresent() {
nTestsPass(2, TestClassWithMixedPassAndFail.class);
nTestsFails(2, TestClassWithMixedPassAndFail.class);
}
+ @Test
+ void detectsErroringSpockTestsWhenPassingTestsPresent() {
+ nTestsPass(2, TestSpecWithMixedPassAndFail.class);
+ nTestsFails(2, TestSpecWithMixedPassAndFail.class);
+ }
@Test
void findsAndRunsParameterizedTests() {
@@ -133,6 +189,11 @@ void findsAndRunsTestsFromTestTemplateAnnotation() {
findsAndRunsNTests(1, TestClassWithTestTemplateAnnotation.class);
}
+ @Test
+ void findsAndRunsTestsFromDataDrivenSpockFeature() {
+ findsAndRunsNTests(2, TestSpecWithDataDrivenFeature.class);
+ }
+
@Test
void findsAndRunsTestsFromClassWithNestedAnnotationAndNestedTestAnnotation() {
findsAndRunsNTests(1, TestClassWithNestedAnnotationAndNestedTestAnnotation.class);
@@ -164,6 +225,11 @@ void findsNoTestsWhenNoTestAnnotations() {
findsAndRunsNTests(0, TestClassWithoutAnnotations.class);
}
+ @Test
+ void findsNoSpockTestsWhenNoFeaturesDefined() {
+ findsAndRunsNTests(0, TestSpecWithoutFeatures.class);
+ }
+
@Test
void findsNoTestsInOuterClassWhenNestedAnnotationPresent() {
findsAndRunsNTests(0, TestClassWithNestedClassWithNestedAnnotationAndNestedTestAnnotation.class);
@@ -179,21 +245,40 @@ void findsInheritedTests() {
findsAndRunsNTests(1, TestClassWithInheritedTestMethod.class);
}
+ @Test
+ void findsInheritedSpockTests() {
+ findsAndRunsNTests(1, TestSpecWithInheritedFeature.class);
+ }
+
@Test
void findsTestsIncludedByMethodName() {
findsAndRunsNTests(1, new JUnit5TestUnitFinder(new TestGroupConfig(), singletonList("included")), TestClassWithIncludedTestMethod.class);
}
+ @Test
+ void findsSpockTestsIncludedByMethodName() {
+ findsAndRunsNTests(1, new JUnit5TestUnitFinder(new TestGroupConfig(), singletonList("included")), TestSpecWithIncludedFeature.class);
+ }
+
@Test
void excludesTestsByTag() {
findsAndRunsNTests(3, new JUnit5TestUnitFinder(new TestGroupConfig().withExcludedGroups("excluded"), emptyList()), TestClassWithTags.class);
}
+ void excludesSpockTestsByTag() {
+ findsAndRunsNTests(3, new JUnit5TestUnitFinder(new TestGroupConfig().withExcludedGroups("excluded"), emptyList()), TestSpecWithTags.class);
+ }
+
@Test
void includesTestsByTag() {
findsAndRunsNTests(1, new JUnit5TestUnitFinder(new TestGroupConfig().withIncludedGroups("included"), emptyList()), TestClassWithTags.class);
}
+ @Test
+ void includesSpockTestsByTag() {
+ findsAndRunsNTests(1, new JUnit5TestUnitFinder(new TestGroupConfig().withIncludedGroups("included"), emptyList()), TestSpecWithTags.class);
+ }
+
@Test
void findsNoTestsInAbstractTestClass() {
findsAndRunsNTests(0, AbstractTestClass.class);
@@ -209,26 +294,51 @@ void findsAndRunsAbortedTest() {
findsAndRunsNTests(1, TestClassWithAbortingTest.class);
}
+ @Test
+ void findsAndRunsAbortedSpockTest() {
+ findsAndRunsNTests(3, TestSpecWithAbortingFeature.class);
+ }
+
@Test
void findsAndRunsTestsWithAfterAll() {
findsAndRunsNTests(2, TestClassWithAfterAll.class);
}
+ @Test
+ void findsAndRunsTestsWithCleanupSpec() {
+ findsAndRunsNTests(2, TestSpecWithCleanupSpec.class);
+ }
+
@Test
void findsAndRunsTestsWithBeforeAll() {
findsAndRunsNTests(2, TestClassWithBeforeAll.class);
}
+ @Test
+ void findsAndRunsTestsWithSetupSpec() {
+ findsAndRunsNTests(2, TestSpecWithSetupSpec.class);
+ }
+
@Test
void findsAndRunsTestsWithFailingAfterAll() {
findsAndRunsNTests(2, TestClassWithFailingAfterAll.class);
}
+ @Test
+ void findsAndRunsTestsWithFailingCleanupSpec() {
+ findsAndRunsNTests(2, TestSpecWithFailingCleanupSpec.class);
+ }
+
@Test
void findsNoTestsWithFailingBeforeAll() {
findsAndRunsNTests(0, TestClassWithFailingBeforeAll.class);
}
+ @Test
+ void findsNoTestsWithFailingSetupSpec() {
+ findsAndRunsNTests(0, TestSpecWithFailingSetupSpec.class);
+ }
+
@Test
void findsNoTestsWithNestedTestClassWithoutAnnotations() {
findsAndRunsNTests(0, TestClassWithNestedClassWithoutAnnotations.class);