Learn how to run testng.xml from maven in this testng maven example. Learn to integrate testng tests to run during build time to automate testng tests.
TestNG parallel execution of tests, classes and suites examples. Learn how to run testng tests and suites in parallel or single test in multiple threads.
While learning TestNG, many people get confused when they read about the @DataProvider and @Factory annotations – what to use when? and what is better? Let’s take a look at both of their functionalities. Difference between @Factory and @DataProvider Below is the main difference between @Factory and @DataProvider functionalities on TestNG. DataProvider: A test method […]
Let’s learn about the @Factory annotation provided by TestNG. @Factory allows tests to be created at runtime depending on certain data-sets or conditions. Sometimes we may need to run a set of tests with different data values. To achieve this we may define a separate set of tests inside a suite in the testng XML […]
Dependency is a feature in TestNG that allows a test method to depend on a single or a group of test methods. This will help in executing a set of tests to be executed before a test method. Method dependency only works if the “depend-on-method” is part of the same class or any of the […]
Grouping test methods is one of the most important features of TestNG. In TestNG users can group multiple test methods into a named group. You can also execute a particular set of test methods belonging to a group or multiple groups. This feature allows the test methods to be segregated into different sections or modules. […]
An important features provided by TestNG is the DataProvider feature. It helps you to write data-driven tests, which essentially means that same test method can be run multiple times with different data-sets. Please note that DataProvider is the second way of passing parameters to test methods (first way we already discussed in @Parameters example). It […]
One of the important features of TestNG is parameterization. This feature allows user to pass parameter values to test methods as arguments. This is supported by using the @Parameters annotation. There are mainly two ways through which we can provide parameter values to test-methods: – Through testng.xml XML configuration file – Through DataProviders (We will […]
While running tests there can be cases where certain tests get stuck or may take much more time than expected. In such a case you may need to mark the said test case as fail and then continue. In this tutorial, we will learn to configure TestNG tests to timeout after some configured time duration. […]
When executing TestNG tests, there may be some scenarios where you may have to disable a particular test or a set of tests from getting executed. For example, consider a scenario where a serious bug exists in a feature due to certain tests belonging to certain scenarios that cannot be executed. As the issue has […]
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. TestNG provides a feature to test such scenarios by allowing the user to specify the type of exceptions that are expected to be thrown by a test method during execution. […]
TestNG before and after annotations. @BeforeSuite, @AfterSuite, @BeforeTest, @AfterTest, @BeforeGroups, @AfterGroups, @BeforeClass, @AfterClass, @BeforeMethod and @AfterMethod.
TestNG uses annotations to help developers to write the tests. The following is a table containing information about all the annotations provided by TestNG and a brief description of them. I will cover them in detail in separate tutorials specific to their usages. TestNG Test Configuration Annotations Annotation Description @BeforeSuite The annotated method will be […]
Testing as you may know is the process of validating and verifying that a piece of software or hardware is working according to the way it’s expected to work. Testing is a very important part of the software development life cycle (SDLC) as it helps in improving the quality of the product developed. There are […]