TestNG
TestNG is a testing framework inspired from JUnit and NUnit but introducing new functionalities that make it more powerful and easier to use.
It is an open source automated testing framework; where NG of TestNG means Next Generation. TestNG is similar to JUnit, especially when testing integrated classes.
TestNG eliminates most of the limitations of the older framework and gives the developer the ability to write more flexible and powerful tests with help of easy annotations, grouping, sequencing & parameterizing.
Benefits of TestNG
There are number of benefits but from Selenium perspective, major advantages of TestNG are:
- It gives the ability to produce HTML Reports of execution
- Annotations made testers life easy
- Test cases can be Grouped & Prioritized more easily
- Parallel testing is possible
- Generates Logs
- Data Parameterization is possible
Architecture of the testNG framework
pCloudy
pCloudy platform provides single click access to real Android and IOS devices directly from your browser. Use these real Mobile Devices to click-and-perform Manual Testing and execution of Automation Testing for your App. Integrate our platform with CI for continuous Automation Testing and test your App on multiple real Mobile Devices with every change of your App.
Now it’s very much simple to integrate your existing TestNG project with pCloudy.
Architecture of the TestNG framework with pCloudy
Prerequisite to integrate framework:
- TestNG Project or Download sample framework code
- contains public static void main methods.
- helps to create dynamic testng.xml file with selected device test.
- runs testing.xml as testng target.
Steps to integrate:
1. Add pCloudy connector jar in your existing project
2. Add Controller class in existing project
3. Add DeviceContext class in existing project
4. Add a list, which contains the classes that you want to run, pCloudy username, pCloudy API key & application path in Controller class.
Controller class
5. In TestNg class, add code to launch appium under @BeforeClass, @BeforeMethod annotation according to your project:
@Parameters({ “myDeviceContext” })
@BeforeClass
public void beforeClass(String myDeviceContext) throwsConnectError, IOException, InterruptedException {
DeviceContext myContext = Controller.allDeviceContexts.get(myDeviceContext);
try {
myContext.driver = newAndroidDriver
} catch (Exception ex) {
ex.printStackTrace();
}
}
6. In TestNG class, add code to quit driver under @AfterClass, @AfterMethod annotation according to your project:
@Parameters({ “myDeviceContext” })
@AfterClass
public void afterClass(String myDeviceContext) throws ConnectError, IOException {
DeviceContext myContext = Controller.allDeviceContexts.get(myDeviceContext);
myContext.driver.quit();
}
7. In TestNG class, add code to close pCloudy appium under @AfterTest annotation according to your project:
@Parameters({ “myDeviceContext” })
@AfterTest
public void afterTest(String myDeviceContext) {
DeviceContext myContext = Controller.allDeviceContexts.get(myDeviceContext);
try {
myContext.pCloudySession.releaseSessionNow();
} catch (ConnectError | IOException e) {
e.printStackTrace();
}
}
8. Run the TestNg framework execution by running controller class as java application.
Create support ticket; if you have any issues our expertise will help you.
Keep Automating…