behavior of "A loop"
for (i <- 1 to 10) {
it should behave like aGoodLoop(i)
}
}
When run this gives:
$ scala -cp target/jar_contents/ org.scalatest.tools.Runner -o -s FlatTests -R .
Run starting. Expected test count is: 10
FlatTests:
A loop
hi 1
hi 2
hi 3
hi 4
hi 5
hi 6
hi 7
- should do logic: 1 *** FAILED ***
true was not false (delme.scala:20)
hi 8
- should do logic: 2 *** FAILED ***
true was not false (delme.scala:20)
hi 9
- should do logic: 3 *** FAILED ***
true was not false (delme.scala:20)
hi 10
- should do logic: 4 *** FAILED ***
true was not false (delme.scala:20)
- should do logic: 5 *** FAILED ***
true was not false (delme.scala:20)
- should do logic: 6 *** FAILED ***
true was not false (delme.scala:20)
- should do logic: 7 *** FAILED ***
true was not false (delme.scala:20)
- should do logic: 8 *** FAILED ***
true was not false (delme.scala:20)
- should do logic: 9 *** FAILED ***
true was not false (delme.scala:20)
- should do logic: 10 *** FAILED ***
true was not false (delme.scala:20)
Run completed in 247 milliseconds.
Total number of tests run: 10
Suites: completed 1, aborted 0
Tests: succeeded 0, failed 10, canceled 0, ignored 0, pending 0
*** 10 TESTS FAILED ***
Let me know if you have other questions. I'll try and find some way to elaborate in the documentation on when things execute. In short, only tests themselves are not executed at construction time. Scopes (describe clauses, should/must/can clauses, etc.) and everything else in the constructor are executed at construction time. If an exception happens during construction for whatever reason, a SuiteAborted event is fired and no tests will ever run. If you want to a test failure instead, then you need to delay execution of that code until tests are run. The usual way to do that is make variables lazy.