I'm attempting to run Selenium 2 tests using the TestNG framework
through the command line. I can run the tests through Eclipse by right
clicking on either the 3 browser test runners and doing 'Run As >
TestNG Test' or by right clicking on the 'testng.xml' and doing 'Run
As > TestNG Suite'.
My project consists of this structure:
C:\projects\SeleniumTest
\src
testng.xml
\tests
FirefoxTestRunner.java
InternetExplorerTestRunner.java
ChromeTestRunner.java
\utils
Tests.java
Helpers.java
The actual tests with the @Test annotation are in 'Tests.java,' which
as you can see below is never called explicitly. The 3 browser test
runners extend 'Tests,java'.
Here is my testng.xml file:
<!DOCTYPE suite SYSTEM "
http://testng.org/testng-1.0.dtd" >
<suite name="Selenium Test" verbose="10">
<test name="Tests" preserve-order="true">
<classes>
<class name="tests.FirefoxTestRunner"/>
<class name="tests.InternetExplorerTestRunner"/>
<class name="tests.ChromeTestRunner"/>
</classes>
</test>
</suite>
Now trying to run from the command line gives a TestNG Exception when
using this command 'java org.testng.TestNG testng.xml'.
Here is the output:
[ClassHelper] Could not instantiate tests.FirefoxTestRunner:
tests.FirefoxTestRunner
[ClassHelper] Could not instantiate tests.FirefoxTestRunner:
tests.FirefoxTestRunner
org.testng.TestNGException:
Cannot find class in classpath: tests.FirefoxTestRunner
My classpath from 'set CLASSPATH' shows all of these:
C:\projects\SeleniumTest\src
C:\projects\SeleniumTest\lib
C:\projects\SeleniumTest
C:\projects\SeleniumTest\src\utils
C:\projects\SeleniumTest\src\tests
Furthermore, my Build Path for my project shows it has the 'src'
directory under the Source tab. Also, Ctrl+Shift+T will pull up all 3
of my browser test runners.
But when I try to invoke the xml through the command line, it cannot
find the first test runner class. I'm assuming I made a stupid error
with my classpath... but I really have no idea. Any suggestions would
be greatly appreciated.
Thanks
Zack