Running Test Suites

Running Test Suites From IDE

To run the test suite from your IDE, right click on the testng.xml file in the side navigation bar. Then click on the option ‘Run testng.xml’ to run your suite:

Running test suites from command line

To run test suites from command line, navigate to the root directory of your project in the terminal and type:

mvn test

This will automatically compile tests as:

Test Compilation


Then the testng.xml file will be automatically run as:

Automation by Test Class A


Automation by Test class B

Finally you will see the following result logged on the console as:

Running testng.xml through command line

Configuring test suite execution options

1. Thread Count

TestNG provides you with the option to define the number of threads you want to use to run your test suite. This can be simply achieved as:

XML
<suite name="MySuite" thread-count="10">
  </suite>

You have to assign an integer value to the attribute ‘thread-count’ and you are done.

2. Parallel Execution

You can also configure your test suite to allow your tests to run in parallel. To know more on how to parallelize your tests, click here.

How to Create Test Suite in TestNG?

In this article we will learn about test suites and how can we build them using Java and TestNG. TestNG is a modern testing framework that is used very widely used today. It has a broad base of features that allow us to write unit tests and club them together in groups.

Table of Content

  • What is a Test Suite?
  • Steps to Create Test Suite in TestNG
  • Understanding TestNG XML Configuration
  • Creating Test Suites Using TestNG XML
  • Running Test Suites
  • Conclusion
  • FAQ’s on How to Create Test Suite in TestNG

TestNG is used in combination with Selenium to implement browser automation and therefore used for regression testing. By the end of this article, you will be successfully creating and running your own test suites.

Similar Reads

What is a Test Suite?

A test suite is a collection of test cases. There are various ways to create test these. You could either choose to group these tests by functionality or you could simply club your test classes together to form a test suite. In TestNG, the test suite is written in the form of a xml document. This allows you as a tester to have a fine grained control over what tests you want to run and create groups or suites according to the very specific requirements of your project....

Steps to Create Test Suite in TestNG

Step 1. Setting Up TestNG Environment...

Understanding TestNG XML Configuration

Introduction to TestNG XML configuration file...

Creating Test Suites Using TestNG XML

Guide to creating a basic test suite in TestNG XML...

Running Test Suites

Running Test Suites From IDE...

Conclusion

In this article we looked at what test suites are and how we can create them using TestNG in java. We looked at two approaches to clubbing tests, through groups and through classes. Hope you learnt something useful. If you want to discuss something, please feel free to leave comments below....

FAQ’s on How to Create Test Suite in TestNG

Where can I use the tag inside testng.xml?...