Running different test configurations for ScalaTest in IntelliJ 16.2

SBT allows specifying different *configurations* for running your tests: Test, IntegrationTest, etc.  

By default, the Test configuration looks for sources & resource files in src/test/scala & src/test/resources & the IntegrationTest in src/it/scala & src/it/resources, respectively.  When running SBT tasks such as `test`, they will run in the configuration's scope only: `it:test` will only run the integration tests & so on.

IntelliJ's default configuration for ScalaTest seems to be to run all tests in one package, which breaks the above contract if the package starts the same for all the tests (for us, it does).  That means, it also is not possible to set up IntegrationTest-specific run / debug configurations as they will be set up by package, not by folder structure as above.

Is it possible to set up IntelliJ, without changing the package structure, to only run ScalaTest in the directory instead?

Happy to provide more clarification if necessary.

4 comments

Unfortunately sbt's model can't be fully mapped to IDEA's project model, which results in some of the inconsistencies you are describing. We are working on a better sbt integration, which will allow delegating such tasks to sbt directly.

As a workaround, you can run sbt tasks from IDEA directly by creating an sbt run configuration (Run/Debug configurations, + icon, SBT task) that just calls it:test

2

How would one then incorporate Code Coverage if running tests as SBT tasks ?

0

The coverage execution is currently not supported, I've created an issue: https://youtrack.jetbrains.com/issue/SCL-14105

You may be able to add coverage support within the sbt configuration however.

 

0

It should be noted that resources don't merge so intellij cannot find the resources in `src/it/resources`.

0

Please sign in to leave a comment.