0
TestNG 6.8.8
理解測試套件
我有以下接口:
public interface MyInterface{
/**
* Some contract
**/
public String convert(String arg);
}
現在我有一堆MyInterface
實現:MyInterface1Impl
,MyInterface2Impl
,MyInterface3Impl
,等...
的問題是,我想測試JavaDoc
中定義的總體合同以及具體實施的細節。一個我會寫這樣的事:
public class MyInterfacecontractTestSuite{
@Test(dataProvider="someDataProvider")
public void testContract(MyInterface mi, String arg){
//test
}
}
和,例如
public class MyInterface1ImplTest{
//test cases for the implementation MyInterface1Impl
}
但它看起來在一點點凌亂的情況下爲MyInterface1Impl
是不是所有的MyInterface1ImplTest
類,這可能是混亂了一下。
但是在每個實現測試類中放置一個總體合同的重複測試用例也很奇怪。
所以,我不qiute肯定,如果我在正確的方式。也許有更好的解決方案來測試這些合同。
是的,我想到了這種想法,但拒絕了。如果一個實現實現了多個接口,這也是測試一些基本合同所必需的,該怎麼辦?我認爲這可能是一個問題......但無論如何,它看起來更好。 – user3663882
也許你可以嘗試實現Factory(http://testng.org/doc/documentation-main.html#factories)並根據你的實現實現的接口來生成MyInterfacecontractTestSuite(和其他接口相關的測試類)。但它可能比重複更復雜。 – juherr