Very slow to compile Unit Tests

Hi

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
    sb.append("easy!")
    assertEquals("ScalaTest is easy!", sb.toString)
    assertTrue(lb.isEmpty)
    lb += "sweet"
    try {
      "verbose".charAt(-1)
      fail()
    }
    catch {
      case e: StringIndexOutOfBoundsException => // Expected
    }
  }

  @Test def verifyFun() { // Uses ScalaTest assertions
    sb.append("fun!")
    assert(sb.toString === "ScalaTest is fun!")
    assert(lb.isEmpty)
    lb += "sweeter"
    intercept[StringIndexOutOfBoundsException] {
      "concise".charAt(-1)
    }
  }
}


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

Thanks
0

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

regards, Alex

0
Avatar
Permanently deleted user

I've enabled Fast Scala Compiling (fsc) as per this post http://grahamhackingscala.blogspot.com/2010/10/turn-fsc-fast-scala-compiling-on-in.html.

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.

0

请先登录再写评论。