- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How test runner prioritize test classes for execution in Selenium?
We can prioritize tests in TestNG during execution. It must be noted that priority can only be set for test methods with @Test annotation. Lower the priority number set for a test method, higher the priority it gets during execution.
Only integer value (positive, zero or negative) can be set as priority. A decimal number can also be set as priority, however it is required to be converted to integer value via typecasting.
A test method cannot have multiple priority numbers. Also, the priority for a test method cannot be set from the TestNG XML file.
Syntax
public class TestNG { @Test (priority = 2) public void tC1() { System.out.println("Test Case 1"); }
Example
import org.testng.annotations.Test; public class TestNGP { @Test (priority = 2) public void testCase1() { System.out.println("This is the A Normal Test Case 1"); } @Test (priority = 1) public void testCase2() { System.out.println("This is the A Normal Test Case 2"); } @Test (priority = 3) public void testCase3() { System.out.println("This is the A Normal Test Case 3"); } }
Output
- Related Articles
- Cypress Test Runner (Test Automation)
- How to trigger headless test execution in Selenium with Python?
- How to create a test runner file for Cucumber in Java?
- Test and Collection Runner in Postman
- How to run tests using a test runner file for Cucumber?
- How to set Test and Collection Runner in Postman?
- How to set the order of execution for test methods in Cucumber?
- How to create nested test suites for Selenium IDE?
- How to run multiple test classes in TestNG?
- How to exclude a test from execution in Pytest?
- How to run multiple test cases using TestNG Test Suite in Selenium?
- How does the execution of a particular test method depend on other test\nmethods in TestNG?
- How to skip a selected test from execution in pytest?
- How to incorporate and remove test methods from execution from a\ncollection of test cases in TestNG?
- How to overlook a particular test method from execution in TestNG?

Advertisements