Categories: Selenium TopicsTestNG Tutorials

TestNG Tutorials 39: Run Only Test From a TestNG Class Without Using TestNG XML?

Hello Folks,

Suppose you have created a testng class which has many @Test annotated methods say 10 test methods. You may need to run only one test out of 10 for debug/verify etc. Generally I see people will comment “@Test” annotations or use testng.xml to include required test method using include or exclude tags.

There are some very simple ways to achieve this. I will discuss those ways here:

  1. Just select test method name and click on run method.
  2. Use run configuration.

Just select test method name and click on run method:

Refer below video to understand how to do this (Click on Full Screen icon):

 

Steps to follow:

  1. Select a test method from TestNG class.
  2. Hit “Run” button or press Fn+f9 button.

 

TestNG Class:

 

Output: Selected test method will be run only.

Use run configuration:

Refer below video to understand how to do this:

 

Steps to follow:

  1. Navigate to Run-> Run Configuration.

    2. Select your project in “Project” field using browse button.

3. Select TestNG class name in “Class” field using browse button.

4. Select Method name in “Method” field using browse button. When you click on browse button, all methods from above selected class will be shown.

 

5. Click on “Apply” and “Run”.

You will observe only selected method has run. This is very helpful while creating scripts or bug fixes. Hope it will help you.

More about TestNG in upcoming posts. Stay tuned.

If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.
#ThanksForReading
#HappySelenium

 

Author: Amod Mahajan

My name is Amod Mahajan and I am an IT employee with 4+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went throw so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning

Amod Mahajan

My name is Amod Mahajan and I am an IT employee with 4+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went throw so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning

Recent Posts

How To Verify Maximum Character Limit of an Input Box Through Selenium

Hello Folks, Recently a guy asked me this question which he was asked in an interview in IBM. What the…

12 hours ago

API Testing Tutorial Part 15 – Sending GET Request With Params in Postman

Hello Folks, As part of our API Testing series, we will see “Sending GET request with params in Postman”. In last…

4 days ago

TestNG Tutorials 62: Dependency in TestNG – Types of Dependencies in TestNG

We have learnt in previous posts regarding establishing relationship between test methods. You can go through them below: Dependency in…

7 days ago

TestNG Tutorials 61: Dependency in TestNG – Creating Dependency Among Test Methods – DependsOnGroup

In previous post, We have learnt to Establish dependency among test methods. In this post, we will see another concept…

7 days ago

TestNG Tutorials 60: Dependency in TestNG – Creating Dependency Among Test Methods – DependsOnMethod

We are going to see another important concept or feature provided by TestNG. This feature is called as Dependency. Suppose,…

7 days ago

TestNG Tutorials 59: DataProvider in TestNG – Running DataProvider Method in Parallel – Parallel DataProvider Method

A Test method is run for all data set provided by a DataProvider method which is by default one after…

2 weeks ago