Can't Intelli-J run Spock tests? (Failed to connect test reporter ...)

I am 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 Intelli-J, I get unable to attach test reporter to test framework or test framework quit unexpectedly .

Anyone successfully run an engraving test through Intelli-J?

+6
source share
6 answers

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

  • Right click class
  • Run
  • Select jUnit icon, not grails icon
+8
source

When I come across this error message (... cannot connect the test reporter ...) I usually have a Groovy syntax error somewhere that is not shown as such by IntelliJ. This is a lack of Groovy extreme syntactic flexibility.

0
source

I had the same problem: "Could not attach the test report to the test environment or test environment unexpectedly."

This happened because my jUnit * .groovy class was in the \ com \ myproject \ app folder, but in this class the package was installed as "com.myprojec.app.subpacakge package". As you can see, the meaning of the package and folder was different, and I violated the agreement.

When I checked and fixed the package and class folder, I saw green tests.

0
source

I had a similar problem. The reason was that the class name is different from the file name. I accidentally renamed the class without changing the file name (maybe I forgot to use the IntelliJ rename function?)

0
source

Not sure if the answer is relevant, but it will happen in Intellij. I have the same problem when I returned to the JUnit framework from TestNG .

I 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 selected JUnit and the error will disappear.

0
source

(My experience in Grail 2.4.5)

For those who are confronted with this question and still stuck, I thought I mentioned a receipt that is easy to miss if you don't create your tests through the command line.

It seems that the Spock test files (and their class names) should be marked with the word "Spec".

for example, in FakeControllerSpec.groovy :

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

If at this point intellij convinced itself that your test is a junit test (or some other framework other than Spock), you will need to remove the configuration from Run > editConfigurations before running the test again.

0
source

Source: https://habr.com/ru/post/912054/


All Articles