0
현재 FunSuite는 test
메소드를 테스트로 실행합니다.ScalaTest의 FunSuite에서 자체 테스트 메소드
test
을 감싸는 mytest
함수를 작성하고 싶습니다. FunSuite가 실행할 테스트로 mytest
을 어떻게 인식시킬 수 있습니까?
현재 FunSuite는 test
메소드를 테스트로 실행합니다.ScalaTest의 FunSuite에서 자체 테스트 메소드
test
을 감싸는 mytest
함수를 작성하고 싶습니다. FunSuite가 실행할 테스트로 mytest
을 어떻게 인식시킬 수 있습니까?
FunSuite.test
은 ScalaTest의 FunSpecLike
특성으로 정의됩니다.
protected def test(testName: String, testTags: Tag*)(testFun: => Any /* Assertion */)(implicit pos: source.Position): Unit = {
// SKIP-SCALATESTJS-START
val stackDepth = 4
val stackDepthAdjustment = -2
// SKIP-SCALATESTJS-END
//SCALATESTJS-ONLY val stackDepth = 6
//SCALATESTJS-ONLY val stackDepthAdjustment = -6
engine.registerTest(testName, Transformer(testFun _), Resources.testCannotAppearInsideAnotherTest, "FunSuiteLike.scala", "test", stackDepth, stackDepthAdjustment, None, None, Some(pos), None, testTags: _*)
}
가장 중요한 포인트는 engine.registerTest(...)
호출을 통해, 실행을위한 페이로드를 등록하는 것입니다 : 그것은 다음과 같이 정의되어있다. 다음과 같이
class MyFunSuite
extends FunSuite {
// User-defined test named mytest
protected def mytest(testName: String, testTags: Tag*)(testFun: => Any /* Assertion */)(implicit pos: source.Position) = {
test(testName, testTags: _*)(testFun)(pos)
}
}
당신은 다음을 사용 : 이론적으로는이 같은 수행하여 mytest
을 인식 할 수
class MyTests
extends MyFunSuite {
mytest("This is one of my own tests.") {
// ...
}
mytest("This is another test.") {
// ...
}
// ...
}
는, 여기에는 부가 가치가 없다 (아직까지는)를하고, 기존 기능을 복제하기 위해 많은 노력을 기울일 것입니다. 그러나 필요할 수있는 상용구 작업을 수행하기 위해 mytest
의 정의를 명확하게 수정할 수 있습니다.