Dependency Test in TestNG

Sometimes, you may need to invoke methods in a Test case in a particular order or you want to share some data and state between methods. This kind of dependency is supported by TestNG as it supports the declaration of explicit dependencies between test methods. In simple, Dependency means if one @Test method fails or skipped […]

Read More »

Data driven Testing inTestNG using DataProvider

TestNG Data Providers Data Provider feature helps you to write data-driven tests, which essentially means that same test method can be run multiple times with different data-sets. It helps in providing complex parameters to the test methods as it is not possible to do this from testng.xml file. Please note that @DataProvider is the second way of […]

Read More »

Parallel Execution of test In multiple browsers using testNG

Selenium WebDriver does not have any feature which will allow us to perform parallel execution in multiple browsers. So with the help of TestNG we can perform parallel execution in selenium.  This can be done by using @parameters annotation. Let’s consider the below example: package Testng_Pack; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.ie.InternetExplorerDriver; […]

Read More »

Parallel Execution of test methods in TestNG

TestNG provides multiple ways to execute tests in separate threads. In testng.xml, if we set ‘parallel‘ attribute on the tag to ‘tests‘, testNG will run all the ‘@Test’ methods in tag in the same thread, but each tag will be in a separate thread. If we want to run methods/classes in separate threads, we need to set ‘parallel‘ attribute […]

Read More »

Expected Exception and Expected Message in TestNG

TestNG – Expected Exception and Expected Message  While writing unit tests there can be certain scenarios where we need to verify that an exception is being thrown by the program during execution or not. TestNG provides a feature to test such scenarios by allowing the user to specify the type of exceptions that are expected to […]

Read More »