2012-04-25 56 views
1

我在使用GEB + Spock的Grails中進行功能測試時遇到了一些問題。如果我運行「測試應用程序」它總是失敗,但如果我運行「test-app -integration」之前「測試應用程序」它的工作原理!grails「test-app」在功能geb + spock測試中失敗,但「test-app -functional」成功

以下測試序列示出了我的問題:

試驗#1

grails> clean 
grails> test-app -functional 
... 
Tests PASSED 

試驗#2

grails> clean 
grails> test-app 
... 
Tests FAILED 

試驗#3

grails> clean 
grails> test-app -functional 
... 
Test PASSED 
grails> test-app 
... 
Test PASSED 

測試該失敗正在拋出「 geb.waiting.WaitTimeoutException:條件未在10.0秒內傳遞「。值得注意的是,失敗的測試用例正在等待數據庫查詢的結果。

所以我的問題是究竟是什麼區別,功能測試是通過「測試應用程序集成」與「測試應用程序」運行?

與我認爲「測試應用程序」運行所有測試階段(單元,集成,功能)的唯一區別。

而且奇怪的是,它做工作莫名其妙,但只有當我運行「測試應用程序 - 整合」第一:使用以下安裝/

林:

  • 的Grails 2.0 0.1
  • GEB 0.7.0
  • 斯波克0.6
  • 的HtmlUnit - 驅動2.0rc3(我嘗試使用2.20.0,但給了我更多的問題)

真的希望有人能幫助我。創業板+斯波克似乎是一個很好的解決方案,它的工作原理...

問候 Tobbe

回答

2

我設法解決這個問題,如果有興趣在這裏寫的解決方案等。這個解決方案是通過使用geb報告功能(偉大的工具!)

問題是,即時通訊使用grails ZKUI很多功能測試工作的應用程序和zkui生成不同的HTML代碼在不同的測試場景(是的,這真的很奇怪)。

例如一個ZK按鈕i作曲家:

<z:button id="simpleSearchButton" class="simpleSearchButton"/> 

當運行「測試應用程式內 - 整合」,它生成以下:

<span id="cECQ4" class="simpleSearchButton z-button"><table id="cECQ4-box" style=""  cellpadding="0" cellspacing="0" border="0"><tbody><tr><td class="z-button-tl"/><td class="z-button-tm"/><td class="z-button-tr"/></tr><tr><td class="z-button-cl"><button type="button" id="cECQ4-btn" class="z-button"/></td><td class="z-button-cm"><img src="/certservice-admin/images/search.png;jsessionid=2ADDD6FA5F1D011A96E447435514BDA2" align="absmiddle"/></td><td class="z-button-cr"><div></div></td></tr><tr><td class="z-button-bl"/>td class="z-button-bm"/><td class="z-button-br"/></tr></tbody></table></span> 

但運行「測試應用程式內」時它生成以下:

<button type="button" id="l9AP4" class="simpleSearchButton z-button-os"><img src="/certservice-admin/images/search.png;jsessionid=835A2B8A3FE0C54341BB4F109A0CCC62" align="absmiddle"/></button> 

在我的網頁目標i定義的按鈕爲:

simpleSearchButton(required: false) { $("span.simpleSearchButton") } 

其中「test-app」失敗,但沒有「test-app -integration」失敗。簡單的解決方案,以硬/奇怪的問題是:

simpleSearchButton(required: false) { $(".simpleSearchButton") } 

:)

乾杯 /Tobbe