Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle, IntelliJ and ScalaTest plugin: suddenly broken

This is very puzzling. I have a multi module polyglot JVM project built using Gradle. I have a few java modules and a couple scala modules. The scala module uses ScalaTest as the test framework. I set up the Gradle to use the scalatest plugin to run tests. I had the whole thing running like a charm in IntelliJ for about a month (using the Gradle idea plugin). Now all of a sudden the ScalaTest specs won't run from the IDE anymore with the following error:

Unable to load a Suite class. This could be due to an error in your runpath. Missing class: com.mypackage.MySpec

Does anybody know what's going on? I am not sure what has changed since the first time I set up my build file that might have messed this up. This is really frustrating. Ideas?

EDIT: Apparently my junit tests won't run either. Looks like the compiled classes aren't on the classpath used by Intellij. This is what I get if I try to run a JUnit test case:

Class not found: "com.mypackage.MyUnitTests"
like image 445
Giovanni Botta Avatar asked Jan 13 '14 23:01

Giovanni Botta


2 Answers

Chances are that since this is a multi-language project IntelliJ can't tell which are the source folders. Check under Project Structure > Modules (each of your module) and ensure Sources and Tests dirs are correctly marked.

like image 81
dimitrisli Avatar answered Oct 21 '22 19:10

dimitrisli


Figured it out. I was messing with my IntelliJ configuration files after this blog post and I accidentally messed up my project output folder (in the updateBuildOutputFolderForGradle function) so that IntelliJ wasn't able to find the classes at runtime.

like image 24
Giovanni Botta Avatar answered Oct 21 '22 20:10

Giovanni Botta