Intelli-J can't run spock tests? (Unable to attach test reporter...)
Asked Answered
C

6

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?

Chromoplast answered 30/3, 2012 at 14:50 Comment(0)
Y
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
Yellowwood answered 30/3, 2012 at 16:13 Comment(0)
T
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.

Tarentarentum answered 31/3, 2012 at 17:0 Comment(0)
I
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.

Involucre answered 12/9, 2013 at 8:3 Comment(0)
S
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?)

Snowdrift answered 1/6, 2015 at 14:10 Comment(0)
L
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.

Latimore answered 26/2, 2016 at 4:3 Comment(0)
S
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.

Supposing answered 27/11, 2017 at 11:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.