Skip to content

Commit b08c063

Browse files
authored
Merge pull request #84 from Vampire/spock-tests
Add Spock tests
2 parents 756ba0f + e86aff5 commit b08c063

18 files changed

+637
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# JUnit 5 Plugin
22

3-
Adds support to pitest for JUnit 5 and the Jupiter api.
3+
Adds support to pitest for JUnit 5 platform test engines, e.g. Jupiter, Cucumber, or Spock.
44

55
## Versions
66

pom.xml

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<groupId>org.pitest</groupId>
66
<artifactId>pitest-junit5-plugin</artifactId>
77
<version>${revision}</version>
8-
8+
99
<name>pitest-junit5-plugin</name>
1010
<url>http://pitest.org</url>
1111
<description>JUnit 5 plugin for pitest</description>
@@ -25,6 +25,8 @@
2525
<mockito.version>2.7.6</mockito.version>
2626
<pitest.version>1.9.0</pitest.version>
2727
<cucumber.version>5.0.0</cucumber.version>
28+
<spock.version>2.3-groovy-4.0</spock.version>
29+
<groovy.version>4.0.11</groovy.version>
2830
</properties>
2931

3032
<scm>
@@ -137,6 +139,25 @@
137139
</profile>
138140
</profiles>
139141

142+
<dependencyManagement>
143+
<dependencies>
144+
<dependency>
145+
<groupId>org.spockframework</groupId>
146+
<artifactId>spock-bom</artifactId>
147+
<version>${spock.version}</version>
148+
<type>pom</type>
149+
<scope>import</scope>
150+
</dependency>
151+
<dependency>
152+
<groupId>org.apache.groovy</groupId>
153+
<artifactId>groovy-bom</artifactId>
154+
<version>${groovy.version}</version>
155+
<type>pom</type>
156+
<scope>import</scope>
157+
</dependency>
158+
</dependencies>
159+
</dependencyManagement>
160+
140161
<dependencies>
141162
<dependency>
142163
<groupId>org.pitest</groupId>
@@ -173,6 +194,11 @@
173194
<version>${cucumber.version}</version>
174195
<scope>test</scope>
175196
</dependency>
197+
<dependency>
198+
<groupId>org.spockframework</groupId>
199+
<artifactId>spock-core</artifactId>
200+
<scope>test</scope>
201+
</dependency>
176202
</dependencies>
177203

178204
<build>
@@ -184,13 +210,28 @@
184210
<showWarnings>true</showWarnings>
185211
</configuration>
186212
</plugin>
213+
<plugin>
214+
<groupId>org.codehaus.gmavenplus</groupId>
215+
<artifactId>gmavenplus-plugin</artifactId>
216+
<version>2.1.0</version>
217+
<executions>
218+
<execution>
219+
<goals>
220+
<goal>generateTestStubs</goal>
221+
<goal>compileTests</goal>
222+
<goal>removeTestStubs</goal>
223+
</goals>
224+
</execution>
225+
</executions>
226+
</plugin>
187227
<plugin>
188228
<groupId>org.apache.maven.plugins</groupId>
189229
<artifactId>maven-surefire-plugin</artifactId>
190230
<version>2.22.2</version>
191231
<configuration>
192232
<excludes>
193233
<exclude>**/TestClass*</exclude>
234+
<exclude>**/TestSpec*</exclude>
194235
</excludes>
195236
</configuration>
196237
</plugin>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright 2023 Björn Kautler
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.pitest.junit5.repository
18+
19+
import spock.lang.Specification
20+
21+
class TestSpec extends Specification {
22+
def test() {
23+
expect:
24+
true
25+
}
26+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2023 Björn Kautler
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.pitest.junit5.repository
18+
19+
import org.opentest4j.TestAbortedException
20+
import spock.lang.IgnoreIf
21+
import spock.lang.Specification
22+
23+
class TestSpecWithAbortingFeature extends Specification {
24+
@IgnoreIf({ data.ignore })
25+
def test() {
26+
expect:
27+
false
28+
29+
where:
30+
ignore = true
31+
}
32+
33+
def test2() {
34+
expect:
35+
throw new TestAbortedException()
36+
}
37+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright 2023 Björn Kautler
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.pitest.junit5.repository
18+
19+
import spock.lang.Specification
20+
21+
class TestSpecWithCleanupSpec extends Specification {
22+
def cleanupSpec() {
23+
}
24+
25+
def aTest() {
26+
expect:
27+
true
28+
}
29+
30+
def anotherTest() {
31+
expect:
32+
true
33+
}
34+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2023 Björn Kautler
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.pitest.junit5.repository
18+
19+
import spock.lang.Specification
20+
21+
class TestSpecWithDataDrivenFeature extends Specification {
22+
def test() {
23+
expect:
24+
true
25+
26+
where:
27+
i = 1
28+
}
29+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2023 Björn Kautler
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.pitest.junit5.repository
18+
19+
import spock.lang.Specification
20+
21+
class TestSpecWithFailingCleanupSpec extends Specification {
22+
def cleanupSpec() {
23+
assert false
24+
}
25+
26+
def aTest() {
27+
expect:
28+
true
29+
}
30+
31+
def anotherTest() {
32+
expect:
33+
true
34+
}
35+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright 2023 Björn Kautler
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.pitest.junit5.repository
18+
19+
import spock.lang.Specification
20+
21+
class TestSpecWithFailingFeature extends Specification {
22+
def test() {
23+
expect:
24+
false
25+
}
26+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2023 Björn Kautler
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.pitest.junit5.repository
18+
19+
import spock.lang.Specification
20+
21+
class TestSpecWithFailingSetupSpec extends Specification {
22+
def setupSpec() {
23+
assert false
24+
}
25+
26+
def aTest() {
27+
expect:
28+
true
29+
}
30+
31+
def anotherTest() {
32+
expect:
33+
true
34+
}
35+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright 2023 Björn Kautler
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.pitest.junit5.repository
18+
19+
import spock.lang.Specification
20+
21+
class TestSpecWithIncludedFeature extends Specification {
22+
def test() {
23+
expect:
24+
true
25+
}
26+
27+
def included() {
28+
expect:
29+
true
30+
}
31+
}

0 commit comments

Comments
 (0)