当前位置: 首页 > 知识库问答 >
问题:

使用GEB/Spock测试失败时在日志记录中自定义消息?

华献
2023-03-14

我正忙于GEB/Spock中的e2e测试,我想知道如何添加自定义消息。现在我只得到这样一个stacktrace:

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()
}
java.lang.NoSuchMethodError: geb.error.GebAssertionError.<init>(Ljava/lang/Object;Ljava/lang/Throwable;)V

at geb.waiting.WaitTimeoutException.<init>

共有1个答案

商璞
2023-03-14

可以使用custom-message向WaittimeoutException添加自定义消息

class HomePage extends Page {

    static at = {
        waitFor(message:"My custom message")    {title == "Acme Corporation"}
        waitFor(message:"My custom message",20) {$("#roadRunner")}
    }
}
 类似资料:
  • 将PostSharp用于C#应用程序,我有以下场景: Namespace_ACustomLoggingMethod Namespace_B.DoThings thingMethod(实际上是几种不同的方法) DoMomthingMethod调用CustomLoggingMethod,它以所需的格式创建日志条目并且运行良好。正如预期的那样,日志条目将源记录为CustomLoggingMethod,我

  • 我的数据库中没有插入任何内容。所以我的第一个问题是为什么它不工作,请给我任何解决办法,如果可能的话。 另一个问题是,我将的intLevel调整为10,如下所示: 而现在它正在插入数据库,但也抛出了一些错误。 如有任何帮助,我们将不胜感激,并提前向您表示感谢。

  • 目前在spring Boot1.3中,我们只能将访问日志记录到文件系统中的一个文件。有没有办法实际使用自定义记录器(像log4j2)来记录访问日志? 我目前正在使用undertow和spring boot,但是在检查spring boot源代码之后,undertow记录器是用DefaultAccessLogReceiver初始化的,它正在写入文件。如果可能的话,我希望使用AccessLogHand

  • 使用JBOSS 6.2 EAP作为应用服务器开发web应用程序。正在尝试自定义日志记录。要为指定位置的不同模块创建不同的日志。 做了一些家庭作业并尝试添加 在standalone的profile部分中。xml 并在同一文件中添加了记录器 此外,无法找到log4j。jboss文件夹中的xml。刚接触JBoss的人,猜一下遗漏了什么或走错了方向。有人能帮忙吗。

  • 所以我的问题是,功能测试通过“测试-应用程序集成”和“测试-应用程序”运行到底有什么不同? 与我所想的唯一不同的是,“test-app”运行所有测试阶段(单元、集成、功能)。 奇怪的是,它确实以某种方式工作,但只有当我首先运行“test-app-integration”时:/ null Tobbe致意

  • 我正在尝试使用Spock运行geb测试。我已经在groovy脚本中编写了所有内容,该脚本位于中,如下所示