【问题标题】:Separating Test Cases without repeating in Junit在 Junit 中分离测试用例而不重复
【发布时间】:2012-10-04 13:55:38
【问题描述】:

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

        @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("id@blah.com");
        password.sendKeys("blahblahblah");

【问题讨论】:

    标签: java function junit automated-tests


    【解决方案1】:

    将登录过程移动到测试初始化​​方法(用@Before注解)或Fixture初始化方法(用@BeforeClass注解)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-26
      • 1970-01-01
      • 1970-01-01
      • 2013-04-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多