My team is using Scala, IntelliJ, and Maven.
In the some of the tests I need for the current module I am working on the internal test order of execution is important.
For some reason running the same test using JUnit or ScalaTest in IntelliJ effects the order of execution.
For example, the following test:
package com.liveperson.lpbt.hadoop.monitoring.temp
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest.{FunSuite, BeforeAndAfterAll}
@RunWith(classOf[JUnitRunner])
class TempTest extends FunSuite with BeforeAndAfterAll{
println("start TempTest")
override def beforeAll(){
println("beforeAll")
}
override def afterAll(){
println("afterAll")
}
test("test code"){
println("in test code")
}
println("end TempTest")
}
When running with JUnit the above code prints outs:
start TempTest
end TempTest
in test code
beforeAll
afterAll
When running with ScalaTest the above code prints outs:
start TempTest
end TempTest
beforeAll
in test code
afterAll
Does somebody knows how to write such test ensuring the order of execution in both ScalaTests and JUint? Also, how do you switch between them in IntelliJ?
Can you elaborate on exactly how you got the JUnit output? I just tried doing your class from the command line and got the expected output (different from yours):