import org.specs2._
import reporter._
import main._
import specification._
// this reporter executes the specification but do not display anything
object silent extends DefaultReporter {
def export(implicit args: Arguments) = (s: ExecutingSpecification) => s.execute
def execute(fs: Fragments) = report(new Specification { def is = sequential ^ fs })(Arguments())
}
trait Filter { this: Specification =>
override def map(fs: =>Fragments) = {
val executed = silent.execute(fs)
// you can use whatever logic here based on the result of the previous execution
val filtered = executed.fs.zip(fs.fragments).collect { case (f1, f2) if (f1.stats.result.isSuccess) => f2 }
Fragments.createList(filtered:_*)
}
}
class TestSpec extends Specification with Filter { def is =
"ex1" ! ok^
"ex2" ! ko^
"ex3" ! ok
}
This is a hack is the sense that the first execution has to be executed sequentially otherwise there is a deadlock somewhere (I have no idea why). If this is ok for you, this might be the best way to go.
Eric.