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

百般思念 提交于 2019-12-07 04:01:22

问题


I'm trying to use the grails spock plugin with 1.3.7. I can run tests from the terminal via grails test-app :spock, but when I try to run ControllerSpec tests from within Intelli-J, I get unable to attach test reporter to test framework or test framework quit unexpectedly.

Has anyone run grails spock test successfully through Intelli-J?


回答1:


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



回答2:


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.




回答3:


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.




回答4:


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?)




回答5:


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.




回答6:


(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.



来源:https://stackoverflow.com/questions/9945308/intelli-j-cant-run-spock-tests-unable-to-attach-test-reporter

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