Tests not found by JUnit5 after compilation #2199
Replies: 2 comments 4 replies
-
That would only be relevant if you write Spock 1.x tests as those were JUnit 4 based and thus need the Vintage engine.
You confuse JUnit 5 Platform with JUnit 5 Jupiter engine. Spock brings its own JUnit 5 Platform engine, so if the Spock tests are not found, searching for differences to Jupiter tests is not really helpful. |
Beta Was this translation helpful? Give feedback.
-
I was able to resolve the issue. The problem was that I compiled the sources with the wrong classloader. ...
val parentCl: ClassLoader = this.getClass.getClassLoader
val gcl = new GroovyClassLoader(parentCl, config)
val unit = new CompilationUnit(config, null, gcl)
... I am wondering why the compilation succeeded thought before. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am currently writing a Groovy plugin for the Mill build tool. So far it is looking good, sources get compiled and JUnit5 tests are runnable (by Mill and by IDE).
Only the compiled Spock classes refuse to be picked up by JUnit. The generated class files are locking good, IntelliJ recognizes the file as a Testable file, but when running JUnit it claims "no tests were found".
I even have the JUnit vintage runner in my classpath, without success. When I compare the decompiled bytecode, I can see that a Junit5 test uses the
@Test
annotation which is missing in the compiled Spock bytcode.Sample:
get compiled to
Whats the current status with the JUnit5 support? According to the docs, it seems the
junit-vintage
is no longer needed andspock-junit4
dependency seems also only necessary when still using JUnit4.Do I need to pass some special compiler arguments?
Beta Was this translation helpful? Give feedback.
All reactions