1
specs2의 Around 블록에서 별도 클래스의 함수에서 matchers를 실행하는 방법은 무엇입니까?주변 블록에서 specs2 matcher 사용
예 (사용 플레이 프레임 워크) :
class Spec extends Specification {
"the application" should {
"do something" in new WithBrowser { // <-- 1. because of this around block
val runner = new Runner
runner.check(browser)
}
}
}
class Runner extends MustMatchers {
def check(browser: TestBrowser) = {
browser.pageSource must contain("some text that isn't there") // <-- 2. this won't fail
}
}
나는 FailureExceptions을 포기하지 매처 (matcher)와 함께 작동하지 않는다는 주위의 scaladoc에서 읽어 보시기 바랍니다. 이것은 모든 matchers를 직접 점검해야한다는 것을 의미합니까? 어떻게하면 내 matchers가 실패 할 수 있습니까? 당신이 Specs2 모두 아래로 mutable.Specification
에서 모든 방법을 할 특성을 따르는 경우에
/**
* This trait provides implicit definitions to transform any value into a
* MustExpectable, throwing exceptions when a match fails
*/
이있다 :
감사합니다. 작동합니다 (예 : 실패). 답변을 수락하기 전에 잠시 기다려야합니까? – ThorinII
그건 너에게 달렸어. 아마도 누군가 코드에 6자를 추가하는 것보다 훨씬 깨끗한 솔루션을 생각해 낼 수 있습니까? ;-) – millhouse