gpt4 book ai didi

java - TestNG - 在类路径中找不到类

转载 作者:太空宇宙 更新时间:2023-11-04 13:24:54 24 4
gpt4 key购买 nike

我正在执行 Java-Eclipse-TestNG,但在使用 testng 命令行运行测试时遇到问题。我有多个源文件夹,当创建 .class 文件时,它们将转到/bin 目录,其文件夹结构与/src 相同,如下所示。我已将类路径(使用 export CLASSPATH=...)设置为/bin 目录中的所有文件夹,并尝试运行“java org.testng.TestNG testng.xml”,但它给我的是“在类路径中找不到类:TestCases.TC_0001”。我的 testng.xml 文件如下。

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Default suite">
<test verbose="2" name="Default test">
<classes>
<class name="TestCases.TC_0001">
</class>
</classes>
</test> <!-- Default test -->
</suite> <!-- Default suite -->

This is my folder structure

最佳答案

确保将类路径导出到 bin/CIQLib/AIPClasses/;bin/CIQLib/BaseCLasses 等。仅仅将其指向 CIQLib 是没有帮助的。原因如下:

classpath1;classpath2 Class paths to the .jar, .zip or .class files. Each classpath should end with a filename or directory depending on what you are setting the class path to: For a .jar or .zip file that contains .class files, the class path ends with the name of the .zip or .jar file. For .class files in an unnamed package, the class path ends with the directory that contains the .class files. For .class files in a named package, the class path ends with the directory that contains the "root" package (the first package in the full package name).

引用号:http://docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html

关于java - TestNG - 在类路径中找不到类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32756500/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com