Very slow to compile Unit Tests


I''m running a Scala Unit Test in IDEA 10.5.1, but it's also bad simply running a Java Unit test.

It takes around 13s to run this simple test each time:

import org.scalatest.junit.AssertionsForJUnit
import scala.collection.mutable.ListBuffer
import org.junit.Assert._
import org.junit.Test
import org.junit.Before

class ExampleSuite extends AssertionsForJUnit {

  var sb: StringBuilder = _
  var lb: ListBuffer[String] = _

  @Before def initialize() {
    sb = new StringBuilder("ScalaTest is ")
    lb = new ListBuffer[String]

  @Test def verifyEasy() { // Uses JUnit-style assertions
    assertEquals("ScalaTest is easy!", sb.toString)
    lb += "sweet"
    try {
    catch {
      case e: StringIndexOutOfBoundsException => // Expected

  @Test def verifyFun() { // Uses ScalaTest assertions
    assert(sb.toString === "ScalaTest is fun!")
    lb += "sweeter"
    intercept[StringIndexOutOfBoundsException] {

What can be done about this? Obviously a 13s wait makes test driven development pretty much impossible.


How long it takes to compile by native Scala compiler or ant?

regards, Alex


I've enabled Fast Scala Compiling (fsc) as per this post

It's all a lot better now.

As the post mentions, it would be good if this could be made the default, to save people like me investigating why it takes up to 20s to run a simple unit test.