TestNG @Test Priority in Selenium (Easy)

AwedExuberance avatar
AwedExuberance
·
·
Download

Start Quiz

Study Flashcards

30 Questions

Which types of test designs does TestNG cover?

UI test and integration test

What priority does TestNG assign to @Test if it is not defined?

0

Which test cases are scheduled first when running multiple test cases with TestNG?

Test cases with lower priority

What is the scenario in the tutorial where sequencing is required?

Performing a Google search

What is the expected browser title after performing the scenario in the tutorial?

Facebook - Google Search

What should each step of the code be in the tutorial?

In separate methods

What is the purpose of TestNG?

To run and manage tests

Which method is responsible for launching the Firefox browser?

openBrowser

What is the purpose of the launchGoogle method?

Launch Google.com

What is the search term used in the peformSeachAndClick1stLink method?

Facebook

What is the action performed in the FaceBookPageTitleVerification method?

Verify the Google search page title

What is the reason for the failure of the FaceBookPageTitleVerification method?

The search activity was not processed

In the TestNG code without priority, how are the methods executed?

Based on the alphabetical order of their method names

What is the purpose of assigning priority to the test cases in TestNG?

To execute the test cases based on the priority assigned to them

Which tool can be used to define priority in TestNG?

TestNG

Which attribute is used to define priority in TestNG?

@Test(priority)

What happens if priority is defined using a different syntax in TestNG?

It will show a compilation error

What is the purpose of using priority in TestNG?

To run test cases in a specific sequence

Who contributed to making this tutorial possible?

Both Ramandeep Singh and Rama Krishna Gadde

What will happen if priority is not defined for test cases in TestNG?

They will run in alphabetical order

Can priority be defined for individual test methods within a test class in TestNG?

Yes, using @Test(priority)

Which IDE will show a compilation error if priority is defined in a different syntax in TestNG?

Both Eclipse and IntelliJ

Is TestNG case-sensitive when defining priority?

Yes

Which method in the code has the highest priority?

e_method

Which method in the code is executed first when priorities are assigned?

e_method

What happens when two methods have the same priority value?

The method with the higher alphabetical order is executed first.

In the second code example, which method is executed first when priorities are not assigned?

b_method

What is the output of the second code example?

I'm in method B, I'm in method C, I'm in method E, I'm in method A, I'm in method D

What is the output of the third code example?

I'm in method E, I'm in method D, I'm in method A, I'm in method C, I'm in method B

What is the output of the first code example?

I'm in method E, I'm in method D, I'm in method A, I'm in method C, I'm in method B

Study Notes

TestNG Overview

  • TestNG covers various test design types, including unit testing, integration testing, functional testing, and end-to-end testing.

TestNG Priority

  • If the @Test annotation is not defined with a priority, TestNG assigns a default priority of 0.
  • When running multiple test cases with TestNG, the test cases with lower priority values are scheduled first.

Tutorial Scenario

  • In the tutorial, sequencing is required when multiple test cases need to be executed in a specific order.
  • The expected browser title after performing the scenario in the tutorial is "Facebook - Log In or Sign Up".

Code Structure

  • Each step of the code should be self-contained and have a clear purpose.

Purpose of TestNG

  • The purpose of TestNG is to provide a testing framework for Java applications.

Browser Launch

  • The launchFirefox method is responsible for launching the Firefox browser.

Search Method

  • The launchGoogle method is used to launch Google and perform a search.
  • The search term used in the performSearchAndClick1stLink method is "facebook".

Facebook Page Title Verification

  • The FaceBookPageTitleVerification method is used to verify the title of the Facebook page.
  • The method fails if the actual title does not match the expected title.

TestNG Execution

  • Without priority, TestNG methods are executed in the order they are defined in the code.
  • Assigning priority to test cases in TestNG allows for control over the execution order.
  • The purpose of assigning priority is to ensure that critical test cases are executed first.

Priority Definition

  • The @Test annotation with the priority attribute is used to define priority in TestNG.
  • If priority is defined using a different syntax, it will be ignored.

IDE Compilation

  • If priority is defined in a different syntax, Eclipse IDE will show a compilation error.

Priority Case Sensitivity

  • TestNG is case-sensitive when defining priority.

Method Priority

  • The method with the highest priority value is executed first when priorities are assigned.
  • If two methods have the same priority value, the execution order is determined by the method name.

Method Execution

  • The method with the highest priority value is executed first when priorities are assigned.
  • If priorities are not assigned, the methods are executed in the order they are defined in the code.

Code Example Outputs

  • The output of the first code example is the execution of the test cases in the order of their priority.
  • The output of the second code example is the execution of the test cases in the order they are defined in the code.
  • The output of the third code example is the execution of the test cases with the highest priority value first.

Facebook Search and Page Verification Quiz: Test your knowledge of performing searches on Facebook and verifying page titles. Learn how to use xpath and verify search results. Challenge yourself with different scenarios and improve your skills in navigating Facebook.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free

More Quizzes Like This

Use Quizgecko on...
Browser
Browser