2015-11-02 61 views

回答

3

你可以在你的測試扔SkipException的,如果假設不成立,而且機制靈活,足以甚至標記試驗,跳過或失敗。 This article展示瞭如何在測試套件中以聲明方式集成此方法。基本上你用@Assumes註釋方法,並有一個自定義IInvokedMethodListener。或者(我不鼓勵這樣做,但它是一個選項),如果您可以確定要靜態跳過的內容,那麼您可以即時生成XML規範並運行它。

4

您可以使用註釋@Test忽略的測試方法(啓用= FALSE)

2

另一種解決方案是使用IAnnotationTransformers,然後像使用@Test(enabled = false)那樣禁用測試。

public void transform(ITest annotation, Class testClass, 
     Constructor testConstructor, Method testMethod) { 
    if (...determine if the test should be disabled) { 
     annotation.setEnable(false); 
    } 
} 
相關問題