Scala / SBT / JUnit / Cucumber classpath problems?
I've recently downloaded Intellij 14.1.4 and installed the scala and cucumber for scala plugins.
I was following this tutorial (though using more recent dependency versions, as attached). i.e., create scala/sbt project, add dependencies (as attached) create test class (attached) to run cucumber, add HelloWorld.feature (attached), run test class... fails.
When attempting to run the JUnit test class from Intellij, it fails because for some reason the ".idea" folder is on the classpath at runtime, even though it's not marked as a source/resource directory.
Why might this be happening? Running the sbt test target (from the terminal) works fine, but obviously running a JUnit class works differently from within Intellij.
The stacktrace is as follows:
java.lang.IllegalArgumentException: Not a file or directory: ~/IdeaProjects/scala-cuke-test/.idea/modules/src/test/resources/features
at cucumber.runtime.io.FileResourceIterator$FileIterator.<init>(FileResourceIterator.java:54)
at cucumber.runtime.io.FileResourceIterator.<init>(FileResourceIterator.java:20)
at cucumber.runtime.io.FileResourceIterable.iterator(FileResourceIterable.java:19)
at cucumber.runtime.model.CucumberFeature.loadFromFeaturePath(CucumberFeature.java:103)
at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:54)
at cucumber.runtime.model.CucumberFeature.load(CucumberFeature.java:34)
at cucumber.runtime.RuntimeOptions.cucumberFeatures(RuntimeOptions.java:235)
at cucumber.api.junit.Cucumber.<init>(Cucumber.java:60)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at org.junit.internal.builders.AnnotatedBuilder.buildRunner(AnnotatedBuilder.java:29)
at org.junit.internal.builders.AnnotatedBuilder.runnerForClass(AnnotatedBuilder.java:21)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:26)
at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:59)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:26)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:41)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:212)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:68)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:140)
Attachment(s):
build.sbt.zip
RunCucumber.scala.zip
Please sign in to leave a comment.
upload of HelloWorld.feature file seems to fail. Well it doesn't matter too much, something simple like:
@wip
Hi,
You need to change working directory in your JUnit run configurations. It seems there is a bug and $MODULE_DIR$ is replaced with wrong directory. You can use $PROJECT_DIR$ or explicit path as a workaround.
Thanks Nikolay. That worked. Is the MODULE_DIR bug known/reported?
Yes, it is known. But it seems that it is not of a high priority:
https://youtrack.jetbrains.com/issue/IDEA-121819