Running before / after when overriding withFixture

19 views
Skip to first unread message

Ferdinand Svehla

unread,
Mar 24, 2015, 6:49:38 AM3/24/15
to scalate...@googlegroups.com
What I’m trying to do is basically the opposite of Retries, since we want to eradicate flickers ASAP.
When mixed into a Suite, each test must pass N number of times before it is reported as passing.

I’m not overriding `runTest`, since I don’t want to report the running test multiple times, so I’m using
withFixture. However, “before” is only run once.

  override protected def withFixture(test: NoArgTest): Outcome = {
    val
Times = 8


   
@tailrec def rerunUntilPass(iteration: Int): Outcome = {
     
if (iteration == Times) {
       
// On the last invocation we just return the outcome
       
super.withFixture(test)
     
} else {
       
super.withFixture(test) match {
         
case Succeeded rerunUntilPass(iteration + 1)
         
case other    
            alert
(s"Test `${ test.name }' failed at iteration ${ iteration } of ${ Times } needed")
            other
       
}
     
}
   
}


    rerunUntilPass
(1)
 
}

How can I run before / after, or not emit reporter events when overriding `runTest`
Reply all
Reply to author
Forward
0 new messages