Home » Enterprise Java » TestNG

TestNG

TestNG HTML and XML Reports Example

In this article, we will go through the TestNG HTML and XML reports. We will be doing the following: Start with a TestNG project which we will later run to generate reports. We will be running a main suite containing a couple of child suites, this will create enough data for us to review the reports generated. Go through the TestNG ...

Read More »

TestNG Parameters Annotation Example

A TestNG based test method is like any other java method and is allowed to have parameters. @Parameters is the TestNG annotation that allows us to pass parameters to a Test method. In this article, I am going to show you several examples of @Parameters annotation. Before we start with the examples, a bit about the setup: I am using using Maven as the build tool ...

Read More »

TestNG Selenium Integration Example

In this article, I am going to show you an example of TestNG and Selenium integration. Let me first brief you on TestNG and Selenium. TestNG is an annotation based testing framework which allows you to create configurable test suites where each suite contains one or more tests. A test in turn is composed of one more test classes. Selenium ...

Read More »

TestNG Maven Project Example

In this article, I am going to show how to setup a Maven based project and run the TestNG tests. Let’s first start with the setup. Since this is about running TestNG tests using Maven as the build tool, it is obvious you need to have it. I am using Eclipse as the IDE, version Luna 4.4.1. Also install Maven-Eclipse ...

Read More »

TestNG Spring Integration Example

In this article, we will go through a few examples of TestNG and spring integration. Before we start with the examples, let me first brief you on the goal of spring’s integration testing framework:  Manage Spring IoC container caching between test execution.  Provide Dependency Injection of test fixture instances. Provide transaction management appropriate to integration testing. In this article, first I ...

Read More »

TestNG Listeners Example

This article aims to introduce you to TestNG listeners and show you an example for each of the listeners. In TestNG, a listener is represented by the marker interface org.testng.ITestNGListener. TestNG provides you with many more interfaces that extend org.testng.ITestNGListener. Each interface defines one aspect of TestNG. In order to extend TestNG behavior one needs to implement the TestNG-provided listener ...

Read More »

TestNG beforeSuite Example

In this article, we will show you how to use the TestNG @BeforeSuite annotation. If you have used JUnit annotations, you will be familiar with @BeforeClass. In TestNG, apart from @BeforeClass, we also have additional annotations like @BeforeTest and @BeforeSuite. @BeforeSuite will be executed before any tests declared inside a TestNG suite are run. So how is it different from ...

Read More »

TestNG beforeMethod Example

In this article, I will show you an example of TestNG @BeforeMethod. This is one of the annotations provided by TestNG that gets invoked before the execution of each test method. It is very similar to JUnit’s setUp() and is useful if you want to setup some test data before the start of the test method. But first my setup ...

Read More »

TestNG DataProvider Example

In this article, I am going to show you some examples of DataProvider. It is one of the methods used in TestNG to support data-driven testing. Before I proceed with my examples, I will brief you on data-driven testing but first let’s get started with the setup details: I am using Eclipse as the IDE, version Luna 4.4.1. I will ...

Read More »

TestNG beforeTest example

In this article, I will show you an example of the TestNG @beforeTest annotation. In TestNG, you can configure your tests using annotations that start with @Before or @After. TestNG defines many configuration annotations, each one belonging to a specific event in its lifecycle. @beforeTest is one such annotation. A method with @beforeTest annotation will run, before any test method ...

Read More »