I use the SBT plugin for IntelliJ and I created a scala project with the following build settings: Build.scala:
lazy val root = Project("root", file(".")) .configs( IntegrationTest ) .settings( Defaults.itSettings : _*)
build.sbt:
<setting some parameters> libraryDependencies += "org.scalatest" % "scala-test_2.10" % "1.0.8" % "test,it"
Now I am ending src/main , src/test and src/it in my project structure. Now I can run compile , test and it:test from both SBT consoles in IntelliJ and in SBT repl. So, everything is fine at this moment.
The only problem I haven't figured out yet is to debug integration tests. I added a scalatest configuration that runs test:compile before running, and this makes me work with unit test debug. I am trying to create a new Debug configuration for integration tests, but cannot figure out how to point it to src/it to find the tests. I tried to debug a specific test by changing the "Test Type" to a class and pointing to a specific test class, but I continue to get the following exception:
Unable to load a Suite class. This could be due to an error in your runpath. Missing class: it.AddPersonSpec java.lang.ClassNotFoundException: it.AddPersonSpec at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at org.scalatest.tools.Runner$$anonfun$22.apply(Runner.scala:1962) at org.scalatest.tools.Runner$$anonfun$22.apply(Runner.scala:1960) at scala.collection.TraversableLike$$anonfun$filter$1.apply(TraversableLike.scala:264) at scala.collection.immutable.List.foreach(List.scala:318) at scala.collection.TraversableLike$class.filter(TraversableLike.scala:263) at scala.collection.AbstractTraversable.filter(Traversable.scala:105) at org.scalatest.tools.Runner$.doRunRunRunDaDoRunRun(Runner.scala:1960) at org.scalatest.tools.Runner$$anonfun$runOptionallyWithPassFailReporter$2.apply(Runner.scala:850) at org.scalatest.tools.Runner$$anonfun$runOptionallyWithPassFailReporter$2.apply(Runner.scala:849) at org.scalatest.tools.Runner$.withClassLoaderAndDispatchReporter(Runner.scala:2221) at org.scalatest.tools.Runner$.runOptionallyWithPassFailReporter(Runner.scala:848) at org.scalatest.tools.Runner$.run(Runner.scala:706) at org.scalatest.tools.Runner.run(Runner.scala) at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.runScalaTest2(ScalaTestRunner.java:144) at org.jetbrains.plugins.scala.testingSupport.scalaTest.ScalaTestRunner.main(ScalaTestRunner.java:35)
When I look in "Project Structure" β "Modules", I see that src/it/scala is in the "Testing Source Folders" category. Not sure where else to look now ...
Update: I had a problem with the sbt configuration. I used the project name "root" in Build.scala and another name in build.sbt. This created two module configurations for IntelliJ. I fixed this and now I cannot reconcile the IntelliJ and sbt settings for my only module.
The effect that I see now is that after running gen-idea from the sbt console and reloading the project, my integration test looks pretty good (while sbt is being updated). I can even get the definition of the AND method defined in Scalatest. However, after a few seconds it will βloseβ the link to scalatest lib (when sbt is updated). When I go to Project Structure β Modules, I donβt see src/it/scala anywhere. If I add it manually to check the source, IntelliJ can solve the scalar again. After running gen-idea it disappears. Rinse and repeat.
Please note that the remote debugger solution proposed by Eugene does not work for me. I run sbt as a server and connect IntelliJ, but when I run it:test , it does not stop at the checkpoint. I think this is because the integration test source is not considered part of the IntelliJ source / test.
If I first add src/it/scala to the project parameters and then try to use a remote debugger before running gen-idea , then SBT will fail using OutOfMemory. Therefore, I am completely at a dead end ...
Any thoughts are much appreciated.