Last active
August 29, 2015 14:06
-
-
Save swapnil-kotwal-sp/825551dc436655eb7727 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
trait TestableSimulation extends Simulation with FlatSpecLike with BeforeAndAfter { | |
val props = scala.collection.mutable.Map.empty[String, String] | |
for { p <- sys.props if (p._1.startsWith("gatling")) } yield { props += p } | |
GatlingConfiguration.setUp(props) | |
val simClass = getClass.asInstanceOf[Class[io.gatling.core.scenario.Simulation]] | |
val cleanSimClassName = simClass.getSimpleName.clean | |
val outputDirectoryName = configuration.core.outputDirectoryBaseName.getOrElse(cleanSimClassName) | |
var selection = new Selection(simClass, outputDirectoryName, "no description") | |
def describe(desc: String) = selection = new Selection(simClass, outputDirectoryName, desc) | |
"Simulation" should "complete without assertion failures" in { | |
val runOutcome = new Runner(selection).run | |
val result = runOutcome._2 match { | |
case sim: Simulation if !sim.assertions.isEmpty => { | |
if (Assertion.assertThat(sim.assertions, DataReader.newInstance(outputDirectoryName))) GatlingStatusCodes.success | |
else GatlingStatusCodes.assertionsFailed | |
} | |
case _ => GatlingStatusCodes.success | |
} | |
assertResult(GatlingStatusCodes.success, "simulation has assertion errors")(result) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment