gpt4 book ai didi

java - testng 无法从 ant 加载测试类

转载 作者:搜寻专家 更新时间:2023-10-31 19:55:39 25 4
gpt4 key购买 nike

我正在尝试从 Ant 运行 TestNG 测试。看完the manual, I came up with :

<taskdef name="testng" classname="org.testng.TestNGAntTask" classpath="../../lib/testng-6.8.1.jar"/>
<target name="testng" depends="compile-tests" description="Run testng test suite">

<fileset id="mixed.tests" dir="${bin.main}">
<include name="**/*Test.*"/>
</fileset>

<testng mode="mixed" classfilesetref="mixed.tests"
verbose="5"
failureProperty="tests.failed" outputdir="/tmp/report">
<classpath>
<fileset dir="../../lib" includes="*.jar"/>
<fileset dir="../../java/bin/" includes="**/*.class"/>
<fileset dir="/home/y/lib/jars" excludes="junit*jar,messagebus-disc-parent.jar" includes="**/*.jar" description="all jars installed by dependent pacakges" />
</classpath>
</testng>

当我运行它时,它失败了:

   [testng] 'org.testng.TestNG'
[testng] '@/tmp/testng8260935716887369607'
[testng]
[testng] The ' characters around the executable and arguments are
[testng] not part of the command.
[testng] Exception in thread "main" org.testng.TestNGException:
[testng] Cannot load class from file: /home/adamatan/SOME_PATH_THAT_EXISTS/functional/EnforceBasicFilteringTest.class
[testng] at org.testng.internal.ClassHelper.fileToClass(ClassHelper.java:600)
[testng] at org.testng.TestNG.configure(TestNG.java:1393)
[testng] at org.testng.TestNG.privateMain(TestNG.java:1354)
[testng] at org.testng.TestNG.main(TestNG.java:1333)
[testng] The tests failed.

我已经尝试过的:

文件和权限:

/home/adamatan/SOME_PATH_THAT_EXISTS/functional/EnforceBasicFilteringTest.class:

  • 出现在类路径打印输出中(它很长,所以我没有把它放在这里)。
  • 是由编译目标创建的,所以它是非空的,ant可以读取它的内容。
  • ls -l-ing 文件给出 -rw-r--r-- 1 adamatan users 4548 Nov 21 12:19

模式类型:

尝试了 testng mode="testng"testng mode="mixed"。两者均因相同的错误而失败。

为什么 testng 无法读取这个刚刚创建的有效类文件?

最佳答案

我通过将测试本身所在的目录添加到类路径中解决了同样的问题(在您的情况下看起来是 ${bin.main})。

关于java - testng 无法从 ant 加载测试类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20121114/

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