//
archives

TestNG

This category contains 18 posts

Building Dynamic TestNG Suites

We have all at some point wished that we had a way wherein we could dynamically build the TestNG suite xml file based upon some parameters and still make use of built in test execution mechanisms such as maven surefire plugin to run our tests. Its very easy to build these sort of customizations if … Continue reading

Dynamic parameterization in TestNG

TestNG provides us users with two  ways in you can achieve data driven tests. You make use of the @DataProvider annotation wherein you bind your @Test method with a data source. You make use of the @Parameters annotation and have your @Test method read values from a suite xml file. There are enough blogs and documentation pages that … Continue reading

Running setup only once per Test/Suite Without Using @BeforeSuite/@BeforeTest

This is a common question that I am noticing asked by many users in the TestNG google forums and also on StackOverFlow. So instead of constantly repeating myself in all these places, I thought I should just blog it as a solution for others to refer to it. Lets say you have a scenario wherein … Continue reading

Dears Listeners…stand in Q please

Yes, you read the title right.. but I was not hinting at you the readers.. but I was referring to the TestNG listeners . We have all at some point or the other wondered.. what if I could have my listeners follow some order when they are being executed by TestNG. I too wondered this. There … Continue reading

Testcase specific logs for a Selenium project

Problem statement: You would like to have a separate log file for every testcase so that if there are failures, its very easy for you to be able to debug and find out failures. For going through this, I am going to be using a selenium based test as an example. Selenium has a webdriver … Continue reading

How to run test methods in parallel but test classes in sequence

This question came up recently on the TestNG forum. Since when solving this question I had a chance to use one of the lesser known features of TestNG, I thought I should perhaps capture this as a blog so that it can help someone. Here’s the problem statement : A user on the forum wanted … Continue reading

Working with @TestInstance annotation

Sometimes one would need to gain access to the test class instance to which an @Test annotated test method belongs to, from within a data provider. This could be particularly useful in cases, wherein the data provider may need to behave differently based on the type of the class to which the @Test method belongs … Continue reading

Parallel execution of multiple TestNG suites

If we would like to run more than one TestNG suite in parallel, here’s how to go about doing it. For the sake of convenience am going to conveniently assume that your project is a Maven project. We first start by defining two properties in our pom file – One property to accept a list … Continue reading

Running tests which don’t have TestNG annotations

This question came up very recently on the TestNG forum and I found it to be quite interesting. So I decided to spend sometime trying to figure out how to get this to work. The reason why this problem statement sounded interesting was because it was mentioned that the classes in question are all legacy … Continue reading

What are data providers in TestNG

Data providers is a very common need when you are building tests that are data driven in nature. TestNG provides for two types of data providers. Greedy Data provider Lazy Data provider Both the above flavors of data providers can be used in your TestNG driven tests to satisfy the following scenarios. You need to … Continue reading