Monday, October 31

Executing Selenium TestNG tests using ANT

ANT is software build automating tool for Java code. Uses XML file named ‘build.xml’ as the input for the build tasks. If one wants to run TestNG task using ANT, XML should contain information for testng calls and this can be built in two ways
1. By defining a external task of type TestNG and referring this task in another target ANT call further down in the code
2. By defining as Java command in ANT XML
The command line syntax to run TestNG task is   java org.testng.TestNG testng1.xml [testng2.xml testng3.xml ...]. The second option takes this approach of calling testNG using command line syntax but using ANT. Lets have look at the first option here in this post

Monday, October 24

Running Selenium TestNG test from command line

When I tried to run TestNG command from command line, I get following error. This is mainly because java cannot find class path and jar file of TestNG
C:\Selenium\Selenium_tests\DemoProject java org.testng.TestNg
Exception in thread "main" java.lang.NoClassDefFoundError: org/testng/TestNg
Caused by: java.lang.ClassNotFoundException: org.testng.TestNg
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: org.testng.TestNg.  Program will exit.
C:\Selenium\Selenium_tests\DemoProject 
So below are the steps to get it working

---------------------------------------------

Related Posts Plugin for WordPress, Blogger...