-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…ilar to JUnit 4/Spock ordering (#428) Fix #157 - Support @before* and @after* methods; Restore ordering similar to JUnit 4/Spock ordering
- Loading branch information
1 parent
9de8c00
commit aadb56d
Showing
3 changed files
with
93 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
grails-testing-support/src/test/groovy/grails/testing/spock/JUnitAnnotationSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package grails.testing.spock | ||
|
||
import org.junit.jupiter.api.AfterAll | ||
import org.junit.jupiter.api.AfterEach | ||
import org.junit.jupiter.api.BeforeAll | ||
import org.junit.jupiter.api.BeforeEach | ||
import spock.lang.Shared | ||
import spock.lang.Specification | ||
import spock.lang.Stepwise | ||
|
||
@Stepwise | ||
class JUnitAnnotationSpec extends Specification { | ||
@Shared | ||
static List<String> methodOrder = [] | ||
|
||
void setupSpec() { | ||
methodOrder << "setupSpec" | ||
} | ||
|
||
void setup() { | ||
methodOrder << "setup" | ||
} | ||
|
||
void cleanup() { | ||
methodOrder << "cleanup" | ||
} | ||
|
||
void cleanupSpec() { | ||
methodOrder << "cleanupSpec" | ||
} | ||
|
||
@BeforeEach | ||
void beforeEach() { | ||
methodOrder << "beforeEach" | ||
} | ||
|
||
@AfterEach | ||
void afterEach() { | ||
methodOrder << "afterEach" | ||
} | ||
|
||
@BeforeAll | ||
static void beforeAll() { | ||
methodOrder << "beforeAll" | ||
} | ||
|
||
@AfterAll | ||
static void afterAll() { | ||
methodOrder << "afterAll" | ||
assert methodOrder == ["beforeAll", "setupSpec", "beforeEach", "setup", "cleanup", "afterEach", "cleanupSpec", "afterAll"] | ||
} | ||
|
||
void 'junit 5 annotated methods are called in correct order prior to this test'() { | ||
expect: | ||
methodOrder == ["beforeAll", "setupSpec", "beforeEach", "setup"] | ||
} | ||
} |
1 change: 0 additions & 1 deletion
1
grails-testing-support/src/test/groovy/grails/testing/spock/OnceBeforeSpec.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters