我正在尝试执行一个简单的 TestNG 测试方法,但是,我得到了异常:
cannot find class in calsspath
我已经Project->Clean
在 eclipse 中尝试过,但是它不起作用,另外,请注意我已经为 中的测试类提供了完整的层次结构testng.xml
,请提出问题可能出在哪里。
我试过了Project-->Clean
,Run as-->mvn clean build
{
TestNG.xml have below code
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Suite1" verbose="1" >
<test name="TestClasses" >
<classes>
<class name="com.extentreports.test.ExtentReports.TestClass1" />
</classes>
</test>
</suite>
please see that, i have given complete path for my test class, still issue not solved
POM.xml have below entries
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
<configuration>
<suiteXmlFiles> testng.xml </suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.aventstack/extentreports -->
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>4.0.6</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
</dependencies>
TestClass1.java have below code
@Test
public void test001(){
System.out.println("Test001");
}
}
Eclipse 控制台中的错误跟踪:{ 这是在 Eclipse 控制台中找到的异常跟踪{org.testng.TestNGException:在类路径中找不到类:com.extentreports.test.ExtentReports.TestClass1 at org.testng.xml.XmlClass.loadClass(XmlClass .java:77) 在 org.testng.xml.XmlClass.init(XmlClass.java:69) 在 org.testng.xml.XmlClass.(XmlClass.java:55) 在 org.testng.xml.TestNGContentHandler.startElement(TestNGContentHandler .java:575) 在 com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)}
}