2012-10-04 62 views
0

我已经编写了一个登录Facebook的基本测试。之后,我想编写另一个发布状态的测试用例。我想为此创建一个新的功能,但是如何在不重复整个登录过程的情况下做到这一点。在Junit中分离测试用例而不重复

 @Test 
    public void Facebook_LoginTest() { 

String title= null; 
     // And now use this to visit facebook 
     driver.get("http://www.facebook.com "); 


     // Find the text input element by its name 
     WebElement id = driver.findElement(By.id("email")); 
     WebElement password = driver.findElement(By.id("pass")); 
     WebElement login = driver.findElement(By.id("loginbutton")); 

     // Enter something to search for 
     id.sendKeys("[email protected]"); 
     password.sendKeys("blahblahblah"); 

回答

0

移动登录过程来测试初始化​​方法(带@Before所注解的)或以固定器的初始化方法(注解为@BeforeClass)