gpt4 book ai didi

grails - headless 运行 Geb + spock 测试

转载 作者:行者123 更新时间:2023-12-02 15:07:39 26 4
gpt4 key购买 nike

我对 grails 应用程序进行了许多 geb 功能测试。

从终端或 IDE 执行时,测试按预期工作。
虽然测试需要由 hudson 执行,所以它们使用 Xvfb 以 headless 模式运行。

问题是测试不断失败,或者表现出意外,在没有意义的地方返回诸如RequiredPageContentNotPresent 和Stale Element Reference Exception 之类的错误。

例如:
(在上面验证了 LicencePage,并且页面没有更改)

when:
addDocument(Data.Test_Doc_name,Data.Test_Doc_file)

有时会抛出
 Failure:  Add Actual Licence (HomePageSpec)
| geb.error.RequiredPageContentNotPresent: The required page content 'addDocument - SimplePageContent (owner: LicencePage, args: [Functional Test Doc, /var/lib/hudson/jobs/KB-Functional_Tests/workspace/app/../manual_test_data/so_v3/os_test_1], value: null)' is not present
at geb.content.TemplateDerivedPageContent.require(TemplateDerivedPageContent.groovy:61)
at geb.content.PageContentTemplate.create_closure1(PageContentTemplate.groovy:63)
at geb.content.PageContentTemplate.create(PageContentTemplate.groovy:82)
at geb.content.PageContentTemplate.get(PageContentTemplate.groovy:54)
at geb.content.NavigableSupport.getContent(NavigableSupport.groovy:45)
at geb.content.NavigableSupport.methodMissing(NavigableSupport.groovy:121)
at geb.Browser.methodMissing(Browser.groovy:194)
at geb.spock.GebSpec.methodMissing(GebSpec.groovy:51)
at HomePageSpec.Add Actual Licence (HomePageSpec.groovy:228)

方法 addDocument()是在一个“抽象”页面上定义的,LicencePage 正在扩展该页面。在大多数情况下,如果我将方法代码直接复制到我的规范中,它就会起作用,尽管它破坏了我在测试页面上的所有结构。

有人有使用 Xvfb 运行 geb 测试的经验吗?你遇到过这些问题吗?

All tests are passing when executed locally, and this not a data issue as the DB is always cleared



此外,在不进行任何更改的情况下,测试的行为是不确定的(在 hudson 上),因此并不总是抛出上述异常。完全不做任何更改,测试有时会成功,有时会失败。

最佳答案

您给出的描述似乎是一个不稳定的测试套件的症状。我们前段时间也面临这个问题。一个很好的起点是 presentation (大约 35 分钟左右)和 documentation关于 geb 中的等待内容。

如果您认为,它可能与 xvfb(我没有经验)有关,您可以尝试使用 phantomjs作为测试运行者并检查它是否正常工作。

关于grails - headless 运行 Geb + spock 测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24185173/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com