Find the best tutors and institutes for Software Testing

Find Best Software Testing classes

Please select a Category.

Please select a Locality.

No matching category found.

No matching Locality found.

Outside India?

Search for topics

Software Testing Updates

Ask a Question

Post a Lesson

All

All

Lessons

Discussion

Lesson Posted on 24 Jul IT Courses/QA/Selenium/Selenium with Java IT Courses/QA/Automation Testing IT Courses/Software Testing

TestNG

Kiran Ayyagari

I am an Automation Engineer with experience of 4.7 years in Selenium with Java, TestNG, Cucumber framework...

TestNG Concepts TestNG: TestNG is an automation framework to run the test cases, test suites and do parallel testing. It is an advanced version of Junit. It consists of many features like annotations, groups, parameterization and listeners. It generates html reports as well which is an advanced... read more

TestNG Concepts

 

TestNG:

TestNG is an automation framework to run the test cases, test suites and do parallel testing. It is an advanced version of Junit. It consists of many features like annotations, groups, parameterization and listeners. It generates html reports as well which is an advanced feature.

 

Annotations of TestNg:

There are different types of annotations present in TestNG which are used for organized and reusable tests.

  1. @BeforeSuite: The method which has this annotation will run before all the tests in the suite runs
  2. @AfterSuite: The method which has this annotation will run after all the tests in the suite runs
  3. @BeforeTest: The method which has this annotation will run before the tests present inside the class tag of testing.xml is run
  4. @AfterTest: The method which has this annotation will run after the tests present inside the class tag of testing.xml is run
  5. @BeforeClass: The method which has this annotation will run before the first test in the class is run
  6. @AfterClass: The method which has this annotation will run after all tests in the class are run
  7. @BeforeMethod: The method which has this annotation will run before each test method runs
  8. @AfterMethod: The method which has this annotation will run after each test method runs
  9. @Test: This is the main part of the test case
  10. @DataProvider: This annotation is used to extract the data from excel and send it to all test methods.
  11. @Parameters : To take the inputs from TestNg xml

 

Example:

 

<suite name="SampleTestNGXml">

<test name="TestNGAnnotationsExample">

<parameter name="browser" value="Firefox"/>

<parameter> name=”Url” value=” https://www.google.com”

<classes>

<class name=" TestNgExample" />classes>test>suite>

 

public class TestNgExample()

{

@Parameters({“browser”})

@BeforeSuite

public void  setup(String browser){

if(browser.equlas(“Firefox”)){

WebDriver driver = new FirefoxDriver();

}

else if(browser.equals(“chrome”)){

System.setProperty(“webDriver.chrome.driver”,path);

WebDriver driver = new ChromeDriver();

 

}

else if(browser.equals(“IE”)){

System.setProperty(“webDriver.ie.driver”,path);

WebDriver driver = new InternetExplorerDriver();

}

 

}

@BeforeClass

Public void browserSetup(){

DesiredCapabilities dc = new DesiredCapabilities.firefox();

driver = new FirefoxDriver(dc);

driver.manage().timeouts().implicitlywait(60,TimeUnit.SECONDS);

driver.manage().window().setSize(new Dimension(1920,1080));

 

}

 

 

@Parameters({“Url”})

@BeforeTest

public void beforeTest(String url){

 

driver.get(url);

driver.manage().window().maximize();

}

 

@DataProvider(name = “sample”)

public object[] getData(){

return new Object[]{

{“TestNg”}}}

 

@Test(dataProvider=”sample”)

Public void minTest(String searchText){

 

WebElement searchBox = driver.findElement(By.Id(“fakebox-input”));

searchBox.sendKeys(searchText);

}

 

@AfterTest

Public void afterTest(){

System.out.println(“any reporting activities using extent Reports”);

}

 

 

@AfterClass

Public void afterClass(){

driver.close();

}

 

 

 

@AfterSuite

 

Public void teardown(){

driver.quit();

}

 

 

}

 

List of Attributes which we use in @Test method:

  • alwaysRun: If we want to run a @Test method always, we can set this attribute to true

eg: @Test(alwaysRun= true)

  • enabled: If we don’t want a @Testmethod run, we can set the enabled attribute as false

eg: @Test(enabled = false)

  • Priority: If we want to run our test cases based on priority ,we can use this attribute.

eg: @Test(Priority = 1)

  • groups: If we want to group together @Test methods, we can use this attribute

eg: @Test(groups = “smoketesting”)

  • dependsOnGroups : If we want to run a particular @Test method after a particular group of @Test method runs, we can use this attribute

eg: @Test(dependsOnGroups = “smoketesting”)

  • dependsOnMethods : If we want to run a particular @Test method after a particular @Test method runs, we can use this attribute

eg: @Test(dependsOnMethods=”testMethodName”)

Example:

 

Public class attributeExample(){

 

@Test(groups=”smoketesting”)

public void test1(){

 

System.out.println(“This method belongs to smoketesting group”);

}

 

@Test(groups=”smoketesting”)

public void test2(){

 

System.out.println(“This method belongs to smoketesting group”);

 

}

@Test(dependsOnGroups=”smoketesting”)

public void test3(){

System.out.println(“This method runs  after smoketesting group methods run”);

 

}

@Test(dependsOnMethods=”test1”)

public void test4(){

System.out.println(“This method runs after test1 runs”);

 

}

 

@Test(enabled = false)

Public void test5(){

System.out.println(“This method will not run till test case is enabled”);

 

}

 

@Test(alwaysRun = true)

Public void test6(){

System.out.println(“This method always runs”);

 

}

 

@Test(priority=1)

Public void test7(){

System.out.println(“This method runs before any other test method runs as it has first priority”);

 

}

depends tag in testing.xml:

Till now we have seen dependsOnMethods and dependsOnGroups used for @Test methods to depend on groups and methods. But , we can use the depends on tag in testing.xml to perform the same operation without using the attribute.

 

 

Example:

 

Include&Exclude Tags in TestNg.Xml:

Include and Exclude Tags are used in testing.xml to include or exclude any @Test method to run

 

Example:

 

TestNG Listeners:

TestNG listeners are used to execute before or after @test method or suite runs. There are different types of TestNG listeners. Please find them below.

IsuiteListener: This is an interface which  has two methods called onStart() and onFinish(). If a class implements this listener, these methods will run before and after the suite runs.

ITestListener: This interface is also similar to IsuiteListener but the difference is that it will run before and after Test  runs. It consists of below methods.

onStart(): This method will run before @Test method runs

onFinish():This method will run after @Test method runs

onTestFailure(ITestResult result): runs whenever a test fails

onTestSkipped(ITestResult result) : runs whenever a test is skipped

onTestSuccess(ItestResult result): runs whenever a test is succeded

 

IInvokedMethodListener: This listener will run before and after every method is run. It consists of two methods.

beforeInvocation(): Invokes before each method runs

afterInvoction(): Invokes after each method runs

 

Example:

 

public class sampleListener implements ItestListener,IsuiteListener,IInvokeMethodListener{

 

public void onStart(ISuite suite){

System.out.println(“runs before suite is started”);

}

public void onFinish(ISuite suite){

System.out.println(“runs after suite is started”);

 

}

public void onStart(ITestContext testContext){

System.out.println(“runs before test is started running”);

 

}

public void onFinish(ITestContext testContext){

System.out.println(“runs after test is started running”);

}

 

public void onTestSuccess(ITestContext testContext){

System.out.println(testContext .getName()+“ is successful”);

}

 

public void onTestFailure(ITestContext testContext){

 

System.out.println(testContext .getName()+“ is failed”);

//Taking failed Test cases screenshots

File src = ((TakeScreensot)driver).getScreenshotAs(OutputType.FILE)

FileUtils.copyFile(src, new File(path));

}

 

public void beforeInvocation(IInvokedMethod method,ItestResult result){

System.out.println(“This method is invoked before every method runs”);

}

 

public void afterInvocation(IInvokedMethod method,ItestResult result){

System.out.println(“This method is invoked after every method runs”);

}

}

Including listener in Testngclass:

 

@Listeners(sampleListener)

public class testngSampleTest(){

 

@Test

public void  test1(){

 

Including listener tag in TestNg.xml:

read less
Comments
Dislike Bookmark

Lesson Posted on 13 Jul IT Courses/Embedded C IT Courses/Embedded Systems IT Courses/Software Testing +1 IT Courses/Programming Languages/C Language less

What is Safety-Critical Software?

Vihanga EmbedSoft

Vihanga embedsoft is india's only training institute for safety-critical embedded software. We enables...

A software whose failure may cause death or injuries to the users called Safety-Critical Software.The software present as part of Aeroplanes, or present in Rail as railway signalling software or Automotive (current as part of cars/buses/trucks) or health care (x-rays, scanners etc.).How is it, safety-critical?... read more

A software whose failure may cause death or injuries to the users called Safety-Critical Software.
The software present as part of Aeroplanes, or present in Rail as railway signalling software or Automotive (current as part of cars/buses/trucks) or health care (x-rays, scanners etc.).
How is it, safety-critical?
 Let's take an example.
1. The software was written for engine control of an aeroplane. During its flight, if the software fails, then the possibility of flight crash may result in life loss or disabilities.
2. Software written for signalling of train network, failure of that may result in a train collision.
3. break systems software of a Car, whose failure may result in an accident
4. Incorrect results produced by x-rays and scanners leads to health hazards to people.
Usually, all the above software are embedded softwares. As the software is safety-critical, extra care needs to be for software design and development.
Out of the four above, Avionics software is more critical because the aeroplane will not always be on the ground to switch off the system that is creating a problem.  Hence, more care needs to be taken than others while designing software or Testing software.

read less
Comments
Dislike Bookmark

Answered on 05 Aug IT Courses/Software Testing

Grace Phosiya

Software Tester with 2 years Exprience, One year in to teaching , another one year Non-IT experience

Analytical skills and logical thinking. Keep on learning and update yourself everytime.
Answers 19 Comments
Dislike Bookmark

Looking for Software Testing classes

Find best Software Testing classes in your locality on UrbanPro.

FIND NOW

Answered on 18/12/2018 IT Courses/Java IT Courses/Programming Languages/Python IT Courses/DevOps Training +7 IT Courses/Angular.JS IT Courses/SAP IT Courses/Amazon Web Services/AWS Certified DevOps Engineer .Net IT Courses/Software Testing IT Courses/IT Certifications/Salesforce Certification IT Courses/RPA Training less

SanKir Technologies Pvt Ltd

Dear Kumar, My suggestion is to - become good in one programming language - preferably Java and one O/S preferably Linux. Be aware of Open Source systems. Try to identify the opportunities in your existing company and focus on those skills. Sanjay Bheemasenarao SanKir Technologies read more

Dear Kumar,

My suggestion is to - become good in one programming language - preferably Java and one O/S preferably Linux. Be aware of Open Source systems.  Try to identify the opportunities in your existing company and focus on those skills.  

Sanjay Bheemasenarao

SanKir Technologies

read less
Answers 41 Comments 1
Dislike Bookmark

Answered on 02/12/2018 IT Courses/Data Science IT Courses/Software Testing

Sahil Manchanda

Machine learning engineer

Yes, I used to work in software testing in 2014. After, my master's from IIT Guwahati, now I am working as a research engineer in Machine learning domain. Data Science is a beautiful field. It involves fundamentals of Statistics. You may need to study various Machine learning algorithms such as decision... read more

Yes,

I used to work in software testing in 2014. After, my master's from IIT Guwahati, now I am working as a research engineer in Machine learning domain.

Data Science is a beautiful field. It involves fundamentals of Statistics. You may need to study various Machine learning algorithms such as decision trees, linear regression, logistic regression, SVM, neural networks. Its an amazing thing to learn. 

Learning mathematical concepts like linear algebra, probability and calculus will help you in understanding the working of these algorithms.

 

Its a good decision to move to data science. Its in high demand and will also nourish your brain.

 

Sahil

M.Tech CSE

IIT GUWAHATI

read less
Answers 17 Comments
Dislike Bookmark

Answered on 31 Jan IT Courses/Software Testing

How do you perform API Testing?

Shubham

I would suggest soap UI tool. Postman tool for api testing they are best in the market for api testing
Answers 2 Comments
Dislike Bookmark

Answered on 15/11/2018 IT Courses/Software Testing

What is the difference between BAT and BVT in manual testing?

Punit

BVT is Build Verification Test and BAT is Build Acceptance Testing. When we receive build the first thing we do is one round of adhoc testing to check the navigation between major screens so as to confirm that there is no broken links that might stop us from testing. Next thing we do is BVT to make sure... read more

BVT is Build Verification Test and BAT is Build Acceptance Testing. When we receive build the first thing we do is one round of adhoc testing to check the navigation between major screens so as to confirm that there is no broken links that might stop us from testing. Next thing we do is BVT to make sure the build is stable enough to go for further testing. Under this we test high level functionalities. Then we do BAT which can also be called as system testing. Under this  other functionalities/modules, UI etc. is tested.

read less
Answers 1 Comments
Dislike Bookmark

Answered on 28/11/2018 IT Courses/Software Testing

Why do QA automation engineers who use Selenium WebDriver use Jenkins?

Pragna Rahul

Jenkins is a integration tool. It checks te changes happened in the SVN server and sends email notifications if any change occurs in build
Answers 2 Comments
Dislike Bookmark

Looking for Software Testing classes

Find best Software Testing classes in your locality on UrbanPro.

FIND NOW

Answered on 28/11/2018 IT Courses/Software Testing

What is the difference between selenium and TestNG?

Pragna Rahul

Selenium is a jar of libraries. TestNG is a package used for bulk execution of testscripts
Answers 1 Comments
Dislike Bookmark

About UrbanPro

UrbanPro.com helps you to connect with the best Software Testing classes in India. Post Your Requirement today and get connected.

Overview

Questions 402

Lessons 39

Total Shares  

+ Follow 20,368 Followers

Related Topics

Top Contributors

Connect with Expert Tutors & Institutes for Software Testing

x

Ask a Question

Please enter your Question

Please select a Tag

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 25 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 6.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more