Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/369.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 无法在testng中运行脚本_Java_Testng_Appium - Fatal编程技术网

Java 无法在testng中运行脚本

Java 无法在testng中运行脚本,java,testng,appium,Java,Testng,Appium,我无法执行整个脚本。现在,我的脚本为@BeforeTest注释运行,而不是为@Test和@postertest运行 public class LaunchApp { WebDriver driver = null; @BeforeTest public void setup() throws InterruptedException{ DesiredCapabilities capabilities = new DesiredCapabilities();

我无法执行整个脚本。现在,我的脚本为
@BeforeTest
注释运行,而不是为
@Test
@postertest
运行

public class LaunchApp {

  WebDriver driver = null;

  @BeforeTest
    public void setup() throws InterruptedException{

      DesiredCapabilities capabilities = new DesiredCapabilities();
      capabilities.setCapability("appium-version", "1.4.13.1");
      capabilities.setCapability("platformName", "Android");
      capabilities.setCapability("platformVersion", "5.0.2");
      capabilities.setCapability("deviceName", "CC55EYG01397");
      capabilities.setCapability("app", "E:\\build_1026.apk");
      try {
        driver = new RemoteWebDriver(
            new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
      } catch (MalformedURLException e) {
        e.printStackTrace();
      }

      driver.manage().timeouts().implicitlyWait(80, TimeUnit.SECONDS);
    }

  @Test
    public void appiumExampleTest() throws Exception {

      WebElement phNo = driver.findElement(By.id("editTextFirst"));
      phNo.sendKeys("99999999");

      driver.findElement(By.id("textViewContinue"));


    }

  @AfterTest
    public void tearDown() {
      if (driver != null) {
        driver.quit();
      }
    }
}
即使从
testng.xml
运行脚本,脚本仍然没有完全运行。
请告诉我哪里弄错了。

请确保您使用的是TestNG库中的@Test注释。@Test注释可能指向JUnit库。只要检查一下就可以了。

欢迎使用堆栈溢出!我对你的问题进行了编辑,以便用户更清楚地理解,从而帮助你。祝你好运你怎么知道测试没有运行?请注意,如果测试未运行或失败,则不会运行
@postest
方法。小心,TestNG不是JUnit,
@Before/afterest
不是
@beforeftermethod
。我已经使用Before、Test、After注释在JUnit中执行了上述脚本。它被完全执行了。但在testng面临的问题。我认为我的注释不正确。如前所述,请尝试使用“@BeforeMethod”和“@AfterMethod”。您可能还想尝试:“@BeforeMethod(alwaysRun=true)”和“@AfterMethod(alwaysRun=true)”是否使用TestNG注释而不是JUnit注释?事件如果TestNG应该与JUnit注释一起使用,则不应使用它。