Integrating TestNG with Eclipse
- You should have installed Eclipse .
- Goto help>Install New Software
- Open Browser
- Goto Google >type install testNG or Goto http://testng.org/doc/download.html
- Copy the link corresponding to Eclipse Version .This should look something like below .
For Eclipse 3.4 and above, enter http://beust.com/eclipse.
For Eclipse 3.3 and below, enter http://beust.com/eclipse1.
6. Paste the same in "Work With" edit field on opened "Avaliable Software"window .Press Add button.
7. Check the Check box TestNg
8. Click next....next blah!blah! ...
9. Restart Eclipse and TestNg will be installed
---------------------------------------------------
Running TestNG
1.
Eclipse > New>Project>Java Project
>Enter name ... blah,blah ..(how you create your normal Java projects)
2.
Project created
3.
Go to project > src > Delete your default
package
4.
Create a new package in src (Ex : tester)
5.
Create a new class (Ex:"starter") inside
"tester" package
6.
Add below code inside tester.java
package starter;
package starter;
public class
starter {
@Test
public void
testing()
{
System.out.print("hi");
}
}
//Note: All Classes and Methods has to be of "Public" access identifier.
7.
Add all dependent libraries
8.
RtClick on src folder
9.
New>Other>XML>XML File
10. Create
file “Testng.xml”
11. Open Testng.xml,
Below screen click on “Source”
12. Add
following Code:
<suite name="some
name">
<test name = "other name">
<parameter name ="var" value="hi"/>
<classes>
<class name = "tester.starter" />
</classes>
</test>
</suite>
Class File
XML File
Examples :
If your class is just inside a default pacjake you can just write following in Testng.xml:
<suite name="TestNg_test">
<test name="assert1">>
<classes>
<class name="your_class" />
</classes>
</test>
</suite>
Following are the links which give you know how on integration of Selenium with TestNG:-
http://qtpselenium.com/selenium-tutorial
http://selftechy.com/2012/01/09/setting-up-testng-with-eclipse