首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >testng.xml无法运行类

testng.xml无法运行类
EN

Stack Overflow用户
提问于 2016-03-18 12:15:23
回答 2查看 1.1K关注 0票数 0

我在我的testng.xml和测试套件中运行是正确的,但是它里面的类没有运行。testng.xml文件:

代码语言:javascript
复制
    <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="TestAll">
  <test name="Test">
  <parameter name="first-name"  value="Here we Go is not displayed after log in!!! "/>
    <classes>
        <class name="tests.LogIn">
    </class>
    </classes>
  </test> <!-- Test -->
</suite> <!-- Suite -->

我正在为这个类使用额外的Appium和JUnit库。Java代码类:

代码语言:javascript
复制
package tests;

import java.net.URL;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.Parameters;

import io.appium.java_client.AppiumDriver;
import io.appium.java_client.MobileElement;
import io.appium.java_client.ios.IOSDriver;
import io.appium.java_client.remote.MobileCapabilityType;



import static common.Helper.*;
import static common.Element.*;


public class LogIn {

    private static final String USERNAME = "string";
    private static final String USERPASSWORD = "string";


    //Config and Setup a AppiumDriverInstance 
     public AppiumDriver<MobileElement> driver;
      public WebDriverWait wait;
      @Before
      public void setUp() throws Exception {
        // set up appium for ios instance
        DesiredCapabilities capabilities = new DesiredCapabilities();
        capabilities.setCapability(MobileCapabilityType.DEVICE_NAME, "iPhone 5s");
        capabilities.setCapability(MobileCapabilityType.APP, "/path/to/file");
        driver = new IOSDriver<MobileElement>(new URL("http://127.0.0.1:4723/wd/hub"), capabilities);
        wait = new WebDriverWait(driver, 30);
      }


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


      @Parameters({ "first-name" })
      @Test
      public void findFirstElement() throws InterruptedException {


          //check if FTU "Here We go" is shown
          iOsAssertExists(WELTBILD_DE_HEREWEGO_XPATH,"Here we Go is not displayed after log in!!! ", driver);

          //tab on screen to close FTU "Here we go"
          driver.findElementByXPath(WELTBILD_DE_HEREWEGO_XPATH).tap(1,100);
          Thread.sleep(3000);

      }

}

这个类运行得很好,但是我不知道为什么testng不运行它。这是运行的结果:

代码语言:javascript
复制
[TestNG] Running:
  /Users/vorse/nga/ProductFamilyTests/AutomationTests/AppiumTest/testng.xml


===============================================
TestAll
Total tests run: 0, Failures: 0, Skips: 0
===============================================
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-03-18 12:40:06

您正在创建testNG.xml并使用junit注释,这就是为什么它不起作用的原因,您需要导入以下内容: import org.testng.注释。

此外,您还需要使用@ testNg,@BeforeTest/@BeforeClass来代替@ use,类似的情况用于@AfterTest-> @AfterTest/@AfterClass

票数 1
EN

Stack Overflow用户

发布于 2016-03-18 13:28:38

来自TestNG文档5.12 - JUnit试验

TestNG可以运行JUnit 3和JUnit 4测试。您所需要做的就是将JUnit jar文件放在类路径上,在testng.classNames属性中指定JUnit测试类,并将testng.junit属性设置为true:

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36084120

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档