1
votes

I am doing Java-Eclipse-TestNG and having trouble running tests using testng command line. I've multiple source folders and when the .class files are created they are going to /bin directory with the same folder structure as /src as shown below. I've set the classpath (using export CLASSPATH=...) to all the folders in /bin directory and tried to run "java org.testng.TestNG testng.xml", but what it gives me is "Cannot find class in classpath: TestCases.TC_0001". My testng.xml file is below.

<?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

1
Could you try with the -cp option of the java command?juherr

1 Answers

0
votes

Make sure you export the class path to bin/CIQLib/AIPClasses/;bin/CIQLib/BaseCLasses and so on. Just pointing it to CIQLib will not help. And here's the reason why:

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).

Ref: http://docs.oracle.com/javase/7/docs/technotes/tools/windows/classpath.html