Spock test together with junit 5 test does not run

两盒软妹~` 提交于 2019-12-02 09:51:25

This is what I see in IDEA:

So maybe you want to get more specific and share an MCVE, i.e. a full Maven project with a few dummy classes and tests (both Spock and JUnit), on GitHub for me to inspect.


Update: After inspecting and fixing your MCVE in my fork I can explain what was wrong:

  1. Your MCVE folder for Spock tests was 'src/test/spock'. I renamed it to 'src/test/groovy' in order to enable GMavenPlus to find it. This fixes Groovy test compilation.

  2. In your POM you manually overrode the dependency versions for three JUnit Jupiter artifacts, but mvn help:effective-pom showed me that some others still were on 5.3.2 while your version was 5.5.1. I am not sure why you think you need to update them other than wishing to be bleeding edge and always use the latest version. Anyway, the effective POM also shows that there are these JUnit-related version properties in your parent POM:

<junit-jupiter.version>5.3.2</junit-jupiter.version>
<junit.version>4.12</junit.version>

More exactly, those properties are from your parent POM's own parent POM. The rest was easy: Just override the relevant property in your own POM:

<properties>
  <junit-jupiter.version>5.5.1</junit-jupiter.version>
</properties>

Now run mvn clean test and see that both JUnit and Spock tests are being compiled and run. Running the tests from IntelliJ IDEA like in my screenshot above also works now.

I also sent you a pull request via GitHub.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!