Created
July 14, 2016 13:15
-
-
Save adriansr/84ca838244f747784efd7bf426dfae56 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* stress test a JUnit test | |
given your test body: | |
feature(a) { | |
} | |
... | |
feature(c) { | |
} | |
wrap it: | |
feature("stress test") { | |
scenario("run") { | |
new StressTest { | |
def run() = { | |
body | |
} | |
}.run_all(num_repetitions,num_concurrent) | |
abstract class StressTest { | |
def run(): Unit | |
def feature(s:String)(body: =>Unit) = body | |
def scenario(s:String)(body: =>Unit) = body | |
def Given(s:String)=Unit | |
def Then(s:String)=Unit | |
def When(s:String)=Unit | |
def And(s:String)=Unit | |
def run_all(numLoops: Int, numConcurrent: Int) { | |
val f = Future.sequence( | |
(1 to numConcurrent).map(_=>Future { | |
for (num <- 1 to numLoops) | |
run() | |
}) | |
) | |
Await.result(f,Duration.Inf) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment