TestNG& appium:如果我使用@ BeforeMethod,@ AfterMethod和DependsOnMethods,如何连续运行2个或更多测试用例

时间:2015-08-17 03:39:13

标签: testng appium

@BeforeMethod
    public void startUp() throws MalformedURLException{
        DesiredCapabilities capabilities = new DesiredCapabilities();
        System.out.println("start appium service");
        capabilities.setCapability("appium-version", "1.0");
        capabilities.setCapability("platformName", "iOS");
        capabilities.setCapability("platformVersion", "8.0");
        capabilities.setCapability("deviceName", "iPhone 6");
        capabilities.setCapability("udid", "xxxxxxxxxxxxxxx");
        capabilities.setCapability("app", xxxxx/xxx.app");
        driver = new IOSDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
    }


    @Test
    public void test1()
    {
        System.out.println("test1");
    }

    @Test(dependsOnMethods={"test1"})
    public void test2()
    {
        System.out.println("test2");
    }

    @Test
    public void test3()
    {
        System.out.println("test3");
    }

    @AfterMethod
    public void tearDown() throws Exception 
    {
        driver.quit();
    }

预期结果:

  1. "启动appium服务" ----
  2. TEST1 ----
  3. TEST2 ----
  4. "启动appium服务" ----
  5. TEST3 ----
  6. 我只想启动appium service并连续执行test1和test2。然后重启appium服务,单独执行test3。

1 个答案:

答案 0 :(得分:0)

在Test3之前使用resetApp()方法。 driver.resetApp()