3
votes

I am trying to do my first test-automation with Spock. I do not want to use maven. I am using eclipse java EE oxygen 4.7. I have created a groovy project. I have added the Spock jar as an external library in the build path configuration. Spock ist Spock-core-1.1-groovy-2.4. I have also added geb jar the same way. However, I am getting this strange error from the automatic build, which I do not understand and I am seeking for help. So far I haven't found anything helpfull.

General error during semantic analysis: Transform org.spockframework.compiler.SpockTransform@xxxx cannot be run org.codehaus.groovy.GroovyException: Transform org.spockframework.compiler.SpockTransform@xxxx cannot be run at org.codehaus.groovy.transform.ASTTransformationVisitor$3.call(ASTTransformationVisitor.java:416) at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:972) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:633) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:609) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:586) at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.processToPhase(GroovyCompilationUnitDeclaration.java:217) at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.resolve(GroovyCompilationUnitDeclaration.java:613) at org.eclipse.jdt.internal.compiler.Compiler.process(Compiler.java:879) at org.eclipse.jdt.internal.compiler.ProcessTaskManager.run(ProcessTaskManager.java:141) at java.lang.Thread.run(Unknown Source) Caused by: java.lang.NoClassDefFoundError: Unable to load class org.spockframework.runtime.ErrorCollector due to missing dependency org/junit/runners/model/MultipleFailureException at org.codehaus.groovy.vmplugin.v5.Java5.configureClassNode(Java5.java:397) at org.codehaus.groovy.ast.ClassNode.lazyClassInit(ClassNode.java:353) at org.codehaus.groovy.ast.ClassNode.getDeclaredMethods(ClassNode.java:981) at org.codehaus.groovy.ast.ImmutableClassNode.getDeclaredMethods(ImmutableClassNode.java:105) at org.spockframework.compiler.AstNodeCache.(AstNodeCache.java:65) at org.spockframework.compiler.SpockTransform$Impl.(SpockTransform.java: 52) at org.spockframework.compiler.SpockTransform.visit(SpockTransform.java:47) at org.codehaus.groovy.transform.ASTTransformationVisitor$3.call(ASTTransformationVisitor.java:395) ... 9 more

My code is as simple as you can get. This is the code:

//The error is on the "p" letter of package
package hellowworld 

class HelloWorld{

    static main(args) {
    }

}

Please note that this error only happens when I add Spock jar. The closest question was Spock without maven or gradle, but obviously the problems are different.

2

2 Answers

1
votes

I just cut the file from the package directory pasted it out side and then recut pasted in the package back. It worked well and I have no idea why.

1
votes

This is one of those problems which occasionally arise in Eclipse and most people just won't know why!

The thing to do usually is to try several "strategies" and hope that one will work. If not you have to come back to SO and try to enlist the support of an expert.

One tip: in my experience sometimes it is worth trying "Refresh Gradle" and "Build all" more than once. Not only that, but sometimes trying either of these actually then seems to do nothing... but a couple of seconds later the horrid x in the red box then vanishes like morning mist!

  1. Highlight/select the project in Project Explorer --> right-click --> Gradle --> Refresh Gradle Project
  2. Put cursor in a code file open in the editor, press Ctrl-B (Project --> Build all)
  3. Close all files in editor, close Eclipse and start up Eclipse again
  4. Try the above in various combinations
  5. Reboot and then try the above in various combinations

If this fails to cure it you may need to turn to SO.