2017-02-08 4 views
0

Geb/Spock에서 e2e 테스트로 바쁘다. 맞춤 메시지를 추가하는 방법이 궁금했다. Geb/Spock으로 실패한 테스트에 대한 로깅의 맞춤 메시지?

내 시험의 예입니다 ...

geb.error.RequiredPageContentNotPresent: The required page content 'pages.patientConversation.PcModal -> contact: geb.navigator.EmptyNavigator' is not present 
    at geb.content.TemplateDerivedPageContent.require(TemplateDerivedPageContent.groovy:60) 
    at geb.content.PageContentTemplate.create_closure1(PageContentTemplate.groovy:63) 
    at geb.content.PageContentTemplate.create_closure1(PageContentTemplate.groovy) 

등 : 지금은이 같은 스택 트레이스를 얻을 내가 텍스트를 생각

def "allow for searching contacts"() { 
    when: 
    to LoginPage 
    login(emailAddress, defaultPassword) 
    then: 
    at QuickBar 
    when: 
    startButton.click() 
    then: 
    at Modal 
    when: 
    selectContactButton.click() 
    contactSearchField.value(context.pcUser2.surname) 
    then: "the contact is shown in the search results" 
    contact.isDisplayed() 
} 

"접촉은 같다 검색 결과 "는 오류 메시지에 나타나지만 분명히 그렇지 않습니다. Geb of Spock에서 사용자 정의 메시지를 더 명확하게 인쇄 할 수있는 또 다른 방법이 있습니까? 검사에서 실패 할 때 때문에

특수 '체커에서'당신은 얻을, 사용자 정의 메시지를 가지고 싶다 :

java.lang.NoSuchMethodError: geb.error.GebAssertionError.<init>(Ljava/lang/Object;Ljava/lang/Throwable;)V 

at geb.waiting.WaitTimeoutException.<init> 

편집 : 흠 I 실현 이제 "then"을 수행하기 전에 필요한 페이지 내용을 검사하기 때문에 테스트가 실패했습니다. 여전히 사용자 정의 메시지를 추가 할 수있는 기능을 원합니다 (특히 '체커'용) ... 가능하면 누구에게 알리십니까?

답변

7

당신은 WaitTimeoutException

class HomePage extends Page { 

    static at = { 
     waitFor(message:"My custom message") {title == "Acme Corporation"} 
     waitFor(message:"My custom message",20) {$("#roadRunner")} 
    } 
} 
+0

덕분에 사용자 정의 메시지를 추가 할 custom-message을 사용할 수 있습니다! 그리고 정기적으로 "a == b"에 대한 커스텀 메시지를주고 싶습니까? 아마 Spock 질문 일 겁니다. –

+0

다음과 같이 어설 션 메시지를 사용할 수 있습니다. '''다음 : 어설 션 a == b : "내 고객 메시지" ''' – Royg

+0

감사합니다. 나쁜 경우에 Spock의 힘이 내재되어 있다고 생각했기 때문에 여전히 그럴 경우 "assert"가 필요합니다 –