Tuesday, 9 December 2014

TestNG Framework in Selenium Webdriver Part 1

What is TestNG?

TestNG is a selenium testing framework, by using which we can run our test cases/test suites in any order we need. There is one more framework available i.e. JUnit. But TestNG is more powerful as compared to JUnit as it is designed to overcome the limitations of JUnit and it supports lot more things as compared to JUnit.
We will see in details for this later.
Lets move on for TestNG and how can we use this and what are the annotations available in TestNG.

Installation of TestNG in Eclipse

Step 1: Open Eclipse and go to Help menu
Step 2: Click on 'Install New Software'. It will show the install window.
Step 3: There put the url:  http://beust.com/eclipse and then click Add. After adding it will show 'TestNG' in the list.
Step 4: Select TestNG checkbox and click Next.




Step 5: Then proceed and click Finish at the end.

There is another way present to install TestNG also. Please look at below steps.

Step 1: In Eclipse >Help menu, we can find 'Eclipse Marketplace...'. Click there.
Step 2: It will open a window. There type 'TestNG' and search. It will show that software to install.

Step 3: Click on Install there. Instead of Install, Uninstall appear here as it is already installed in my machine. After clicking install proceed as per the instruction shown over there.

Setup to use in project

1. Need to include webdriver jar files after creating a project. For more info regarding webdriver jar files, can visit my earlier blog on webdriver jar files..
2. Apart from this, we need TestNG library. Go to below path and include this library to your project.
Right click on Project > Build Path > Configure Build Path > Libraries > Add Library > Select TestNG >Next > Finish



3. Now you can create class file and do your coding stuff. Then to run that program using TestNG, we can right click > Run as, and then select TestNG there.




Now we are done with installation and setup for TestNG in Eclipse. This is just an introduction on how to start with TestNG.
In next blog, we will see all the annotations available in TestNG with practical example and then run them using TestNG.

No comments :

Post a Comment