I'm trying to run TestNG tests from Ant. After reading 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>
When I run it it fails with:
[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
:
ls -l
-ing the file gives -rw-r--r-- 1 adamatan users 4548 Nov 21 12:19
Tried both testng mode="testng"
and testng mode="mixed"
. Both failed with the same error.
Why can't testng read this valid class file that was just created?
The same problem was solved for me by adding to the classpath the directory where tests themselves are located (looks like it's ${bin.main}
in your case).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With