Difficulty running grails tests in IntelliJ : Illegal use of nonvirtual function call
Asked Answered
S

2

6

Lately I've been trying to run my spock tests in IntelliJ (which used to work beautifully and had great debugging / specific test re-running on failure features) and in the past few months I've began getting the following error:

| Error Error executing script TestApp: 
 (class: com/company/MyServiceSpec, method: super$2$oldImpl signature:
 (Ljava/lang/Object;)Ljava/lang/Object;) 
 Illegal use of nonvirtual function call (Use --stacktrace to see the full trace)

It's a spock test that runs just fine from the command line, individually (by specifying the class) or in the entire test-app series. Virtually all of the spock and plain old Unit or Integration tests I have on this project give similar failures in IntelliJ.

I've tried twiddling with the run features of the test (having classpath on or off, running an individual method, a whole test class, or the entire test series) with no luck to remedying the situation. I've also done a grails clean and tried re-running them from IntelliJ : that looked as if it worked once and I was able to run the tests for a little while, but then quickly after doing some work the problem now persists.

I know this is a bit of a vague question, but has anyone seen similar failures and found a reliable remedy? I'm on Grails 2.1 and Spock 0.7, same problem in both IntelliJ 12 and 13

Systematism answered 7/1, 2014 at 16:24 Comment(3)
Is it possible that you're running your tests via IntelliJ using a different grails/groovy version that the classes aren't compiled against?Dugald
I'm pretty sure I have them configured properly (under Project Structure it is listed as a provided dependency) but I have mucked that up before, thanks for the suggestion though!Systematism
Rob Fletcher has recommended to me to try running the tests as JUnit, I will be giving that a shot soon!Systematism
D
3

I managed to solve this problem adding the following env variable in my configuration:

   _JAVA_OPTIONS='-Xverify:none'
Daye answered 9/10, 2014 at 15:17 Comment(0)
L
0

First check your configurations and clear out the test that you have ran that are now failing. It is possible you ran the tests as JUnit and now when you are running them again them they are defaulting this behavior.

Note: You can determine if this the issue by running your tests via the command line (e.g. grails test-app unit com.yourPackage.Whatever) if they pass as expected then follow the steps below to clear your saved test configurations in IntelliJ

IntelliJ Steps

  1. Click Run
  2. Click Edit Configurations
  3. In the left pane of the pop up click the arrow to unroll the jUnit tests
  4. Next Click on a test and then click the minus icon ( do this for each to clear them all )
  5. Go to your test you want to run and right click it and make sure you select the grails choice and not jUnit.
Larios answered 18/9, 2017 at 23:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.