Skip to content

Commit

Permalink
WIP experiment with using test-suites for xVtests
Browse files Browse the repository at this point in the history
  • Loading branch information
leonard84 committed Aug 31, 2022
1 parent 0cb3f1b commit d5ddb7a
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 22 deletions.
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,10 @@ subprojects {
}

tasks.withType(JavaCompile) {
javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(8)
if (it.name == 'compileJava') {
javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(8)
}
}
options.encoding = 'UTF-8'
}
Expand Down Expand Up @@ -183,7 +185,6 @@ subprojects {
from javadoc
}

def javaVersionNoShadow = javaVersion // Test task also has javaVersion
tasks.withType(Test) {
useJUnitPlatform()
def taskName = name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,11 @@ class JavaSpies extends Specification {
e.message.contains("global")
}
@IgnoreIf(
value = { jvm.java17Compatible },
reason = "We can't access private fields in java.util anymore, without an explicit --add-opens"
)
@Issue("https://github.com/spockframework/spock/issues/822")
def "inferred type is ignored for instance mocks"() {
when:
Expand Down Expand Up @@ -301,4 +306,3 @@ class JavaSpies extends Specification {
}
}
}
93 changes: 75 additions & 18 deletions spock-spring/spring.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
plugins {
id 'jvm-test-suite'
}

apply from: script("publishMaven")

ext.displayName = "Spock Framework - Spring Module"
Expand All @@ -6,33 +10,85 @@ description = "Spock's Spring Module makes it possible to use Spring's TestConte
Supports Spring 2.5.x, 3.x, and 4.x."

def springVersion = "4.3.5.RELEASE"
def testSpringVersions = [
"3.2.16.RELEASE": (8..8),
(springVersion): (8..11),
"5.0.2.RELEASE": (8..11),
"6.0.0-M5": (17..17)
].findAll { javaVersion in it.value }

if (springVersion.startsWith("2.")) {
sourceSets.test.groovy.exclude "**/*ContextHierarchyExample.groovy"
// necessary until we have a final version of Spring 6
repositories {
mavenCentral()
maven {
url = "https://repo.spring.io/artifactory/libs-milestone-local/"
content {
includeGroup "org.springframework"
}
}
}

dependencies {
api project(":spock-core")
compileOnly "org.springframework:spring-test:$springVersion"
compileOnly "org.springframework:spring-beans:$springVersion"
compileOnly "org.springframework:spring-context:$springVersion"
}

testing {
suites {
all {
useJUnitJupiter()
dependencies {
implementation "javax.inject:javax.inject:1"
implementation libs.groovySql // for groovy.sql.Sql
implementation libs.junitPlatformTestkit
runtimeOnly libs.h2database
runtimeOnly libs.log4j
runtimeOnly libs.bytebuddy
runtimeOnly libs.cglib
runtimeOnly libs.objenesis
}
}

// not used directly at implementation-time, but needed by groovyc
testImplementation "org.springframework:spring-test:$springVersion"
testImplementation "org.springframework:spring-beans:$springVersion"
testImplementation "org.springframework:spring-context:$springVersion"
testImplementation "org.springframework:spring-core:$springVersion"
testImplementation "org.springframework:spring-jdbc:$springVersion"
testImplementation "org.springframework:spring-tx:$springVersion"
testImplementation "javax.inject:javax.inject:1"
testImplementation libs.groovySql // for groovy.sql.Sql
testImplementation libs.junitPlatformTestkit

testRuntimeOnly libs.h2database
testRuntimeOnly libs.log4j
testRuntimeOnly libs.bytebuddy
testRuntimeOnly libs.cglib
testRuntimeOnly libs.objenesis
test {
targets {
all {
testTask.configure {
onlyIf { false } //skip normal test task
}
}
}
}


testSpringVersions.each { testSpringVersion, __ ->
"spring${testSpringVersion.charAt(0)}"(JvmTestSuite) {

sources {
java {
srcDir 'src/test/java'
}
groovy {
srcDir 'src/test/groovy'
}
resources {
srcDir 'src/test/resources'
}
}

dependencies {
implementation project
implementation "org.springframework:spring-test:$testSpringVersion"
implementation "org.springframework:spring-beans:$testSpringVersion"
implementation "org.springframework:spring-context:$testSpringVersion"
implementation "org.springframework:spring-core:$testSpringVersion"
implementation "org.springframework:spring-jdbc:$testSpringVersion"
implementation "org.springframework:spring-tx:$testSpringVersion"
}
}
}
}
}

task testCglib(type: Test) {
Expand All @@ -41,6 +97,7 @@ task testCglib(type: Test) {
}

check.dependsOn testCglib
check.dependsOn testSpringVersions.collect {k,v -> "spring${k.charAt(0)}" }

jar {
manifest {
Expand Down

0 comments on commit d5ddb7a

Please sign in to comment.