簡體   English   中英

Groovy 類可以用作 FitNesse 夾具嗎

[英]Can Groovy classes be used as FitNesse fixtures

我正在學習 FitNesse 框架,想知道夾具代碼是否可以用 Groovy 編寫。 因此,我復制了一個示例決策表,將原始 class 重命名為ShouldIBuyMilkJava並創建了具有相同功能的 Groovy class。 所以我的設置是這樣的:

wiki 測試頁面(為簡潔起見省略了表格行):

|should I buy milk Java                                         |
|cash in wallet|credit card|pints of milk remaining|go to store?|
|0             |no         |0                      |no          |
|10            |no         |0                      |yes         |

|should I buy milk Groovy                                       |
|cash in wallet|credit card|pints of milk remaining|go to store?|
|0             |no         |0                      |no          |
|10            |no         |0                      |yes         |

應該買MilkJava.java

此處相同,只是 class 重命名為ShouldIBuyMilkJava

應該購買MilkGroovy.groovy

class ShouldIBuyMilkGroovy {
    def dollars
    def pints
    boolean creditCard

    ShouldIBuyMilkGroovy() {

    }

    // the rest is omitted for brevity

這兩個類都編譯成功,並且位於測試頁面中作為類路徑導入的文件夾中。 第一個測試成功通過,但第二個測試出現異常Could not invoke constructor for ShouldIBuyMilkGroovy[0]

我嘗試從 Groovy class 中刪除一個空的無參數構造函數 - 結果相同。

如何使 Groovy 類用作 FitNesse 固定裝置?

所以,修復很簡單——我必須將指向 groovy 庫的!path指令包含到 FitNesse root頁面中,而不是測試頁面中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM