我有 selenium.properties,我在其中指定了测试配置(baseURL、浏览器等)。ant 脚本使用它来启动 webdriver junit 测试用例。现在我有几个 junit 测试方法,我只想在 Firefox 上运行。我想知道是否有一种方法可以使用 JUnit 注释来完成此任务?我可以创建自定义注释吗?
my setup
public class TestBase{
public static String baseURL = null;
public static String browser = null;
@BeforeClass
public static void webdriverSetUp() {
try {
FileInputStream fn = new FileInputStream(SELENIUM_PROP_FILE);
Properties selenium_properties = new Properties();
selenium_properties.load(fn);
baseURL = selenium_properties.getProperty("baseUrl");
browser = selenium_properties.getProperty("browser");
} catch (Exception e) {
e.printStackTrace();
}
if(browserg.equalsIgnoreCase("firefox")){
File profileDirectory = new File("./profile");
FirefoxProfile profile = new FirefoxProfile(profileDirectory);
driver = new FirefoxDriver(profile);
}
}
//Test Class
public class TestCase1 extends TestBase{
@Test //run this case only if browser = firefox
public void test1(){
}
@Test //do not run this case if browser = chrome
public void test2(){
}
}
any pointers?