Continuous Testing of Scala sources

Prerequisite : common usages

Running all tests

If you want continuous testing of sources under src/main and src/test (files are compiled when they are saved then tests are run whenever a compile succeeds) :

mvn scala:cctest
  • Compilation runs in a infinite loop and compiles only modified files (non-stop), so use Ctrl+C to stop it
  • Tests are run if the compile succeeds
  • If you want to compile without FSC (with regular scalac like non-continuous compilation) :
    mvn scala:cctest -Dfsc=false

Running a subset of tests

To run only a single test each time or test cases matching a particular pattern, supply the test parameter (like the surefire:test goal)

mvn scala:cctest -Dtest=MyTest

Summary of test failures

To get useful output when tests fail (like SBT does by default) please make sure you have configured the surefire plugin to set useFile to false (or to use a maven property in the configuration of the useFile so you can override on the command line) then you get a reasonable report on the console when tests fail; showing the failed assertion and stack traces etc. So adding something like the following to your pom.xml

<plugin>
  <artifactId>maven-surefire-plugin</artifactId>
  <configuration>
    <forkMode>once</forkMode>
    <useFile>false</useFile>
  </configuration>
</plugin>
       

Note

If you want to display command used to run scala :

mvn scala:cctest -DdisplayCmd=true
  • WARNING : continuous compilation is an infinite loop so, avoid call the goal "cctest" in pom.xml or to connect it to a lifecycle's phase.