Grails 运行Geb+;斯波克测试无头

Grails 运行Geb+;斯波克测试无头,grails,spock,geb,xvfb,Grails,Spock,Geb,Xvfb,我为grails应用程序做了许多geb功能测试 当从终端或IDE执行测试时,测试工作正常。 尽管这些测试需要由哈德逊公司执行,所以它们是使用Xvfb在无头模式下运行的 问题是测试一直失败,或者表现出意外,在没有意义的地方返回错误,如RequiredPageContentNotPresent和Stale元素引用异常 例如: (在许可证页面已在上面验证,页面未更改) 有时抛出 Failure: Add Actual Licence (HomePageSpec) | geb.error.Requ

我为grails应用程序做了许多geb功能测试

当从终端或IDE执行测试时,测试工作正常。 尽管这些测试需要由哈德逊公司执行,所以它们是使用Xvfb在无头模式下运行的

问题是测试一直失败,或者表现出意外,在没有意义的地方返回错误,如RequiredPageContentNotPresent和Stale元素引用异常

例如: (在许可证页面已在上面验证,页面未更改)

有时抛出

 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()
在“摘要”页面上定义,LicensePage正在扩展该页面。在大多数情况下,如果我将方法代码直接复制到我的规范中,它会工作,尽管它会破坏我在测试页面上的所有结构

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

当在本地执行时,所有测试都通过,这不是数据问题,因为数据库总是被清除


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

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

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

 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)