@@ -9,24 +9,27 @@ import utest.*
99
1010object HelloGroovyTests extends TestSuite {
1111
12- val junit5Version = sys.props.getOrElse(" TEST_JUNIT5_VERSION" , " 5.13.1" )
12+ val groovy4Version = " 4.0.28"
13+ val junit5Version = sys.props.getOrElse(" TEST_JUNIT5_VERSION" , " 5.13.4" )
1314
1415 object HelloGroovy extends TestRootModule {
1516
1617 lazy val millDiscover = Discover [this .type ]
1718
18- object maven extends JavaModule with MavenModule {
19+ // needed for a special test where only the tests are written in Groovy while appcode remains Java
20+ object `mixed-compile` extends JavaModule with MavenModule {
1921
20- object `maven- test-only ` extends TestGroovyMavenModule with TestModule .Junit5 {
22+ object `test` extends TestGroovyMavenModule with TestModule .Junit5 {
2123
22- override def groovyVersion = " 4.0.28"
23- override def testModuleName : String = " test"
24+ override def moduleDeps : Seq [JavaModule ] = Seq (
25+ HelloGroovy .`mixed-compile`, // TODO improve: TestOnly does not inherit outer deps
26+ )
2427
28+ override def groovyVersion = groovy4Version
2529 override def depManagement = Seq (
26- mvn " org.junit.jupiter:junit-jupiter-engine:5.13.4 "
30+ mvn " org.junit.jupiter:junit-jupiter-engine: $junit5Version "
2731 )
28-
29- override def jupiterVersion = " 5.13.4"
32+ override def jupiterVersion = junit5Version
3033 override def junitPlatformVersion = " 1.13.4"
3134 }
3235
@@ -46,18 +49,16 @@ object HelloGroovyTests extends TestSuite {
4649 override def junitPlatformVersion = " 1.13.4"
4750 }
4851
49- object script extends GroovyTests with TestModule .Junit5 {
50- override def depManagement = Seq (
51- mvn " org.junit.jupiter:junit-jupiter-engine:5.13.4 "
52- )
53-
54- override def jupiterVersion = " 5.13.4"
55- override def junitPlatformVersion = " 1.13.4"
56-
52+ object script extends GroovyModule {
5753 override def groovyVersion = " 4.0.28"
5854 override def mainClass = Some (" HelloScript" )
5955 }
6056
57+ object staticcompile extends GroovyModule {
58+ override def groovyVersion = " 4.0.28"
59+ override def mainClass = Some (" hellostatic.HelloStatic" )
60+ }
61+
6162 object spock extends GroovyTests with TestModule .Junit5 {
6263 override def junitPlatformVersion = " 1.13.4"
6364 def spockVersion : T [String ] = " 2.3-groovy-4.0"
@@ -75,7 +76,7 @@ object HelloGroovyTests extends TestSuite {
7576 }
7677 }
7778 object main extends Test {
78- override def groovyVersion : T [String ] = " 4.0.28 "
79+ override def groovyVersion : T [String ] = groovy4Version
7980 }
8081 }
8182
@@ -89,15 +90,15 @@ object HelloGroovyTests extends TestSuite {
8990 def tests : Tests = Tests {
9091
9192 def m = HelloGroovy .main
92- def mavenTestOnly = HelloGroovy .maven.`maven-test-only `
93+ def mixed = HelloGroovy .`mixed-compile `
9394
9495 test(" running a Groovy script" ) {
9596 testEval().scoped { eval =>
9697 val Right (_) = eval.apply(m.script.run()): @ unchecked
9798 }
9899 }
99100
100- test(" compile Groovy module" ) {
101+ test(" compile & run Groovy module" ) {
101102 testEval().scoped { eval =>
102103 val Right (compiler) = eval.apply(m.groovyCompilerMvnDeps): @ unchecked
103104
@@ -112,70 +113,73 @@ object HelloGroovyTests extends TestSuite {
112113 assert(
113114 os.walk(result.value.classes.path).exists(_.last == " Hello.class" )
114115 )
115- }
116116
117- test(" run Groovy module" ) {
118- testEval().scoped { eval =>
119- val Right (_) = eval.apply(m.run()): @ unchecked
120- }
117+ val Right (_) = eval.apply(m.run()): @ unchecked
121118 }
122119 }
123120
124- test(" compile Groovy JUnit5 test" ) {
121+ test(" compile & run Groovy JUnit5 test" ) {
125122 testEval().scoped { eval =>
126123
127124 val Right (result) = eval.apply(m.test.compile): @ unchecked
128125
129126 assert(
130127 os.walk(result.value.classes.path).exists(_.last == " HelloTest.class" )
131128 )
132- }
133- }
134129
135- test(" run JUnit5 test" ) {
136- testEval().scoped { eval =>
137130 val Right (discovered) = eval.apply(m.test.discoveredTestClasses): @ unchecked
138131 assert(discovered.value == Seq (" hello.tests.HelloTest" ))
139- }
140- testEval().scoped { eval =>
141- val Left (ExecResult .Failure (_)) = eval.apply(m.test.testForked()): @ unchecked
142- }
143- }
144-
145- test(" compile and run test-only Maven JUnit5 test" ) {
146- testEval().scoped { eval =>
147132
148- val Right (resultCompile) = eval.apply(mavenTestOnly.compile): @ unchecked
149- assert(
150- os.walk(resultCompile.value.classes.path).exists(_.last == " HelloMavenTestOnly.class" )
151- )
152-
153- val Right (discovered) = eval.apply(mavenTestOnly.discoveredTestClasses): @ unchecked
154- assert(discovered.value == Seq (" hello.maven.tests.HelloMavenTestOnly" ))
155-
156- val Right (_) = eval.apply(mavenTestOnly.testForked()): @ unchecked
133+ val Right (_) = eval.apply(m.test.testForked()): @ unchecked
157134 }
158135 }
159136
160- test(" compile Spock test" ) {
137+ // test("compiling & running a statically compiled Groovy") {
138+ // testEval().scoped { eval =>
139+ // val Right(_) = eval.apply(m.staticcompile.showMvnDepsTree()): @unchecked
140+ // val Right(result) = eval.apply(m.staticcompile.compile): @unchecked
141+ // assert(
142+ // os.walk(result.value.classes.path).exists(_.last == "HelloStatic.class")
143+ // )
144+ // val Right(_) = eval.apply(m.staticcompile.run()): @unchecked
145+ // }
146+ // }
147+
148+ test(" compile & run test-only Maven JUnit5 test" ) {
161149 testEval().scoped { eval =>
162150
163- val Right (result1 ) = eval.apply(m.spock .compile): @ unchecked
151+ val Right (resultCompile ) = eval.apply(mixed .compile): @ unchecked
164152 assert(
165- os.walk(result1 .value.classes.path).exists(_.last == " SpockTest .class" )
153+ os.walk(resultCompile .value.classes.path).exists(_.last == " Greeter .class" )
166154 )
167- }
168- }
169-
170- test(" run Spock test" ) {
171- testEval().scoped { eval =>
172155
173- val Right (discovered) = eval.apply(m.spock.discoveredTestClasses): @ unchecked
174- assert(discovered.value == Seq (" hello.spock.SpockTest" ))
156+ val Right (_) = eval.apply(mixed.test.compile): @ unchecked
157+ val Right (discovered) = eval.apply(mixed.test.discoveredTestClasses): @ unchecked
158+ assert(discovered.value == Seq (" tests.GreeterTests" ))
175159
176- val Left ( ExecResult . Failure (_)) = eval.apply(m.spock .testForked()): @ unchecked
160+ val Right (_) = eval.apply(mixed.test .testForked()): @ unchecked
177161 }
178162 }
179163
164+ // test("compile Spock test") {
165+ // testEval().scoped { eval =>
166+ //
167+ // val Right(result1) = eval.apply(m.spock.compile): @unchecked
168+ // assert(
169+ // os.walk(result1.value.classes.path).exists(_.last == "SpockTest.class")
170+ // )
171+ // }
172+ // }
173+
174+ // test("run Spock test") {
175+ // testEval().scoped { eval =>
176+ //
177+ // val Right(discovered) = eval.apply(m.spock.discoveredTestClasses): @unchecked
178+ // assert(discovered.value == Seq("hello.spock.SpockTest"))
179+ //
180+ // val Right(_) = eval.apply(m.spock.testForked()): @unchecked
181+ // }
182+ // }
183+
180184 }
181185}
0 commit comments