Saturday, October 27, 2018

How to implement ISuiteListener in TestNG?

ISuiteListener is an interface or TestNG listener provided by TestNG. This listener has two methods onStart() and onFinish(). onStart() method will be invoke before any test suite run and onFinish() method will be invoked after each test suite run.

So when we have a specific tasks that needs to be performed before running a test suite and after finishing the run then this listener will be helpful. Let us understand this listener with an example.

In this example we will be creating two child test suites and these will be executed from another test suite (parent).

How to implement IExecutionListener in TestNG?

IExecutionListener is an interface or TestNG Listener provided by TestNG. This listener monitors the beginning and ending of the TestNG execution.

IExecutionListener interface has two methods onExecutionStart() and onExecutionEnd(). onExecutionStart() will be invoked before TestNG execute any test suite and onExecutionEnd() will be invoked after TestNG executes all test suites.

Let us understand this with an example:

Friday, October 26, 2018

What is the use of TestNG Listeners?

As the name "Listeners" indicating they listen to some events and act accordingly. TestNG provides some interface that will help us to do certain tasks that before and after Suite or Test execution, these interfaces are nothing but TestNG Listeners.

TestNG Listeners are mainly used in generating customized reports and logs. Below are the list of listeners provided TestNG. Each interface is having different abstract methods which can be overridden as per our requirement.

Sunday, October 14, 2018

What is invocationTimeOut in TestNG?

invocationTimeOut: This is a TestNG attribute that defines the maximum period of time that a test method with invocationCount should take to execute/invoke a test method. If the invocationTimeOut has reached before invoking the test method for invocationCount then an exception (ThreadTimeOutException) will be thrown.

And invocationTimeOut should always used with invocationCount otherwise it will be ignored. Let us understand invocationTimeOut with examples.

What is invocationCount in TestNG?

invocationCount: This is a TestNG attribute that defines number of times a test method should be invoked or executed before executing any other test method. If invocationCount = 5, then the test method will be executed 5 times before executing next test method.

Check the below example, In getTitle() test method we are printing the title of the website with invocationCount = 5. And we have another test method secondTest() also.

How to pass heterogeneous parameters from testng.xml in TestNG?

In the previous post we have seen passing only String data as parameters from testng.xml, that is we passed homogeneous data to test method.

But sometimes we have to pass different types of data, that is heterogeneous data to the test method. How to do it in TestNG from testng.xml file.

Check the below example, suppose we are filling a registration form which requires different data types like String, int, long Boolean. Then we need to write a test method that accepts different data types as below

DevOps 01: What is DevOps and How it benefits organizations?

DevOps is a culture in an organization, where the development team and operations team help each other by sharing information, process and t...