6

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?

doelleri
  • 19,232
  • 5
  • 61
  • 65
Stefan Kendall
  • 66,414
  • 68
  • 253
  • 406

6 Answers6

8

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
Hans Westerbeek
  • 5,645
  • 3
  • 34
  • 35
0

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.

Geniy
  • 395
  • 3
  • 18
0

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

gogognome
  • 727
  • 8
  • 24
0

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.

vkrams
  • 7,267
  • 17
  • 79
  • 129
0

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

Jay Edwards
  • 950
  • 1
  • 12
  • 21
0

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.

johanneslink
  • 4,877
  • 1
  • 20
  • 37