Junit测试方法的顺序,当扩展类时

时间:2013-08-01 09:36:59

标签: eclipse junit selenium-webdriver

这里当我运行“第二”类时,执行的方法顺序是: 一个 b C 虽然在这里,“a”和“b”方法依赖于“c”方法。所以有人能告诉我该怎么办?

代码:

public class first {
public static WebDriver driver;  
@BeforeClass
public static void beforeClass()
{
    System.setProperty("webdriver.chrome.driver", "E:/chromedriver.exe");
    driver = new ChromeDriver();

}
   @Test
   public void c()throws Exception
   {
    driver.get("URL");
    WebElement login = driver.findElement(By.xpath("my xpath");
    login.findElement(By.id("username")).sendKeys("username");
    login.findElement(By.id("password")).sendKeys("pwd");
    driver.findElement(By.xpath("my xpath")).click();
   }
}

第二课:

public class second extends first
{
@Test
public void a() throws Exception
{
        //My Code;
    }

@Test
public void b() throws Exception
{
        //My Code;
    }
}

0 个答案:

没有答案