如何在before中访问我的TestSuiteParams
我正在使用Runner运行测试
import org.scalatest.tools.Runner
val runnerArray: Array[String] = Array("-s", "com.inn.org.functional.Stateless", "-Dmonth=1")
Runner.run(runnerArray)我想在我的before中访问TestSuiteParams中的month属性,但是我不确定如何访问它。
到目前为止,我的测试是如何格式化的
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)
}发布于 2017-05-25 12:13:49
您必须将配置映射注入到测试类中,如下所示。
import org.scalatest.{ConfigMapWrapperSuite, WrapWith}
@WrapWith(classOf[ConfigMapWrapperSuite])
class Stateless(configMap: Map[String, Any]) extends fixture.FeatureSpec with BeforeAndAfter {
before("before") {
configMap("month")
}
}https://stackoverflow.com/questions/44170805
复制相似问题