Hi Jared,
ScalaTest does not have a trait for that, but luckily you can "bend
the framework" (instead of fighting the framework). The way to
accomplish this is to override one of ScalaTest's lifecycle methods.
To rerun the entire Suite you'd most likely want to override the run
method. It would call super.run then look at the Status result. That
can be async (Status is like a domain specific Future[Boolean]), so
you should call the succeeds() method that blocks waiting for the
completion. Then if it is a failure, just call super.run again,
returning the second Status. It would look something like:
trait SuiteRetries extends SuiteMixin { this: Suite =>
abstract override def run(testName: Option[String], args: Args): Status = {
val status = super.run(testName, args)
if (status.succeeds())
status
else
super.run(testName, args)
}
}
Here how that looks in the REPL:
scala> import scala.language.postfixOps
import scala.language.postfixOps
scala> class MySuite extends FunSuite with SuiteRetries {
| test("oops") { assert(1 == 2) }
| test("good") { assert(1 + 1 == 2) }
| }
defined class MySuite
scala> new MySuite execute
MySuite:
- oops *** FAILED ***
org.scalatest.exceptions.TestFailedException was thrown. (<console>:28)
- good
- oops *** FAILED ***
org.scalatest.exceptions.TestFailedException was thrown. (<console>:28)
- good
As you can see because one test failed, it reran both of the others.
Here's the success behavior:
scala> class MyOtherSuite extends FunSuite with SuiteRetries {
| test("not oops") { assert(1 != 2) }
| test("good") { assert(1 + 1 == 2) }
| }
defined class MyOtherSuite
scala> new MyOtherSuite execute
MyOtherSuite:
- not oops
- good
As you can see, when all tests passed it doesn't rerun the suite.
Bill
> --
> You received this message because you are subscribed to the Google
> Groups "scalatest-users" group.
> To post to this group, send email to
scalate...@googlegroups.com
> To unsubscribe from this group, send email to
>
scalatest-use...@googlegroups.com
> For more options, visit this group at
>
http://groups.google.com/group/scalatest-users?hl=en
> ScalaTest itself, and documentation, is available here:
>
http://www.artima.com/scalatest
> ---
> You received this message because you are subscribed to the Google Groups
> "scalatest-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
scalatest-use...@googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.
--
Bill Venners
Artima, Inc.
http://www.artima.com