SlideShare a Scribd company logo
1 of 26
Download to read offline
www.pragmatictestlabs.com/ janesh@pragmatictesters.com +94 71 873 2025
Next Selenium Training is starting from 30th March 2014 : Batch # : 2014-4
TestNG for Testers
- by Pragmatic Testers
Reference
The Creator of TestNG
Cédric Beust is a French software engineer and a software
technology author. He is the co-author of two books and the
creator of the TestNG Java testing framework
In 2004, he created TestNG an open source Java testing framework that has seen a lot
of adoption, especially in the web testing area.
He is still actively working on the framework on his spare time to support the community. I
maintain both the TestNG core and its Eclipse plug-in
Features of TestNG
Annotations
Run Tests in Big Thread Pools
Flexible Test Configuration
Support for Data Driven Testing
Support for Parameters
Powerful Execution Model - (TestSuite)
Supported by variety of tools and Plugins
source : http://testng.org/doc/index.html
Configure Maven
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.1.1</version>
<scope>test</scope>
</dependency>
source : http://testng.org/doc/maven.html
Three Step Process
Write the test script and insert TestNG annotations
Add the information about your test in a testng.xml file
(e.g. the class name, the groups you wish to run, etc.)
Run TestNG
First Test Script
public class SimpleTest {
@BeforeClass
public void beforeClass() {
// code that will be invoked when this test is instantiated
}
@Test(groups = { "fast" })
public void aFastTest() {
System.out.println("This is a fast test");
}
@Test(groups = { "slow" })
public void aSlowTest() {
System.out.println("This is a slow test");
}
}
Invoke the Test Script
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="Suite1" verbose="1" >
<test name="Test1">
<groups>
<run>
<include name="fast"/>
</run>
</groups>
<classes>
<class name="selenium.testng.example.SimpleTest"/>
</classes>
</test>
</suite>
Test Result
Annotations
@BeforeSuite
@AfterSuite
@BeforeTest
@AfterTest
@BeforeGroup
@AfterGroup
@BeforeMethod
@AfterMethod
alwaysRun
enabled
groups
@Test
alwaysRun
dataProvider
dataProviderClass
dependsOnGroups
dependsOnMethods
description
enabled
invocationCount
invocationTimeOut
singleThreaded, threadPoolSize
successPercentage
timeOut
Class level annotations
@Test
public class Test1 {
public void test1() {
}
@Test(groups = "g1")
public void test2() {
}
}
Parameters
Test methods can have parameters
Can use any number of parameters in Test methods
Pass parameters using @Parameters
From testing.xml : For simple values
With DataProviders : For complex parameters
Parameters with testing.xml
@Parameters({ "first-name" })
@Test
public void testSingleString(String firstName) {
System.out.println("Invoked testString " + firstName);
assert "Cedric".equals(firstName);
}
<suite name="My suite">
<parameter name="first-name" value="Cedric"/>
<test name="Simple example">
<-- ... -->
Parameters with @DataProvider
//This method will provide data to any test method that declares that its Data Provider
//is named "test1"
@DataProvider(name = "test1")
public Object[][] createData1() {
return new Object[][] {
{ "Cedric", new Integer(36) },
{ "Anne", new Integer(37)},
};
}
//This test method declares that its data should be supplied by the Data Provider
//named "test1"
@Test(dataProvider = "test1")
public void verifyData1(String n1, Integer n2) {
System.out.println(n1 + " " + n2);
}
DataProvider in Different Class
public class StaticProvider {
@DataProvider(name = "create")
public static Object[][] createData() {
return new Object[][] {
new Object[] { new Integer(42) }
}
}
}
public class MyTest {
@Test(dataProvider = "create", dataProviderClass = StaticProvider.class)
public void test(Integer n) {
// ...
}
}
Data Driven Testing
Data-Driven testing generally means executing a set of steps with
multiple sets of data.
Selenium does not provide any out-of-the box solution for data driven
testing but leaves it up to the user to implement this on his own.
TestNG is a framework that makes data-driven testing possible in
selenium. TestNG is a testing framework created in line with Junit but
with added features that makes it suitable for use in regression test
automation projects.
source : http://functionaltestautomation.blogspot.com/2009/10/dataprovider-data-driven-testing-with.html
Dependancies
Invoking Test Methods in certain order
With Annotations
Hard Dependencies : Must run and succeed
Soft Dependencies : Add alwaysRun=”true” to @Test
With XML
<test name="My suite">
<groups>
<dependencies>
<group name="c" depends-on="a b" />
<group name="z" depends-on="c" />
</dependencies>
</groups>
</test>
Running Failed Tests
TestNG creates a testng-failed.xml in output directory
Contains failed methods
Allows to re-run the failed tests
Can reproduce the failures and verify fixes quickly
TestNG and Selenium
@BeforeSuite(alwaysRun = true)
public void setupBeforeSuite(ITestContext context) {
String driverPropertyName = context.getCurrentXmlTest().getParameter("driver.property.name");
String driverPath = context.getCurrentXmlTest().getParameter("driver.path");
String browserType = context.getCurrentXmlTest().getParameter("browser.type");
String baseURL = context.getCurrentXmlTest().getParameter("base.url");
if (browserType == null) {
driver = new HtmlUnitDriver();
} else if (browserType.equalsIgnoreCase("Firefox")) {
driver = new FirefoxDriver();
} else if (browserType.equalsIgnoreCase("Chrome")) {
System.setProperty(driverPropertyName,driverPath);
driver = new ChromeDriver();
} //For other browsers
logger.info("BROWSER_TYPE=" + BROWSER_TYPE);
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(TIME_OUT, TimeUnit.SECONDS);
}
<parameter name="browser.type" value="Chrome" />
TestNG Assertions
Assert.assertEquals(Actual, Expected)
Assert.assertEquals(Actual, Expected, Message)
Assert.assertEqualsNoOrder(Actual, Expected)
Assert.assertFalse(Actual)
Assert.assertNotEquals(Actual1, Actual2, Delta)
Assert.assertSame(Actual, Expected)
Assert.fail(Message)
TestNG Reporting
Understanding Java API
Reference
Books
Videos : Data Driven Testing
Tutorials
TestNG Tutorial by MKYong
Testing Tutorials - Search for TestNG tutorial
Tutorials Point
Pragmatic Test Labs
Thank You !
www.pragmatictestlabs.com

More Related Content

What's hot

Introduction of TestNG framework and its benefits over Junit framework
Introduction of TestNG framework and its benefits over Junit frameworkIntroduction of TestNG framework and its benefits over Junit framework
Introduction of TestNG framework and its benefits over Junit frameworkBugRaptors
 
Junit4&testng presentation
Junit4&testng presentationJunit4&testng presentation
Junit4&testng presentationSanjib Dhar
 
TestNG vs JUnit: cease fire or the end of the war
TestNG vs JUnit: cease fire or the end of the warTestNG vs JUnit: cease fire or the end of the war
TestNG vs JUnit: cease fire or the end of the warOleksiy Rezchykov
 
TestNG - The Next Generation of Unit Testing
TestNG - The Next Generation of Unit TestingTestNG - The Next Generation of Unit Testing
TestNG - The Next Generation of Unit TestingBethmi Gunasekara
 
TestNG Annotations in Selenium | Edureka
TestNG Annotations in Selenium | EdurekaTestNG Annotations in Selenium | Edureka
TestNG Annotations in Selenium | EdurekaEdureka!
 
Selenium with testng and eclipse ide
Selenium with testng and eclipse ideSelenium with testng and eclipse ide
Selenium with testng and eclipse ideTestertester Jaipur
 
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and MockitoAn Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockitoshaunthomas999
 
JUnit 5 - The Next Generation of JUnit - Ted's Tool Time
JUnit 5 - The Next Generation of JUnit - Ted's Tool TimeJUnit 5 - The Next Generation of JUnit - Ted's Tool Time
JUnit 5 - The Next Generation of JUnit - Ted's Tool TimeTed Vinke
 
Maven TestNg frame work (1) (1)
Maven TestNg frame work (1) (1)Maven TestNg frame work (1) (1)
Maven TestNg frame work (1) (1)Gopi Raghavendra
 

What's hot (20)

Introduction of TestNG framework and its benefits over Junit framework
Introduction of TestNG framework and its benefits over Junit frameworkIntroduction of TestNG framework and its benefits over Junit framework
Introduction of TestNG framework and its benefits over Junit framework
 
TestNG
TestNGTestNG
TestNG
 
Junit4&testng presentation
Junit4&testng presentationJunit4&testng presentation
Junit4&testng presentation
 
TestNG vs JUnit: cease fire or the end of the war
TestNG vs JUnit: cease fire or the end of the warTestNG vs JUnit: cease fire or the end of the war
TestNG vs JUnit: cease fire or the end of the war
 
TestNG vs. JUnit4
TestNG vs. JUnit4TestNG vs. JUnit4
TestNG vs. JUnit4
 
testng
testngtestng
testng
 
TestNG Framework
TestNG Framework TestNG Framework
TestNG Framework
 
Junit and testNG
Junit and testNGJunit and testNG
Junit and testNG
 
TestNG - The Next Generation of Unit Testing
TestNG - The Next Generation of Unit TestingTestNG - The Next Generation of Unit Testing
TestNG - The Next Generation of Unit Testing
 
TestNG Annotations in Selenium | Edureka
TestNG Annotations in Selenium | EdurekaTestNG Annotations in Selenium | Edureka
TestNG Annotations in Selenium | Edureka
 
TestNG Data Binding
TestNG Data BindingTestNG Data Binding
TestNG Data Binding
 
Selenium TestNG
Selenium TestNGSelenium TestNG
Selenium TestNG
 
Test ng
Test ngTest ng
Test ng
 
Selenium with java
Selenium with javaSelenium with java
Selenium with java
 
TestNG vs Junit
TestNG vs JunitTestNG vs Junit
TestNG vs Junit
 
Selenium with testng and eclipse ide
Selenium with testng and eclipse ideSelenium with testng and eclipse ide
Selenium with testng and eclipse ide
 
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and MockitoAn Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
An Introduction to JUnit 5 and how to use it with Spring boot tests and Mockito
 
JUnit 5 - The Next Generation of JUnit - Ted's Tool Time
JUnit 5 - The Next Generation of JUnit - Ted's Tool TimeJUnit 5 - The Next Generation of JUnit - Ted's Tool Time
JUnit 5 - The Next Generation of JUnit - Ted's Tool Time
 
Maven TestNg frame work (1) (1)
Maven TestNg frame work (1) (1)Maven TestNg frame work (1) (1)
Maven TestNg frame work (1) (1)
 
Junit
JunitJunit
Junit
 

Viewers also liked

Automation Testing using Selenium
Automation Testing using SeleniumAutomation Testing using Selenium
Automation Testing using SeleniumNaresh Chintalcheru
 
Testing RESTful Webservices using the REST-assured framework
Testing RESTful Webservices using the REST-assured frameworkTesting RESTful Webservices using the REST-assured framework
Testing RESTful Webservices using the REST-assured frameworkMicha Kops
 
2015-StarWest presentation on REST-assured
2015-StarWest presentation on REST-assured2015-StarWest presentation on REST-assured
2015-StarWest presentation on REST-assuredEing Ong
 
Using Selenium 3 0
Using Selenium 3 0Using Selenium 3 0
Using Selenium 3 0TEST Huddle
 
REST API testing with SpecFlow
REST API testing with SpecFlowREST API testing with SpecFlow
REST API testing with SpecFlowAiste Stikliute
 
Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...
Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...
Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...Edureka!
 
Selenium Basics Tutorial
Selenium Basics TutorialSelenium Basics Tutorial
Selenium Basics TutorialClever Moe
 
Test automation Frame Works
Test automation Frame WorksTest automation Frame Works
Test automation Frame WorksvodQA
 
Stand up
Stand upStand up
Stand upvodQA
 

Viewers also liked (15)

Automation Testing using Selenium
Automation Testing using SeleniumAutomation Testing using Selenium
Automation Testing using Selenium
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 
Selenium Overview
Selenium OverviewSelenium Overview
Selenium Overview
 
Testing RESTful Webservices using the REST-assured framework
Testing RESTful Webservices using the REST-assured frameworkTesting RESTful Webservices using the REST-assured framework
Testing RESTful Webservices using the REST-assured framework
 
2015-StarWest presentation on REST-assured
2015-StarWest presentation on REST-assured2015-StarWest presentation on REST-assured
2015-StarWest presentation on REST-assured
 
Rest assured
Rest assuredRest assured
Rest assured
 
BDD for APIs
BDD for APIsBDD for APIs
BDD for APIs
 
Using Selenium 3 0
Using Selenium 3 0Using Selenium 3 0
Using Selenium 3 0
 
REST API testing with SpecFlow
REST API testing with SpecFlowREST API testing with SpecFlow
REST API testing with SpecFlow
 
10 Benefits of Automated Testing
10 Benefits of Automated Testing10 Benefits of Automated Testing
10 Benefits of Automated Testing
 
Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...
Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...
Selenium Tutorial For Beginners | What Is Selenium? | Selenium Automation Tes...
 
Automation Testing by Selenium Web Driver
Automation Testing by Selenium Web DriverAutomation Testing by Selenium Web Driver
Automation Testing by Selenium Web Driver
 
Selenium Basics Tutorial
Selenium Basics TutorialSelenium Basics Tutorial
Selenium Basics Tutorial
 
Test automation Frame Works
Test automation Frame WorksTest automation Frame Works
Test automation Frame Works
 
Stand up
Stand upStand up
Stand up
 

Similar to Test ng for testers

Unit testing php-unit - phing - selenium_v2
Unit testing   php-unit - phing - selenium_v2Unit testing   php-unit - phing - selenium_v2
Unit testing php-unit - phing - selenium_v2Tricode (part of Dept)
 
Dev labs alliance top 20 testng interview questions for sdet
Dev labs alliance top 20 testng interview questions for sdetDev labs alliance top 20 testng interview questions for sdet
Dev labs alliance top 20 testng interview questions for sdetdevlabsalliance
 
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!Puneet Kala
 
JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkOnkar Deshpande
 
Lesson_06_Software_and_Automation_Testing_Frameworks.pdf
Lesson_06_Software_and_Automation_Testing_Frameworks.pdfLesson_06_Software_and_Automation_Testing_Frameworks.pdf
Lesson_06_Software_and_Automation_Testing_Frameworks.pdfMinh Quân Đoàn
 
Continuous Test Automation, by Richard Langlois P. Eng. and Yuri Pechenko.
Continuous Test Automation, by Richard Langlois P. Eng. and Yuri Pechenko.Continuous Test Automation, by Richard Langlois P. Eng. and Yuri Pechenko.
Continuous Test Automation, by Richard Langlois P. Eng. and Yuri Pechenko.Richard Langlois P. Eng.
 
Testing And Drupal
Testing And DrupalTesting And Drupal
Testing And DrupalPeter Arato
 
Introduction to JUnit testing in OpenDaylight
Introduction to JUnit testing in OpenDaylightIntroduction to JUnit testing in OpenDaylight
Introduction to JUnit testing in OpenDaylightOpenDaylight
 
JahiaOne 2015 - How to automatically unit and integration test your Digital F...
JahiaOne 2015 - How to automatically unit and integration test your Digital F...JahiaOne 2015 - How to automatically unit and integration test your Digital F...
JahiaOne 2015 - How to automatically unit and integration test your Digital F...Jahia Solutions Group
 
Automated Testing on Web Applications
Automated Testing on Web ApplicationsAutomated Testing on Web Applications
Automated Testing on Web ApplicationsSamuel Borg
 
03 test specification and execution
03   test specification and execution03   test specification and execution
03 test specification and executionClemens Reijnen
 

Similar to Test ng for testers (20)

Unit testing php-unit - phing - selenium_v2
Unit testing   php-unit - phing - selenium_v2Unit testing   php-unit - phing - selenium_v2
Unit testing php-unit - phing - selenium_v2
 
Dev labs alliance top 20 testng interview questions for sdet
Dev labs alliance top 20 testng interview questions for sdetDev labs alliance top 20 testng interview questions for sdet
Dev labs alliance top 20 testng interview questions for sdet
 
New selenium rc
New selenium rcNew selenium rc
New selenium rc
 
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
Selenium-Webdriver With PHPUnit Automation test for Joomla CMS!
 
JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing Framework
 
Lesson_06_Software_and_Automation_Testing_Frameworks.pdf
Lesson_06_Software_and_Automation_Testing_Frameworks.pdfLesson_06_Software_and_Automation_Testing_Frameworks.pdf
Lesson_06_Software_and_Automation_Testing_Frameworks.pdf
 
Continuous Test Automation, by Richard Langlois P. Eng. and Yuri Pechenko.
Continuous Test Automation, by Richard Langlois P. Eng. and Yuri Pechenko.Continuous Test Automation, by Richard Langlois P. Eng. and Yuri Pechenko.
Continuous Test Automation, by Richard Langlois P. Eng. and Yuri Pechenko.
 
Testing And Drupal
Testing And DrupalTesting And Drupal
Testing And Drupal
 
Junit_.pptx
Junit_.pptxJunit_.pptx
Junit_.pptx
 
Introduction to JUnit testing in OpenDaylight
Introduction to JUnit testing in OpenDaylightIntroduction to JUnit testing in OpenDaylight
Introduction to JUnit testing in OpenDaylight
 
Introduction to JUnit
Introduction to JUnitIntroduction to JUnit
Introduction to JUnit
 
Testing with Junit4
Testing with Junit4Testing with Junit4
Testing with Junit4
 
JahiaOne 2015 - How to automatically unit and integration test your Digital F...
JahiaOne 2015 - How to automatically unit and integration test your Digital F...JahiaOne 2015 - How to automatically unit and integration test your Digital F...
JahiaOne 2015 - How to automatically unit and integration test your Digital F...
 
Presentation
PresentationPresentation
Presentation
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Application Testing
Application TestingApplication Testing
Application Testing
 
Testing In Java
Testing In JavaTesting In Java
Testing In Java
 
Testing In Java4278
Testing In Java4278Testing In Java4278
Testing In Java4278
 
Automated Testing on Web Applications
Automated Testing on Web ApplicationsAutomated Testing on Web Applications
Automated Testing on Web Applications
 
03 test specification and execution
03   test specification and execution03   test specification and execution
03 test specification and execution
 

Test ng for testers

  • 1. www.pragmatictestlabs.com/ janesh@pragmatictesters.com +94 71 873 2025 Next Selenium Training is starting from 30th March 2014 : Batch # : 2014-4
  • 2. TestNG for Testers - by Pragmatic Testers Reference
  • 3. The Creator of TestNG Cédric Beust is a French software engineer and a software technology author. He is the co-author of two books and the creator of the TestNG Java testing framework In 2004, he created TestNG an open source Java testing framework that has seen a lot of adoption, especially in the web testing area. He is still actively working on the framework on his spare time to support the community. I maintain both the TestNG core and its Eclipse plug-in
  • 4. Features of TestNG Annotations Run Tests in Big Thread Pools Flexible Test Configuration Support for Data Driven Testing Support for Parameters Powerful Execution Model - (TestSuite) Supported by variety of tools and Plugins source : http://testng.org/doc/index.html
  • 6. Three Step Process Write the test script and insert TestNG annotations Add the information about your test in a testng.xml file (e.g. the class name, the groups you wish to run, etc.) Run TestNG
  • 7. First Test Script public class SimpleTest { @BeforeClass public void beforeClass() { // code that will be invoked when this test is instantiated } @Test(groups = { "fast" }) public void aFastTest() { System.out.println("This is a fast test"); } @Test(groups = { "slow" }) public void aSlowTest() { System.out.println("This is a slow test"); } }
  • 8. Invoke the Test Script <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > <suite name="Suite1" verbose="1" > <test name="Test1"> <groups> <run> <include name="fast"/> </run> </groups> <classes> <class name="selenium.testng.example.SimpleTest"/> </classes> </test> </suite>
  • 12. Parameters Test methods can have parameters Can use any number of parameters in Test methods Pass parameters using @Parameters From testing.xml : For simple values With DataProviders : For complex parameters
  • 13. Parameters with testing.xml @Parameters({ "first-name" }) @Test public void testSingleString(String firstName) { System.out.println("Invoked testString " + firstName); assert "Cedric".equals(firstName); } <suite name="My suite"> <parameter name="first-name" value="Cedric"/> <test name="Simple example"> <-- ... -->
  • 14. Parameters with @DataProvider //This method will provide data to any test method that declares that its Data Provider //is named "test1" @DataProvider(name = "test1") public Object[][] createData1() { return new Object[][] { { "Cedric", new Integer(36) }, { "Anne", new Integer(37)}, }; } //This test method declares that its data should be supplied by the Data Provider //named "test1" @Test(dataProvider = "test1") public void verifyData1(String n1, Integer n2) { System.out.println(n1 + " " + n2); }
  • 15. DataProvider in Different Class public class StaticProvider { @DataProvider(name = "create") public static Object[][] createData() { return new Object[][] { new Object[] { new Integer(42) } } } } public class MyTest { @Test(dataProvider = "create", dataProviderClass = StaticProvider.class) public void test(Integer n) { // ... } }
  • 16. Data Driven Testing Data-Driven testing generally means executing a set of steps with multiple sets of data. Selenium does not provide any out-of-the box solution for data driven testing but leaves it up to the user to implement this on his own. TestNG is a framework that makes data-driven testing possible in selenium. TestNG is a testing framework created in line with Junit but with added features that makes it suitable for use in regression test automation projects. source : http://functionaltestautomation.blogspot.com/2009/10/dataprovider-data-driven-testing-with.html
  • 17. Dependancies Invoking Test Methods in certain order With Annotations Hard Dependencies : Must run and succeed Soft Dependencies : Add alwaysRun=”true” to @Test With XML <test name="My suite"> <groups> <dependencies> <group name="c" depends-on="a b" /> <group name="z" depends-on="c" /> </dependencies> </groups> </test>
  • 18. Running Failed Tests TestNG creates a testng-failed.xml in output directory Contains failed methods Allows to re-run the failed tests Can reproduce the failures and verify fixes quickly
  • 19. TestNG and Selenium @BeforeSuite(alwaysRun = true) public void setupBeforeSuite(ITestContext context) { String driverPropertyName = context.getCurrentXmlTest().getParameter("driver.property.name"); String driverPath = context.getCurrentXmlTest().getParameter("driver.path"); String browserType = context.getCurrentXmlTest().getParameter("browser.type"); String baseURL = context.getCurrentXmlTest().getParameter("base.url"); if (browserType == null) { driver = new HtmlUnitDriver(); } else if (browserType.equalsIgnoreCase("Firefox")) { driver = new FirefoxDriver(); } else if (browserType.equalsIgnoreCase("Chrome")) { System.setProperty(driverPropertyName,driverPath); driver = new ChromeDriver(); } //For other browsers logger.info("BROWSER_TYPE=" + BROWSER_TYPE); driver.manage().window().maximize(); driver.manage().timeouts().implicitlyWait(TIME_OUT, TimeUnit.SECONDS); } <parameter name="browser.type" value="Chrome" />
  • 20. TestNG Assertions Assert.assertEquals(Actual, Expected) Assert.assertEquals(Actual, Expected, Message) Assert.assertEqualsNoOrder(Actual, Expected) Assert.assertFalse(Actual) Assert.assertNotEquals(Actual1, Actual2, Delta) Assert.assertSame(Actual, Expected) Assert.fail(Message)
  • 23. Books
  • 24. Videos : Data Driven Testing
  • 25. Tutorials TestNG Tutorial by MKYong Testing Tutorials - Search for TestNG tutorial Tutorials Point
  • 26. Pragmatic Test Labs Thank You ! www.pragmatictestlabs.com