Reputation: 16479
How do I access my TestSuiteParams
within my before
?
I am running my tests with Runner
import org.scalatest.tools.Runner
val runnerArray: Array[String] = Array("-s", "com.inn.org.functional.Stateless", "-Dmonth=1")
Runner.run(runnerArray)
I have the month
property in TestSuiteParams
I would like to access in my before
but I'm not sure how to access it.
Here is how my tests are formatted so far
class Stateless extends fixture.FeatureSpec with BeforeAndAfter {
before("before") {
// I want to access TestSuiteParams HERE
// but I cannot!
}
feature("feature") {
scenario() {TestSuiteParams =>
// this piece works! I can access .month!
assert(TestSuiteParams.month != null)
}
}
def withFixture(test: OneArgTest): org.scalatest.Outcome = {
val hiveContext = new HiveContext(sc)
test(TestSuiteParams(hiveContext, 1)
}
case class TestSuiteParams(hiveContext: HiveContext, month: String)
}
Upvotes: 0
Views: 157
Reputation: 11587
you will have to inject the config map into your test class as shown below.
import org.scalatest.{ConfigMapWrapperSuite, WrapWith}
@WrapWith(classOf[ConfigMapWrapperSuite])
class Stateless(configMap: Map[String, Any]) extends fixture.FeatureSpec with BeforeAndAfter {
before("before") {
configMap("month")
}
}
Upvotes: 1