SlideShare a Scribd company logo
1 of 29
TestNG Framework for
Extensive Testing and TDD
Next Generation Testing, TestNG - Testing Tool
Narendran Solai Sridharan
19-Feb-2014
Table of Contents
 TestNG Features & Benefits
 TestNG Installation
 TestNG Demo
 JUnit vs TestNG
 TestNG - Links
TestNG Overview
Features
 TestNG is a testing framework inspired by JUnit and NUnit
 Designed to cover all categories of tests: unit, functional, end-to-end, integration etc.,
 Designed to perform Multi threaded testing, to help in load and stress testing.
 Designed to Group Test Scripts and run them selectively.
 Designed to run test scripts based on dependencies & failures.
 Designed to check module performance such as response time with test timeouts.
 Has a flexible plugin API for report creation and for even changing core behavior.
Benefits
 Overcomes the drawbacks of JUNIT Framework.
 One Stop Shop for various kinds of testing.
 Dependency testing, grouping concept to make testing more powerful and easy.
 Thins the gaps between Development and Testing and encourages Test Driven Development (TDD).
 Combined use of several TestNG's features provides a very intuitive and maintainable testing design.
 Easy Migration from JUNIT to TestNG.
 Easy Integration with framework & tools like Spring, Selenium, Guice, Jenkins etc.
 Easy Reporting
TestNG Installation
Pre-Requisite
 Mandatory: JDK 1.5 & above & TestNG Jar
 Optional: TestNG Plugin for Eclipse (any version)
 Optional: Maven (any version)
 Optional: JUNIT Jar, if JUNIT test cases to be run by TestNG.
Types of Installation
1. TestNG as Eclipse Plugin
2. TestNG as Maven Dependency
3. TestNG as Class Path Jar
Maven Dependency
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8.6</version>
<scope>test</scope>
</dependency>
TestNG - Demo
1. TestNG XML & YAML Configuration
2. TestNG – “Rhythms of Testing” with Annotations.
3. TestNG – Groups
4. TestNG – Dependency
5. TestNG – Parameters, Data Provider & Factory
6. TestNG – Parallel Execution & Time Outs
7. TestNG – Exception Capture
8. TestNG – JUNIT Run
9. TestNG – Failure Run
10. TestNG – Report
Other Concepts not in Demo [Bean Shell and advanced
group selection, Annotation Transformers, Method
Interceptors, TestNG Listeners, Dependency injection –
Refer TestNG - Links]
TestNG XML & YAML Configuration
TestNG Yaml Configuration
TestNG XML Configuration
XML/YAML - Entry Point of TestNG
TestNG – “Rhythms of Testing” with
Annotations.
The flow / Life Cycle Methods in Test in Test NG
TestNG – Groups
Test class Grouping as a Package
Test class Grouping as a list of Classes
Test class Grouping as a list of Methods
TestNG – Groups - continued
Test class Grouping as a list of wildcard methods names
Test class Grouping as list of custom group of methods
Adding any method to a custom group
TestNG – Groups - continued
Test class Grouping as a list custom Groups with wildcards
Test class Grouping as list of Group of Groups
TestNG – Groups - continued
Test class Grouping as a Partial Group or Class Level Group
Only TestConfiguration will run
Adding any class into a group leads to partial Group
Pros of Grouping
1. Easy to create test suite / test groups based on need
2. No Compilation Required
3. Custom grouping remains independent of JAVA language literals class & package
4. Custom grouping can be heavily used for Integration testing.
Cautions
1. Grouping which are not done mutually exclusive need to be carefully done, otherwise it will
lead to confusion
2. Grouping and Dependency should go hand in hand.
TestNG – Dependency
Dependency to construct our own symphony both in order and based
on dependency
Independent Method
Hard Dependency – Maintains the order of run,
It will be skipped if the dependent method fails
Soft Dependency – Maintains the order of run,
but does not fails – run always
TestNG – Dependency -
continued
Dependency based on Groups
Pros of Dependency
1. Failure does not get propagated as test methods are skipped based on dependency
2. Dependencies between groups can be done explicitly in xml.
Cautions
1. When dependency & grouping between methods are declared with annotations & xml,
they should go hand in hand – all dependent methods should be grouped together or all
groups should include all dependent methods
Data Provider – Parameters , Data Providers &
Factories
Parameter – for simple data – String & Number, from XML
Data Providers – for complex data / Types – Objects, from Class
Provides various data sets to a test method, Static Data
Factories – for Dynamic Data both simple & Complex, from Class
Instantiates Test Classes Dynamically with different sets of data or single
set repeatedly
TestNG – Parameter
Parameters
Parameters can be provided at Suite, Test and at Class scope
Parameter Provision through XML
TestNG – Data Provider
Data Providers
TestNG – Factory
To configure / generate / create test cases dynamically
Factory – To create different instance of test Class repeatedly
Factory – with Data Provider
TestNG – Factory - continued
Factory – Constructor Factory
Pros of Data Providers
1. Can pass input / output parameters with ease
2. With Factories generation of required parameters can be done with ease
TestNG – Parallel Execution & Time
Out
More Configurations
TestNG – Exception Capture
TestNG – JUNIT Run
TestNG – Failure Run
TestNG Failed / Skipped tests are tracked, they can be run after correction,
either with IDE or with testng-failed.xml generated by Test NG
TestNG – Failure Run
TestNG Generates the reports in IDE, in the form of XML, HTML
In Eclipse IDE
TestNG – Listener & Method Interceptor
Implementation
Priority Annotation
Method Interceptor & Annotation Parser
TestNG – Listener & Method Interceptor
Implementation
Test Class with Priority annotations
Listener Configuration
JUnit vs TestNG
Feature JUnit 4 TestNG
test annotation @Test @Test
run before all tests in this suite have run – @BeforeSuite
run after all tests in this suite have run – @AfterSuite
run before the test – @BeforeTest
run after the test – @AfterTest
run before the first test method that belongs
to any of these groups is invoked
– @BeforeGroups
run after the last test method that belongs to
any of these groups is invoked
– @AfterGroups
run before the first test method in the current
class is invoked
@BeforeClass @BeforeClass
run after all the test methods in the current
class have been run
@AfterClass @AfterClass
run before each test method @Before @BeforeMethod
run after each test method @After @AfterMethod
ignore test @ignore @Test(enbale=false)
expected exception @Test(expected = ArithmeticException.class)
@Test(expectedExceptions =
ArithmeticException.class)
timeout @Test(timeout = 1000) @Test(timeout = 1000)
Continued..
Other Features present only in Test NG
 Clean Parallel Processing with Thread pools, without using
Thread class.
 Annotation Transformers, Dependency Injection, Listener for
plugging in new reporting & modifying run time test scripts
executions are present.
 To run JUNIT test cases with TestNG
 To convert JUNIT test cases into TestNG test cases.
For Simple Unit Testing it does not matter whether we use JUnit or TestNG, but
when we go for TDD, Integration & end to end testing, skipping of test cases
based on logical & fail fast dependencies & Parameterized testing, clean
Multithread testing, testing groups will help a lot.
As of now, JUnit is popular for Unit Testing, TestNG is more complete & Clean
& popular for TDD, Integration & end to end testing.
Groups vs Universes
 We can classify & group test cases as UNIT,
INTEGRATION & SMOKE and with in this
groups we could have Business functional
segregations.
 School of tests which has to be run has to be
grouped.
 Groups formed should be mutually exclusive.
 If Groups are not mutually exclusive, there
should be another group formed which
combines all non exclusive groups without
redundancy.
 A Group can have “N” no. of mutually
exclusive sub groups.
TestNG Documentation
http://testng.org/doc/documentation-main.html
TestNG Download
http://testng.org/doc/download.html
Reference Github link
https://github.com/Schools/TestNGSchool
TestNG – Links
THANKS

More Related Content

What's hot

Test Automation and Selenium
Test Automation and SeleniumTest Automation and Selenium
Test Automation and SeleniumKarapet Sarkisyan
 
Hybrid Automation Framework Development introduction
Hybrid Automation Framework Development introductionHybrid Automation Framework Development introduction
Hybrid Automation Framework Development introductionGanuka Yashantha
 
05 junit
05 junit05 junit
05 junitmha4
 
Selenium locators: ID, Name, xpath, CSS Selector advance methods
Selenium locators: ID, Name,  xpath, CSS Selector advance methodsSelenium locators: ID, Name,  xpath, CSS Selector advance methods
Selenium locators: ID, Name, xpath, CSS Selector advance methodsPankaj Dubey
 
Automated Testing with Agile
Automated Testing with AgileAutomated Testing with Agile
Automated Testing with AgileKen McCorkell
 
Xpath in Selenium | Selenium Xpath Tutorial | Selenium Xpath Examples | Selen...
Xpath in Selenium | Selenium Xpath Tutorial | Selenium Xpath Examples | Selen...Xpath in Selenium | Selenium Xpath Tutorial | Selenium Xpath Examples | Selen...
Xpath in Selenium | Selenium Xpath Tutorial | Selenium Xpath Examples | Selen...Edureka!
 
Automation - web testing with selenium
Automation - web testing with seleniumAutomation - web testing with selenium
Automation - web testing with seleniumTzirla Rozental
 
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...Simplilearn
 
Web application testing with Selenium
Web application testing with SeleniumWeb application testing with Selenium
Web application testing with SeleniumKerry Buckley
 
katalon studio 툴을 이용한 GUI 테스트 자동화 가이드
katalon studio 툴을 이용한 GUI 테스트 자동화 가이드katalon studio 툴을 이용한 GUI 테스트 자동화 가이드
katalon studio 툴을 이용한 GUI 테스트 자동화 가이드SangIn Choung
 
Unit Testing in Angular
Unit Testing in AngularUnit Testing in Angular
Unit Testing in AngularKnoldus Inc.
 

What's hot (20)

TestNG with selenium
TestNG with seleniumTestNG with selenium
TestNG with selenium
 
Selenium-Locators
Selenium-LocatorsSelenium-Locators
Selenium-Locators
 
Selenium Primer
Selenium PrimerSelenium Primer
Selenium Primer
 
Selenium IDE LOCATORS
Selenium IDE LOCATORSSelenium IDE LOCATORS
Selenium IDE LOCATORS
 
Test Automation and Selenium
Test Automation and SeleniumTest Automation and Selenium
Test Automation and Selenium
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 
Hybrid Automation Framework Development introduction
Hybrid Automation Framework Development introductionHybrid Automation Framework Development introduction
Hybrid Automation Framework Development introduction
 
Selenium web driver
Selenium web driverSelenium web driver
Selenium web driver
 
05 junit
05 junit05 junit
05 junit
 
QSpiders - Automation using Selenium
QSpiders - Automation using SeleniumQSpiders - Automation using Selenium
QSpiders - Automation using Selenium
 
Selenium locators: ID, Name, xpath, CSS Selector advance methods
Selenium locators: ID, Name,  xpath, CSS Selector advance methodsSelenium locators: ID, Name,  xpath, CSS Selector advance methods
Selenium locators: ID, Name, xpath, CSS Selector advance methods
 
Test automation using selenium
Test automation using seleniumTest automation using selenium
Test automation using selenium
 
Automated Testing with Agile
Automated Testing with AgileAutomated Testing with Agile
Automated Testing with Agile
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 
Xpath in Selenium | Selenium Xpath Tutorial | Selenium Xpath Examples | Selen...
Xpath in Selenium | Selenium Xpath Tutorial | Selenium Xpath Examples | Selen...Xpath in Selenium | Selenium Xpath Tutorial | Selenium Xpath Examples | Selen...
Xpath in Selenium | Selenium Xpath Tutorial | Selenium Xpath Examples | Selen...
 
Automation - web testing with selenium
Automation - web testing with seleniumAutomation - web testing with selenium
Automation - web testing with selenium
 
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
What Is Selenium? | Selenium Basics For Beginners | Introduction To Selenium ...
 
Web application testing with Selenium
Web application testing with SeleniumWeb application testing with Selenium
Web application testing with Selenium
 
katalon studio 툴을 이용한 GUI 테스트 자동화 가이드
katalon studio 툴을 이용한 GUI 테스트 자동화 가이드katalon studio 툴을 이용한 GUI 테스트 자동화 가이드
katalon studio 툴을 이용한 GUI 테스트 자동화 가이드
 
Unit Testing in Angular
Unit Testing in AngularUnit Testing in Angular
Unit Testing in Angular
 

Viewers also liked

TestNG introduction
TestNG introductionTestNG introduction
TestNG introductionDenis Bazhin
 
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
 
Automation Testing using Selenium
Automation Testing using SeleniumAutomation Testing using Selenium
Automation Testing using SeleniumNaresh Chintalcheru
 
Hybrid Automation Framework
Hybrid Automation FrameworkHybrid Automation Framework
Hybrid Automation FrameworkASHIRVAD MISHRA
 
Junit4&testng presentation
Junit4&testng presentationJunit4&testng presentation
Junit4&testng presentationSanjib Dhar
 
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!
 

Viewers also liked (20)

Test ng for testers
Test ng for testersTest ng for testers
Test ng for testers
 
TestNG introduction
TestNG introductionTestNG introduction
TestNG introduction
 
TestNg_Overview_Config
TestNg_Overview_ConfigTestNg_Overview_Config
TestNg_Overview_Config
 
Test ng tutorial
Test ng tutorialTest ng tutorial
Test ng tutorial
 
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
 
Selenium ppt
Selenium pptSelenium ppt
Selenium ppt
 
Test ng
Test ngTest ng
Test ng
 
Junit and testNG
Junit and testNGJunit and testNG
Junit and testNG
 
Automation Testing using Selenium
Automation Testing using SeleniumAutomation Testing using Selenium
Automation Testing using Selenium
 
Hybrid Automation Framework
Hybrid Automation FrameworkHybrid Automation Framework
Hybrid Automation Framework
 
TestNG vs. JUnit4
TestNG vs. JUnit4TestNG vs. JUnit4
TestNG vs. JUnit4
 
Junit4&testng presentation
Junit4&testng presentationJunit4&testng presentation
Junit4&testng presentation
 
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
 
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
 

Similar to Test NG Framework Complete Walk Through

JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkOnkar Deshpande
 
Top 20 Junit interview questions for sdet
Top 20 Junit interview questions for sdetTop 20 Junit interview questions for sdet
Top 20 Junit interview questions for sdetDevLabs Alliance
 
Unit Testing & TDD Training for Mobile Apps
Unit Testing & TDD Training for Mobile AppsUnit Testing & TDD Training for Mobile Apps
Unit Testing & TDD Training for Mobile AppsMarcelo Busico
 
20070514 introduction to test ng and its application for test driven gui deve...
20070514 introduction to test ng and its application for test driven gui deve...20070514 introduction to test ng and its application for test driven gui deve...
20070514 introduction to test ng and its application for test driven gui deve...Will Shen
 
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
 
IT talk: Как я перестал бояться и полюбил TestNG
IT talk: Как я перестал бояться и полюбил TestNGIT talk: Как я перестал бояться и полюбил TestNG
IT talk: Как я перестал бояться и полюбил TestNGDataArt
 
Automation testing
Automation testingAutomation testing
Automation testingTomy Rhymond
 
UNIT TESTING PPT
UNIT TESTING PPTUNIT TESTING PPT
UNIT TESTING PPTsuhasreddy1
 
Implementing TDD in for .net Core applications
Implementing TDD in for .net Core applicationsImplementing TDD in for .net Core applications
Implementing TDD in for .net Core applicationsAhmad Kazemi
 
Unit testing using Munit Part 1
Unit testing using Munit Part 1Unit testing using Munit Part 1
Unit testing using Munit Part 1Anand kalla
 
Unit Testing Fundamentals
Unit Testing FundamentalsUnit Testing Fundamentals
Unit Testing FundamentalsRichard Paul
 
Introduction to Unit Testing for Mule Flows using Munit(Java) - Part 1
Introduction to Unit Testing for Mule Flows using Munit(Java) - Part 1Introduction to Unit Testing for Mule Flows using Munit(Java) - Part 1
Introduction to Unit Testing for Mule Flows using Munit(Java) - Part 1Alex Fernandez
 
Mykola Kovsh - Functional API automation with Jmeter
Mykola Kovsh - Functional API automation with JmeterMykola Kovsh - Functional API automation with Jmeter
Mykola Kovsh - Functional API automation with JmeterIevgenii Katsan
 
The Ultimate Guide to Java Testing Frameworks.pdf
The Ultimate Guide to Java Testing Frameworks.pdfThe Ultimate Guide to Java Testing Frameworks.pdf
The Ultimate Guide to Java Testing Frameworks.pdfUncodemy
 
Simple test drupal7_presentation_la_drupal_jul21-2010
Simple test drupal7_presentation_la_drupal_jul21-2010Simple test drupal7_presentation_la_drupal_jul21-2010
Simple test drupal7_presentation_la_drupal_jul21-2010Miguel Hernandez
 
Performance testing and_reporting_with_j_meter by Le Van Nghi
Performance testing and_reporting_with_j_meter by  Le Van NghiPerformance testing and_reporting_with_j_meter by  Le Van Nghi
Performance testing and_reporting_with_j_meter by Le Van NghieXo Platform
 
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)
 
How To Use Ignore Annotation In JUnit
How To Use Ignore Annotation In JUnitHow To Use Ignore Annotation In JUnit
How To Use Ignore Annotation In JUnitBugRaptors
 

Similar to Test NG Framework Complete Walk Through (20)

JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing Framework
 
Top 20 Junit interview questions for sdet
Top 20 Junit interview questions for sdetTop 20 Junit interview questions for sdet
Top 20 Junit interview questions for sdet
 
Unit Testing & TDD Training for Mobile Apps
Unit Testing & TDD Training for Mobile AppsUnit Testing & TDD Training for Mobile Apps
Unit Testing & TDD Training for Mobile Apps
 
20070514 introduction to test ng and its application for test driven gui deve...
20070514 introduction to test ng and its application for test driven gui deve...20070514 introduction to test ng and its application for test driven gui deve...
20070514 introduction to test ng and its application for test driven gui deve...
 
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
 
IT talk: Как я перестал бояться и полюбил TestNG
IT talk: Как я перестал бояться и полюбил TestNGIT talk: Как я перестал бояться и полюбил TestNG
IT talk: Как я перестал бояться и полюбил TestNG
 
Automation testing
Automation testingAutomation testing
Automation testing
 
UNIT TESTING PPT
UNIT TESTING PPTUNIT TESTING PPT
UNIT TESTING PPT
 
Implementing TDD in for .net Core applications
Implementing TDD in for .net Core applicationsImplementing TDD in for .net Core applications
Implementing TDD in for .net Core applications
 
Unit testing using Munit Part 1
Unit testing using Munit Part 1Unit testing using Munit Part 1
Unit testing using Munit Part 1
 
New selenium rc
New selenium rcNew selenium rc
New selenium rc
 
Unit Testing Fundamentals
Unit Testing FundamentalsUnit Testing Fundamentals
Unit Testing Fundamentals
 
Introduction to Unit Testing for Mule Flows using Munit(Java) - Part 1
Introduction to Unit Testing for Mule Flows using Munit(Java) - Part 1Introduction to Unit Testing for Mule Flows using Munit(Java) - Part 1
Introduction to Unit Testing for Mule Flows using Munit(Java) - Part 1
 
Mykola Kovsh - Functional API automation with Jmeter
Mykola Kovsh - Functional API automation with JmeterMykola Kovsh - Functional API automation with Jmeter
Mykola Kovsh - Functional API automation with Jmeter
 
The Ultimate Guide to Java Testing Frameworks.pdf
The Ultimate Guide to Java Testing Frameworks.pdfThe Ultimate Guide to Java Testing Frameworks.pdf
The Ultimate Guide to Java Testing Frameworks.pdf
 
Simple test drupal7_presentation_la_drupal_jul21-2010
Simple test drupal7_presentation_la_drupal_jul21-2010Simple test drupal7_presentation_la_drupal_jul21-2010
Simple test drupal7_presentation_la_drupal_jul21-2010
 
Quality for developers
Quality for developersQuality for developers
Quality for developers
 
Performance testing and_reporting_with_j_meter by Le Van Nghi
Performance testing and_reporting_with_j_meter by  Le Van NghiPerformance testing and_reporting_with_j_meter by  Le Van Nghi
Performance testing and_reporting_with_j_meter by Le Van Nghi
 
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
 
How To Use Ignore Annotation In JUnit
How To Use Ignore Annotation In JUnitHow To Use Ignore Annotation In JUnit
How To Use Ignore Annotation In JUnit
 

More from Narendran Solai Sridharan (9)

Java module configuration
Java module configurationJava module configuration
Java module configuration
 
Introduction to Web Components
Introduction to Web ComponentsIntroduction to Web Components
Introduction to Web Components
 
Thinking tools for value innovation
Thinking tools for value innovationThinking tools for value innovation
Thinking tools for value innovation
 
Domain driven design - Part I
Domain driven design - Part IDomain driven design - Part I
Domain driven design - Part I
 
Raspberry pi and pi4j
Raspberry pi and pi4jRaspberry pi and pi4j
Raspberry pi and pi4j
 
Functional Programming in Java
Functional Programming in JavaFunctional Programming in Java
Functional Programming in Java
 
Http 2
Http 2Http 2
Http 2
 
Introduction to value types
Introduction to value typesIntroduction to value types
Introduction to value types
 
Upfront adoption & migration of applications to latest jdk
Upfront adoption & migration of applications to latest jdkUpfront adoption & migration of applications to latest jdk
Upfront adoption & migration of applications to latest jdk
 

Recently uploaded

[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 

Recently uploaded (20)

[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 

Test NG Framework Complete Walk Through

  • 1. TestNG Framework for Extensive Testing and TDD Next Generation Testing, TestNG - Testing Tool Narendran Solai Sridharan 19-Feb-2014
  • 2. Table of Contents  TestNG Features & Benefits  TestNG Installation  TestNG Demo  JUnit vs TestNG  TestNG - Links
  • 3. TestNG Overview Features  TestNG is a testing framework inspired by JUnit and NUnit  Designed to cover all categories of tests: unit, functional, end-to-end, integration etc.,  Designed to perform Multi threaded testing, to help in load and stress testing.  Designed to Group Test Scripts and run them selectively.  Designed to run test scripts based on dependencies & failures.  Designed to check module performance such as response time with test timeouts.  Has a flexible plugin API for report creation and for even changing core behavior. Benefits  Overcomes the drawbacks of JUNIT Framework.  One Stop Shop for various kinds of testing.  Dependency testing, grouping concept to make testing more powerful and easy.  Thins the gaps between Development and Testing and encourages Test Driven Development (TDD).  Combined use of several TestNG's features provides a very intuitive and maintainable testing design.  Easy Migration from JUNIT to TestNG.  Easy Integration with framework & tools like Spring, Selenium, Guice, Jenkins etc.  Easy Reporting
  • 4. TestNG Installation Pre-Requisite  Mandatory: JDK 1.5 & above & TestNG Jar  Optional: TestNG Plugin for Eclipse (any version)  Optional: Maven (any version)  Optional: JUNIT Jar, if JUNIT test cases to be run by TestNG. Types of Installation 1. TestNG as Eclipse Plugin 2. TestNG as Maven Dependency 3. TestNG as Class Path Jar Maven Dependency <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.8.6</version> <scope>test</scope> </dependency>
  • 5. TestNG - Demo 1. TestNG XML & YAML Configuration 2. TestNG – “Rhythms of Testing” with Annotations. 3. TestNG – Groups 4. TestNG – Dependency 5. TestNG – Parameters, Data Provider & Factory 6. TestNG – Parallel Execution & Time Outs 7. TestNG – Exception Capture 8. TestNG – JUNIT Run 9. TestNG – Failure Run 10. TestNG – Report Other Concepts not in Demo [Bean Shell and advanced group selection, Annotation Transformers, Method Interceptors, TestNG Listeners, Dependency injection – Refer TestNG - Links]
  • 6. TestNG XML & YAML Configuration TestNG Yaml Configuration TestNG XML Configuration XML/YAML - Entry Point of TestNG
  • 7. TestNG – “Rhythms of Testing” with Annotations. The flow / Life Cycle Methods in Test in Test NG
  • 8. TestNG – Groups Test class Grouping as a Package Test class Grouping as a list of Classes Test class Grouping as a list of Methods
  • 9. TestNG – Groups - continued Test class Grouping as a list of wildcard methods names Test class Grouping as list of custom group of methods Adding any method to a custom group
  • 10. TestNG – Groups - continued Test class Grouping as a list custom Groups with wildcards Test class Grouping as list of Group of Groups
  • 11. TestNG – Groups - continued Test class Grouping as a Partial Group or Class Level Group Only TestConfiguration will run Adding any class into a group leads to partial Group Pros of Grouping 1. Easy to create test suite / test groups based on need 2. No Compilation Required 3. Custom grouping remains independent of JAVA language literals class & package 4. Custom grouping can be heavily used for Integration testing. Cautions 1. Grouping which are not done mutually exclusive need to be carefully done, otherwise it will lead to confusion 2. Grouping and Dependency should go hand in hand.
  • 12. TestNG – Dependency Dependency to construct our own symphony both in order and based on dependency Independent Method Hard Dependency – Maintains the order of run, It will be skipped if the dependent method fails Soft Dependency – Maintains the order of run, but does not fails – run always
  • 13. TestNG – Dependency - continued Dependency based on Groups Pros of Dependency 1. Failure does not get propagated as test methods are skipped based on dependency 2. Dependencies between groups can be done explicitly in xml. Cautions 1. When dependency & grouping between methods are declared with annotations & xml, they should go hand in hand – all dependent methods should be grouped together or all groups should include all dependent methods
  • 14. Data Provider – Parameters , Data Providers & Factories Parameter – for simple data – String & Number, from XML Data Providers – for complex data / Types – Objects, from Class Provides various data sets to a test method, Static Data Factories – for Dynamic Data both simple & Complex, from Class Instantiates Test Classes Dynamically with different sets of data or single set repeatedly
  • 15. TestNG – Parameter Parameters Parameters can be provided at Suite, Test and at Class scope Parameter Provision through XML
  • 16. TestNG – Data Provider Data Providers
  • 17. TestNG – Factory To configure / generate / create test cases dynamically Factory – To create different instance of test Class repeatedly Factory – with Data Provider
  • 18. TestNG – Factory - continued Factory – Constructor Factory Pros of Data Providers 1. Can pass input / output parameters with ease 2. With Factories generation of required parameters can be done with ease
  • 19. TestNG – Parallel Execution & Time Out More Configurations
  • 20. TestNG – Exception Capture TestNG – JUNIT Run
  • 21. TestNG – Failure Run TestNG Failed / Skipped tests are tracked, they can be run after correction, either with IDE or with testng-failed.xml generated by Test NG
  • 22. TestNG – Failure Run TestNG Generates the reports in IDE, in the form of XML, HTML In Eclipse IDE
  • 23. TestNG – Listener & Method Interceptor Implementation Priority Annotation Method Interceptor & Annotation Parser
  • 24. TestNG – Listener & Method Interceptor Implementation Test Class with Priority annotations Listener Configuration
  • 25. JUnit vs TestNG Feature JUnit 4 TestNG test annotation @Test @Test run before all tests in this suite have run – @BeforeSuite run after all tests in this suite have run – @AfterSuite run before the test – @BeforeTest run after the test – @AfterTest run before the first test method that belongs to any of these groups is invoked – @BeforeGroups run after the last test method that belongs to any of these groups is invoked – @AfterGroups run before the first test method in the current class is invoked @BeforeClass @BeforeClass run after all the test methods in the current class have been run @AfterClass @AfterClass run before each test method @Before @BeforeMethod run after each test method @After @AfterMethod ignore test @ignore @Test(enbale=false) expected exception @Test(expected = ArithmeticException.class) @Test(expectedExceptions = ArithmeticException.class) timeout @Test(timeout = 1000) @Test(timeout = 1000)
  • 26. Continued.. Other Features present only in Test NG  Clean Parallel Processing with Thread pools, without using Thread class.  Annotation Transformers, Dependency Injection, Listener for plugging in new reporting & modifying run time test scripts executions are present.  To run JUNIT test cases with TestNG  To convert JUNIT test cases into TestNG test cases. For Simple Unit Testing it does not matter whether we use JUnit or TestNG, but when we go for TDD, Integration & end to end testing, skipping of test cases based on logical & fail fast dependencies & Parameterized testing, clean Multithread testing, testing groups will help a lot. As of now, JUnit is popular for Unit Testing, TestNG is more complete & Clean & popular for TDD, Integration & end to end testing.
  • 27. Groups vs Universes  We can classify & group test cases as UNIT, INTEGRATION & SMOKE and with in this groups we could have Business functional segregations.  School of tests which has to be run has to be grouped.  Groups formed should be mutually exclusive.  If Groups are not mutually exclusive, there should be another group formed which combines all non exclusive groups without redundancy.  A Group can have “N” no. of mutually exclusive sub groups.

Editor's Notes

  1. In Junit there is no grouping concept. All these grouping can be done in JUNIT but it has to done in JAVA Code and need to be maintained manually.
  2. In JUNIT, there is no test dependency Concept, every test dependency should be hardcoded in JAVA (by method calls) or by Dependency Injection (only for objects) in case if it is an UNIT Test cases Test dependencies are not JAVA type(class) dependencies. Types of Dependencies Based on Hierarchy Class level – Importing Types, fields, methods Method level – Method calls, method parameter, return type Package level – Based on class level Types of Dependency Injection Setter Interface Constructor Lookup Reference
  3. Package & Class grouping can be done for UNIT Testing (Maven folder structure does it always). It is appropriate as the test cases have to be changed based on the changes done in application packages and classes. For Screen level testing Custom grouping concept can be used else packing & classification should be based on Screens – Page Object Pattern. Here based on screen changes the grouping need to be changed. Integration test case which become cross functional demands Custom grouping where package and classification will not be enough.
  4. Parameters are passed for a TEST or SUITE. In JUNIT static variables are used to for such purposes. Here it can be configured in XML if it is a simple parameter. If the parameter is complex -> Data Providers can be used. Instead of single data, Data Providers can provide a list of data.