Skip to content

Commit fba416d

Browse files
committed
Inject the JUnit version to tests via system property
The sample now expects the JUnit version to be injected via a system property. This will allow consistent upgrades of libraries without having to update the samples themselves.
1 parent f79c4a3 commit fba416d

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

native-gradle-plugin/buildSrc/src/main/groovy/org.graalvm.build.functional-testing.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ configurations.functionalTestImplementation.extendsFrom(configurations.testImple
7979
inputs.files(files("src/samples"))
8080
inputs.files(configurations.functionalTestCommonRepository)
8181
systemProperty('common.repo.url', configurations.functionalTestCommonRepository.incoming.files.files[0])
82+
systemProperty('versions.junit', project.properties.junit_jupiter_version)
8283
environment('GRAALVM_HOME', javaToolchains.launcherFor {
8384
languageVersion.set(JavaLanguageVersion.of(11))
8485
vendor.set(JvmVendorSpec.matching("GraalVM Community"))

native-gradle-plugin/src/functionalTest/groovy/org/graalvm/buildtools/gradle/JavaApplicationWithTestsFunctionalTest.groovy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@
4141
package org.graalvm.buildtools.gradle
4242

4343
import org.graalvm.buildtools.gradle.fixtures.AbstractFunctionalTest
44+
import spock.lang.Unroll
4445

4546
class JavaApplicationWithTestsFunctionalTest extends AbstractFunctionalTest {
47+
@Unroll("can execute tests in a native image on Gradle #version with JUnit Platform #junitVersion")
4648
def "can execute tests in a native image"() {
4749
gradleVersion = version
4850
def nativeTestsApp = file("build/native/native-tests")
@@ -83,5 +85,6 @@ class JavaApplicationWithTestsFunctionalTest extends AbstractFunctionalTest {
8385

8486
where:
8587
version << TESTED_GRADLE_VERSIONS
88+
junitVersion = System.getProperty('versions.junit')
8689
}
8790
}

native-gradle-plugin/src/samples/java-application-with-tests/build.gradle

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,16 @@ application {
1111
mainClass.set('org.graalvm.demo.Application')
1212
}
1313

14+
def junitVersion = providers.systemProperty('versions.junit')
15+
.forUseAtConfigurationTime()
16+
.orElse('5.7.2') // so that the sample runs if someone checks it out without the testing infra
17+
.get()
18+
1419
dependencies {
15-
testImplementation(platform('org.junit:junit-bom:5.7.2'))
20+
testImplementation(platform("org.junit:junit-bom:${junitVersion}"))
1621
testImplementation('org.junit.jupiter:junit-jupiter')
1722
}
1823

1924
test {
2025
useJUnitPlatform()
2126
}
22-

0 commit comments

Comments
 (0)