Skip to content

Commit

Permalink
Make Spock specs atomic if certain criteria are met
Browse files Browse the repository at this point in the history
  • Loading branch information
Vampire committed Jun 23, 2023
1 parent b66b56d commit c380aaa
Show file tree
Hide file tree
Showing 13 changed files with 773 additions and 30 deletions.
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<pitest.version>1.14.2</pitest.version>
<cucumber.version>5.0.0</cucumber.version>
<spock.version>2.3-groovy-4.0</spock.version>
<junit4.version>4.13.2</junit4.version>
<groovy.version>4.0.11</groovy.version>
</properties>

Expand Down Expand Up @@ -199,6 +200,12 @@
<artifactId>spock-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit4.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
382 changes: 361 additions & 21 deletions src/main/java/org/pitest/junit5/JUnit5TestUnitFinder.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -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 org.junit.jupiter.api.AfterAll
import spock.lang.Specification

class TestSpecWithAfterAll extends Specification {
@AfterAll
static afterAll() {
}

def test() {
expect:
true

where:
i << (1..2)
}
}
Original file line number Diff line number Diff line change
@@ -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 org.junit.AfterClass
import spock.lang.Specification

class TestSpecWithAfterClass extends Specification {
@AfterClass
static afterClass() {
}

def test() {
expect:
true

where:
i << (1..2)
}
}
Original file line number Diff line number Diff line change
@@ -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 org.junit.jupiter.api.BeforeAll
import spock.lang.Specification

class TestSpecWithBeforeAll extends Specification {
@BeforeAll
static beforeAll() {
}

def test() {
expect:
true

where:
i << (1..2)
}
}
Original file line number Diff line number Diff line change
@@ -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 org.junit.BeforeClass
import spock.lang.Specification

class TestSpecWithBeforeClass extends Specification {
@BeforeClass
static beforeClass() {
}

def test() {
expect:
true

where:
i << (1..2)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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.junit.ClassRule
import spock.lang.Specification

class TestSpecWithClassRuleField extends Specification {
@ClassRule
public static classRule

def test() {
expect:
true

where:
i << (1..2)
}
}
Original file line number Diff line number Diff line change
@@ -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 org.junit.ClassRule
import spock.lang.Specification

class TestSpecWithClassRuleMethod extends Specification {
@ClassRule
static afterClass() {
}

def test() {
expect:
true

where:
i << (1..2)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* 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 TestSpecWithSetupSpecWithoutShared extends Specification {
static fail = true

def setupSpec() {
fail = false
}

def aTest() {
expect:
!fail
}

def anotherTest() {
expect:
!fail
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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 TestSpecWithShared extends Specification {
@Shared
foo

def test() {
expect:
true

where:
i << (1..2)
}
}
Original file line number Diff line number Diff line change
@@ -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
import spock.lang.Stepwise

@Stepwise
class TestSpecWithStepwise extends Specification {
def test() {
expect:
true

where:
i << (1..2)
}
}
Original file line number Diff line number Diff line change
@@ -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
import spock.lang.Stepwise

class TestSpecWithStepwiseFeature extends Specification {
@Stepwise
def test() {
expect:
true

where:
i << (1..2)
}
}
Loading

0 comments on commit c380aaa

Please sign in to comment.