I'm using scala test for my tests, and some time ago the builds started to fail sometimes because some (new, probably) test takes more than the limit allowed by the CI.
At first sight no test should take more than the timeout (10 minutes btw), and by the CI output it not easy to see which test is taking so much time (or how much time every test takes)
I can put simple println-based statements to print the current hour at the beginning/end of each test, but I was wondering if scala test provides some builtin feature for that?
If no, does any other scala test framework/library does?
EDIT: tried to wrap the test
I prefere some native method from the lib itself. I was trying to wrap a specs2 test in a method that would get the description and log the times, but I'm having difficulties in running the test in the moment I want to. I did something Like this:
class SomeSpec {
private def withTimeLog(x: Fragment) = {
println(s"Starting test: ${x.description}(${DateTime.now()})")
//what now?
x.executionResult
println(s"End of test: ${x.description}(${DateTime.now()})")
}
withTimeLog("Feature" should {
"stuff" in {
println(s"test: ${DateTime.now()}")
None.isEmpty must beTrue
}
})
}
and the result:
Starting test: End(2016-07-28T18:11:53.101+01:00)
End of test: End(2016-07-28T18:11:53.191+01:00)
[info] FeatureSpecV2
[info]
test running at 2016-07-28T18:11:54.037+01:00
[info] A test should
[info] + stuff
meaning, test was executed in the end, and not between the 2 print statements. Maybe Fragment.execution result doesn't run the test. Tried with several others. Any idea which method should I be using?
You can display execution times in specs2 by passing the showtimes
option on the command line
sbt>testOnly *MySpec -- showtimes
Also if you use future matchers you can adjust a "time factor" with the timeFactor
command line option.