@@ -35,7 +35,7 @@ junitPlatform {
3535// Create "junit-commons-integration-tests.jar" archive which will be later
3636// mounted as an automatic jar into the integration test module-path.
3737task generateIntegrationTestsJar (type : Jar , dependsOn : compileTestJava) {
38- archiveName ' junit-commons-integration-tests.jar'
38+ archiveName = ' junit-commons-integration-tests.jar'
3939 from compileTestJava. destinationDir
4040 include(" integration/**/*" )
4141}
@@ -49,29 +49,14 @@ task generateDependenciesDirectory(type: Copy) {
4949// Execute console launcher on the module-path.
5050task execScanModulepath (type : Exec , dependsOn : [generateDependenciesDirectory, generateIntegrationTestsJar]) {
5151 executable = ' java'
52- args = [
53- ' --module-path' , files(
54- generateDependenciesDirectory. destinationDir,
55- generateIntegrationTestsJar. archivePath
56- ). asPath,
57- ' --add-modules' , ' ALL-MODULE-PATH,ALL-DEFAULT' ,
58- ' --module' , ' org.junit.platform.console' ,
59- ' --scan-modules'
60- ]
6152 standardOutput = new ByteArrayOutputStream ()
6253 errorOutput = new ByteArrayOutputStream ()
63- }
64-
65- // Execute console launcher on the module-path w/o "java.scripting"
66- task execNoJavaScripting (type : Exec , dependsOn : [generateDependenciesDirectory, generateIntegrationTestsJar]) {
67- executable = ' java'
6854 args = [
69- ' --show-module-resolution' ,
7055 ' --module-path' , files(
7156 generateDependenciesDirectory. destinationDir,
7257 generateIntegrationTestsJar. archivePath
7358 ). asPath,
74- ' --add-modules' , ' junit.commons.integration.tests ' ,
59+ ' --add-modules' , ' ALL-MODULE-PATH,ALL-DEFAULT ' ,
7560 ' --module' , ' org.junit.platform.console' ,
7661 ' --scan-modules'
7762 ]
@@ -109,5 +94,69 @@ task testScanModulepath(dependsOn: execScanModulepath) {
10994 }
11095}
11196
112- test. dependsOn execNoJavaScripting
97+ // Execute console launcher on the module-path w/o "java.scripting"
98+ task execNoJavaScripting (type : Exec , dependsOn : [generateDependenciesDirectory, generateIntegrationTestsJar]) {
99+ ignoreExitValue = true
100+ standardOutput = new ByteArrayOutputStream ()
101+ errorOutput = new ByteArrayOutputStream ()
102+ executable = ' java'
103+ args = [
104+ ' --show-module-resolution' ,
105+ ' --module-path' , files(generateDependenciesDirectory. destinationDir, generateIntegrationTestsJar. archivePath). asPath,
106+ // only "java.base" and "java.logging" are visible
107+ ' --limit-modules' , ' java.base' ,
108+ ' --limit-modules' , ' java.logging' ,
109+ // system modules
110+ // '--add-modules', 'java.scripting',
111+ // '--add-modules', 'jdk.scripting.nashorn',
112+ // '--add-modules', 'jdk.dynalink',
113+ // "JUnit 5" modules
114+ ' --add-modules' , ' org.junit.platform.commons' ,
115+ ' --add-modules' , ' org.junit.platform.engine' ,
116+ ' --add-modules' , ' org.junit.platform.launcher' ,
117+ ' --add-modules' , ' org.junit.jupiter.api' ,
118+ ' --add-modules' , ' org.junit.jupiter.engine' ,
119+ ' --add-modules' , ' org.opentest4j' ,
120+ ' --add-modules' , ' org.apiguardian.api' ,
121+ // local module containing tests
122+ ' --add-modules' , ' junit.commons.integration.tests' ,
123+ // console launcher with arguments
124+ ' --module' , ' org.junit.platform.console' ,
125+ ' --scan-modules'
126+ ]
127+ }
128+
129+ task testNoJavaScripting (dependsOn : execNoJavaScripting) {
130+ doLast {
131+ String text = execNoJavaScripting. errorOutput. toString() + execNoJavaScripting. standardOutput. toString()
132+ // tree node names
133+ assert text. contains(" JUnit Jupiter" )
134+ assert text. contains(" JupiterIntegrationTests" )
135+ assert text. contains(" version()" )
136+ assert text. contains(" moduleIsNamed()" )
137+ assert text. contains(" packageName()" )
138+ assert text. contains(" javaScriptingModuleIsAvailable()" )
139+ assert text. contains(" Failed to evaluate condition" )
140+ assert text. contains(" Class `javax.script.ScriptEngine` is not loadable" )
141+ assert text. contains(" script-based test execution is disabled" )
142+ // summary
143+ assert text. contains(" Test run finished after" )
144+ // container summary
145+ assert text. contains(" 2 containers found" )
146+ assert text. contains(" 0 containers skipped" )
147+ assert text. contains(" 2 containers started" )
148+ assert text. contains(" 0 containers aborted" )
149+ assert text. contains(" 2 containers successful" )
150+ assert text. contains(" 0 containers failed" )
151+ // tests summary
152+ assert text. contains(" 5 tests found" )
153+ assert text. contains(" 0 tests skipped" )
154+ assert text. contains(" 5 tests started" )
155+ assert text. contains(" 0 tests aborted" )
156+ assert text. contains(" 4 tests successful" )
157+ assert text. contains(" 1 tests failed" )
158+ }
159+ }
160+
113161test. dependsOn testScanModulepath
162+ test. dependsOn testNoJavaScripting
0 commit comments