从main方法调用参数化的Junit测试用例

时间:2015-05-14 09:01:09

标签: java junit selenium-webdriver

包含测试用例的类

public class SeleniumTestcaseParameterized  {

WebDriver driver;

private String userName, password, baseUrl;

public SeleniumTestcaseParameterized(String userName, String password) {
    this.userName = userName;
    this.password = password;
}    
 @Before
public void setUp() {
}   
@Test
public void testSeleniumTestcaseParameterized() throws Exception {
    driver.get(baseUrl + "url");
    driver.findElement(By.id("username")).sendKeys(userName);
    driver.findElement(By.id("password")).sendKeys(password);
 }
 @After
public void tearDown() {
    driver.quit();
}

在main方法中调用测试用例的类

public class MainClass {

public static void main(String[] args) {
    String name =JOptionPane.showInputDialog("Please enter Username");
    SeleniumTestcaseParameterized c = new SeleniumTestcaseParameterized(name,name);
    junit.textui.TestRunner.run(c.getClass());

    }

我无法将参数传递给main的测试用例。

0 个答案:

没有答案