无法在 Eclipse 中使用 Appium 启动 JUnit 测试

Cannot start JUnit tests using Appium in Eclipse

我想使用 Eclipse 和 appium 开始 JUnit 测试。当我右键单击 select 运行 作为项目时,我 select 我的项目,但在测试时没有显示任何内容。有什么想法我哪里出错了吗?

我的 class 构建如下:

public WebDriver driver = null;

@BeforeMethod
public void setUp() throws Exception {
  // set up appium
  DesiredCapabilities capabilities = new DesiredCapabilities();
  capabilities.setCapability(CapabilityType.BROWSER_NAME, "iOS");
  capabilities.setCapability(CapabilityType.VERSION, "6.1");
  capabilities.setCapability(CapabilityType.PLATFORM, "Mac");
  capabilities.setCapability("app", "the path to the simulator app is correct, tested it with other software");
  driver = new RemoteWebDriver(new URL("http://127.0.0.1:4725/wd/hub"), capabilities);
}

@Test
public void test01() throws InterruptedException {

  Thread.sleep(5000);

}

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

确保您的以下库:

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;

另外,尝试将@BeforeMethod 和@AfterMethod 更改为@BeforeTest/@AfterTest