Загрузка...

TestNG : What is Priority attribute in TestNG? SDET Automation Testing Interview Questions & Answers

👉 Crack SDET QA Interviews with a Powerful Self-Introduction 👉 https://topmate.io/qa_sdet_automation_expert/1574044
👉 Top 50 SDET Behavioral Interview Questions & Answers 👉 https://topmate.io/qa_sdet_automation_expert/1528511

Level up your SDET and QA skills! 🚀 SDET Automation Testing Interview Questions & Answers

We will be covering a wide range of topics including QA manual testing, automation testing, Selenium, Java, Jenkins, Cucumber, Maven, and various testing frameworks.

TestNG : What is Priority attribute in TestNG?

In TestNG, priority is an attribute that can be applied to test methods to specify the order in which they should be executed.

It is used to indicate the relative importance of a test method when there are multiple tests to be executed.

TestNG executes test methods in alphabetical order by default, but this may not always be desirable.

The priority attribute allows you to specify the order in which test methods should be executed based on their importance.

Here's an example of how to use the priority attribute in TestNG:

import org.testng.annotations.Test;

public class MyTest {
@Test(priority = 2)
public void testMethod1() {
// Test code goes here
}

@Test(priority = 1)
public void testMethod2() {
// Test code goes here
}

@Test(priority = 3)
public void testMethod3() {
// Test code goes here
}
}

In this example, we have three test methods with different priorities. testMethod2 has the highest priority, followed by testMethod1 and testMethod3.

When TestNG runs these tests, it will execute testMethod2 first, followed by testMethod1, and then testMethod3.

Note that priority values can be any integer value, including negative values.

If two or more test methods have the same priority value, TestNG will execute them in alphabetical order.

If you don't specify a priority value for a test method, it will be assigned the default priority of 0.

Видео TestNG : What is Priority attribute in TestNG? SDET Automation Testing Interview Questions & Answers канала SDET Automation Testing Interview Pro
Яндекс.Метрика
Все заметки Новая заметка Страницу в заметки
Страницу в закладки Мои закладки
На информационно-развлекательном портале SALDA.WS применяются cookie-файлы. Нажимая кнопку Принять, вы подтверждаете свое согласие на их использование.
О CookiesНапомнить позжеПринять