Error-TestngTestSuiteUsingXML.java:6:错误:包org.testng不存在

时间:2014-02-27 03:49:14

标签: java eclipse selenium-webdriver testng command-prompt

  1. 我在Eclipse中有一个名为 OneReports 的项目。在项目中,我有一个名为测试的包。
  2. 项目如下:enter image description here

  3. 在eclipse中运行** TestngTestSuiteUsingXML ** java文件时,它正在获取 Test.XML ,它运行正常。

  4. 但是当我在命令中验证相同时,提示错误如下:

    C:\Jars>javac TestngTestSuiteUsingXML.java
    TestngTestSuiteUsingXML.java:6: error: package org.testng does not exist
    import org.testng.TestNG;
    ^
    
    TestngTestSuiteUsingXML.java:7: error: package org.testng.xml does not exist
    import org.testng.xml.XmlSuite;
    ^
    TestngTestSuiteUsingXML.java:15: error: cannot find symbol
    XmlSuite suite = new XmlSuite();
    ^
    symbol: class XmlSuite
    location: class TestngTestSuiteUsingXML
    TestngTestSuiteUsingXML.java:15: error: cannot find symbol
    XmlSuite suite = new XmlSuite();
    ^
    symbol: class XmlSuite
    location: class TestngTestSuiteUsingXML
    TestngTestSuiteUsingXML.java:17: error: cannot find symbol
    List<XmlSuite> suites = new ArrayList<XmlSuite>();
    ^
    symbol: class XmlSuite
    location: class TestngTestSuiteUsingXML
    TestngTestSuiteUsingXML.java:17: error: cannot find symbol
    List<XmlSuite> suites = new ArrayList<XmlSuite>();
    ^
    symbol: class XmlSuite
    location: class TestngTestSuiteUsingXML
    TestngTestSuiteUsingXML.java:19: error: cannot find symbol
    TestNG tng = new TestNG();
    ^
    symbol: class TestNG
    location: class TestngTestSuiteUsingXML
    TestngTestSuiteUsingXML.java:19: error: cannot find symbol
    TestNG tng = new TestNG();
    ^
    symbol: class TestNG
    location: class TestngTestSuiteUsingXML
    8 errors
    

1 个答案:

答案 0 :(得分:1)

您必须将testNG.jar添加到类路径中。以下链接可能会有所帮助: -

Java command line with external .jar

How to include jar files with java file and compile in command prompt

你必须下载testNG jar并将它和selenium jar文件一起添加到你的类路径中。 我建议你使用构建和依赖工具,如maven或ant