2017-10-05 2 views

답변

2

FunSuite.testScalaTestFunSpecLike 특성으로 정의됩니다.

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의 정의를 명확하게 수정할 수 있습니다.