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:
- Just select test method name and click on run method.
- 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:
- Select a test method from TestNG class.
- Hit “Run” button or press Fn+f9 button.
Output: Selected test method will be run only.
Use run configuration:
Refer below video to understand how to do this:
Steps to follow:
- 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.
Author: Amod Mahajan
A software Tester who is paid to judge products developed by others. Currently getting paid in American Dollars. Writing technical posts and creating YouTube videos are my hobbies.