1
我有selenium.properties,其中我指定了测试配置(baseURL,浏览器等)。这被ant脚本用来启动webdriver junit测试用例。现在我有几个junit测试方法,我只想在Firefox上运行。我想知道是否有一种方法可以使用JUnit注释完成此操作?我可以创建自定义注释吗?运行Webdriver 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?
感谢您的指点,我会看看这些课程,并会尽快与我分享我的发现。 – aeinstein83
我能够完成使用自定义注释解释在这里:http://stackoverflow.com/questions/13590557/junit4-skip-tests-according-to-custom-java-annotations – aeinstein83