2015-02-03 2 views
2

단서가 어설 션 오류의 일부가 될 수 있도록 ScalaTest 정규식에 실마리를 추가하는 관용구가 있습니까?ScalaTest matcher에 단서를 추가하는 구문이 있습니까?

withClue("expecting a header row and 3 rows of data") { 
    rowCount should equal(4) 
} 

이 주장에 단서를 추가하는 유일한 구문입니다 : 내가 현재이 같은 ScalaTest의 주장을 쓸 수 있는지 알아? 이 같은 것을보고 주장을 쓸 수있을 것이 좋을 것이다 :

rowCount should equal(4) because("expecting a header row and 3 rows of data") 

답변

5

당신이 AppendedClues 믹스 인 접미어로 withClue을 쓸 수있는 경우 :

class TestSuite extends FlatSpec with Matchers with AppendedClues { 
    3 should equal(4) withClue("expecting a header row and 3 rows of data") 
} 

은 또한 물론 괄호없이 작동합니다.

+0

니스. 이것에 대한 몇 가지 언급은 ScalaTest User Guide의 "Using Matchers"섹션에 추가되어야합니다. –