|
本帖最后由 yyscr0131 于 2012-7-5 09:03 编辑
有以下4个类- @Test(dataProvider = "mainProvider", dataProviderClass = MainProvider.class)
- public class Temp {
- public void testMainTemp1(String test) {
- System.out.println(test);
- }
- public void testMainTemp2(String test) {
- System.out.println(test);
- }
- }
复制代码 这是父类- public class MainProvider {
- @DataProvider(name = "mainProvider")
- public static Object[][] mainProvider() throws Exception {
- return new Object[][] { { "Main_Iphone" },
- { "Main_Android" } };
- }
- }
复制代码 父类的DataProvider- @Test(dataProvider = "subProvider", dataProviderClass = SubProvider.class)
- public class SubTemp extends Temp {
- public void testSubTemp1(String test) {
- System.out.println(test);
- }
- public void testSubTemp2(String test) {
- System.out.println(test);
- }
- }
复制代码 这是子类,继承父类- public class SubProvider {
- @DataProvider(name = "subProvider")
- public static Object[][] subProvider() throws Exception {
- return new Object[][] { { "Sub_Iphone" },
- { "Sub_Android" } };
- }
- }
复制代码 这是子类的DataProvider
此时执行子类的用例,输入
Sub_Iphone
Sub_Android
Sub_Iphone
Sub_Android
Sub_Iphone
Sub_Android
Sub_Iphone
Sub_Android
其实希望的是
子类的用例用子类的DataProvider
父类的用例用父类的DataProvider
执行子类时,输出
Main_Iphone
Main_Android
Main_Iphone
Main_Android
Sub_Iphone
Sub_Android
Sub_Iphone
Sub_Android
求大神给一个解决方案!!! |
|