Intelli-J can't run spock tests? (Unable to attach test reporter…)

不想你离开。 提交于 2019-12-05 07:15:07

Yes I have and I have no problems with it. The only thing to remember is that when you right-click your Spec class, to select the right intelliJ runner. So:

  1. Right click class
  2. Run
  3. Select the jUnit icon, NOT the grails icon

When I run into this error message (... unable to attach test reporter ...) I usually have a Groovy syntax error somewhere which isn't shown as such by IntelliJ. This is the downside of Groovy's extreme syntactical flexibility.

I had the same problem "unable to attach test report to test framework or test framework quit unexpectedly".

It was happened because my jUnit *.groovy class was in folder \com\myproject\app but in this class the package was set like "package com.myprojec.app.subpacakge". As you may see, package and folder value was different and I broke convention.

When I checked and corrected class' package and folder I saw green tests.

I just had a similar problem. The cause turned out to be that the class name differed from the filename. I accidently renamed the class without changing the filename (probably forgot to use the rename function of IntelliJ?)

Not sure the answer is relevant but this will occur in Intellij. I got the same problem when I switched back to JUnit framework from TestNG.

I have solved it very easily by following these steps

1. Select the class file
2. From Top Menu Panel Click Run > Edit Configurations
3. Select the framework which you want.

In my case I have selected the JUnit and the error disappears.

(My experience in grails 2.4.5)

For those who come across this question and are still stuck I thought I'd mention a gotcha that is easy to miss if you don't create your tests via command line.

It appears that Spock test files (and their class names) must be suffixed with the word "Spec".

for Example, in FakeControllerSpec.groovy:

...
@TestFor(FakeController)
class FakeControllerSpec extends Specification {
...
}

If at this point intellij has convinced itself that your test is a junit test (or some framework other than Spock) you'll need to delete the configuration from Run > editConfigurations before you run the test again.

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