2016-11-15 49 views
0

我在寫一個定製的Gradle插件,它將創建一個新的測試任務並運行它。我需要在這個測試任務上設置一些配置。如何在用Java編寫的自定義插件中配置Gradle TestNGOptions?

插件是用Java編寫和執行測試任務的代碼如下所示:

private void runSmokeTests() { 

    Test test = new Test(); 
    test.useTestNG(new Closure(/* What goes in here? */) { 
     // and here? How do I get hold of TestNGOptions? 
    }); 

    test.executeTests(); 

} 

我無法弄清楚如何使用封閉類從Java。

回答

1

最簡單的選項只是調用getOptions()並轉換爲適當的類型。

test.useTestNG(); 
TestNGOptions options = (TestNGOptions) test.getOptions(); 
// configure options ie... 
options.setPreserveOrder(true); 
+0

完美。謝謝馬克。 –

相關問題