我有JUnit主要测试套件。该套件包含许多套件 - 适用于每种测试配置
@RunWith(ProgressSuite.class)
@SuiteClasses({
SimpleTest.class,
AboutTest.class,
CDH4_JDBC_TestSuite.class,
CDH5_JDBC_TestSuite.class,
CDH4_Metastore_TestSuite.class,
CDH5_Metastore_TestSuite.class,
CDH4_JDBC_Kerberos_TestSuite.class,
CDH5_JDBC_Kerberos_TestSuite.class,
CDH4_Metastore_Kerberos_TestSuite.class,
CDH5_Metastore_Kerberos_TestSuite.class,
})
public class TestSuite {
}
每个测试配置的套件包含相同的测试用例,但包含不同的setUpClass()和tearDownClass()方法
@RunWith(Suite.class)
@SuiteClasses({
PerspectiveSwitchTest.class,
NewFolderFromToolbarTest.class,
RenameFolderFromToolbarTest.class,
RenameFileFromToolbarTest.class,
OpenFilePropertiesFromToolbarTest.class,
OpenFolderPropertiesFromToolbarTest.class,
DeleteFileFromToolbarTest.class,
DeleteFolderFromToolbarTest.class,
CopyPasteFolderFromToolbarTest.class,
CopyPasteFileFromToolbarTest.class,
CutPasteFolderFromToolbarTest.class,
CutPasteFileFromToolbarTest.class,
})
public class CDH4_JDBC_Kerberos_TestSuite {
private static SWTWorkbenchBot bot = new SWTWorkbenchBot();
private static AddNewEcosystemNavigator addNewEcosystemNavigator;
private static EcosystemConfigurationLoader ecosystemConfigurationLoader;
private static EcosystemConfiguration ecosystemConfiguration;
private static GenericNavigator genericNavigator;
@BeforeClass
public static void setUpClass() {
bot = new SWTWorkbenchBot();
addNewEcosystemNavigator = new AddNewEcosystemNavigator();
ecosystemConfigurationLoader = new EcosystemConfigurationLoader();
genericNavigator = new GenericNavigator();
ecosystemConfiguration = ecosystemConfigurationLoader
.getDefaultCDH4JDBCKerberosEcosystemConfiguration();
addNewEcosystemNavigator.addNewEcosystemManually(bot,
ecosystemConfiguration);
}
@AfterClass
public static void tearDownClass() {
genericNavigator.closeDialogWindow();
addNewEcosystemNavigator.discardEcosystem(bot, ecosystemConfiguration);
}
}
我正在使用Jenkins和Tycho进行测试。当我运行测试套件并且某些测试失败时,我无法区分哪些配置测试失败。在Jekins中我只能看到例如NewFolderFromToolbarTest被运行8次(3次失败,5次通过)的信息。当然,我可以从日志中获取所需信息,但这很耗时。
有什么方法可以获得所需信息吗?例如使用不同的测试结构,使用不同的jenkins插件,如果可能的话动态重命名方法等?有什么想法吗?非常感谢
答案 0 :(得分:0)
您可以使测试类抽象化,并使每个配置成为子类
public class CDH4NewFolderFromToolbarTest extends AbstractNewFolderFromToolbarTest{
//...
}
然后在你的套件中调用特定的测试类
RunWith(Suite.class)
@SuiteClasses({
CDH4PerspectiveSwitchTest.class,
CDH4NewFolderFromToolbarTest.class,
CDH4RenameFolderFromToolbarTest.class,
CDH4RenameFileFromToolbarTest.class,
//...etc
})
public class CDH4_JDBC_Kerberos_TestSuite {
//same as before
}
我建议不要在每个子类中进行重新配置,因为@BeforeClass
和@AfterClass
只有在放入套件时才会被调用一次。