Skip to content

Commit 6a911b5

Browse files
authored
Fix ignored spock build tools integ tests (elastic#71769)
Gradle 7.0 forced us to update to spock2 because we need a groovy 3 compatible spock framework version. Spock2 requires junit5 to be executed. We use the junit5 platform but provide the vintage runner to be able to execute junit4 implemented IT tests too
1 parent 53b0141 commit 6a911b5

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

buildSrc/build.gradle

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,24 @@ dependencies {
112112
testImplementation 'com.github.tomakehurst:wiremock-jre8-standalone:2.23.2'
113113
testImplementation 'org.mockito:mockito-core:1.9.5'
114114
testImplementation "org.hamcrest:hamcrest:${props.getProperty('hamcrest')}"
115-
integTestImplementation('org.spockframework:spock-core:2.0-M5-groovy-3.0') {
115+
116+
integTestImplementation(platform("org.junit:junit-bom:${props.getProperty('junit5')}"))
117+
integTestImplementation("org.junit.jupiter:junit-jupiter") {
118+
because 'allows to write and run Jupiter tests'
119+
}
120+
integTestRuntimeOnly("org.junit.vintage:junit-vintage-engine") {
121+
because 'allows JUnit 3 and JUnit 4 tests to run'
122+
}
123+
124+
integTestRuntimeOnly("org.junit.platform:junit-platform-launcher") {
125+
because 'allows tests to run from IDEs that bundle older version of launcher'
126+
}
127+
128+
integTestImplementation platform("org.spockframework:spock-bom:2.0-M5-groovy-3.0")
129+
integTestImplementation("org.spockframework:spock-core") {
116130
exclude module: "groovy"
117131
}
132+
integTestImplementation "org.spockframework:spock-junit4" // you can remove this if your code does not rely on old JUnit 4 rules
118133
integTestImplementation "org.xmlunit:xmlunit-core:2.8.2"
119134
}
120135

@@ -230,6 +245,7 @@ if (project != rootProject) {
230245
systemProperty 'test.version_under_test', version
231246
testClassesDirs = sourceSets.integTest.output.classesDirs
232247
classpath = sourceSets.integTest.runtimeClasspath
248+
useJUnitPlatform()
233249
}
234250
tasks.named("check").configure { dependsOn("integTest") }
235251

buildSrc/src/integTest/groovy/org/elasticsearch/gradle/PublishPluginFuncTest.groovy

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest {
3939
file("build/distributions/hello-world-1.0.pom").exists()
4040
assertXmlEquals(file("build/distributions/hello-world-1.0.pom").text, """
4141
<project xmlns="http://maven.apache.org/POM/4.0.0"
42-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
42+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
4343
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
4444
<modelVersion>4.0.0</modelVersion>
4545
<groupId>org.acme</groupId>
@@ -96,7 +96,7 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest {
9696
file("build/distributions/hello-world-plugin-1.0.pom").exists()
9797
assertXmlEquals(file("build/distributions/hello-world-plugin-1.0.pom").text, """
9898
<project xmlns="http://maven.apache.org/POM/4.0.0"
99-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
99+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
100100
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
101101
<modelVersion>4.0.0</modelVersion>
102102
<groupId>org.acme</groupId>
@@ -141,7 +141,7 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest {
141141
file("build/distributions/hello-world-plugin-1.0.pom").exists()
142142
assertXmlEquals(file("build/distributions/hello-world-plugin-1.0.pom").text, """
143143
<project xmlns="http://maven.apache.org/POM/4.0.0"
144-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
144+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
145145
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
146146
<modelVersion>4.0.0</modelVersion>
147147
<groupId>org.acme</groupId>
@@ -202,7 +202,7 @@ class PublishPluginFuncTest extends AbstractGradleFuncTest {
202202
file("build/distributions/hello-world-1.0.pom").exists()
203203
assertXmlEquals(file("build/distributions/hello-world-1.0.pom").text, """
204204
<project xmlns="http://maven.apache.org/POM/4.0.0"
205-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
205+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
206206
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
207207
<modelVersion>4.0.0</modelVersion>
208208
<groupId>org.acme</groupId>

buildSrc/version.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ bouncycastle=1.64
3434
# test dependencies
3535
randomizedrunner = 2.7.7
3636
junit = 4.12
37+
junit5 = 5.7.1
3738
httpclient = 4.5.10
3839
httpcore = 4.4.12
3940
httpasyncclient = 4.1.4

0 commit comments

Comments
 (0)