
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 Prioritizes 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
Advertisements