TestNG Groups: Include, Exclude with Example – Selenium Tutorial (Hard)

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

Questions and Answers

Which types of test designs does TestNG cover?

  • Unit, functional, end-to-end, UI, and integration tests (correct)
  • Unit tests only
  • End-to-end tests only
  • Functional tests only

What is the purpose of creating an XML file in TestNG?

  • To define test methods separately
  • To encapsulate groups of classes (correct)
  • To execute test cases
  • To run single packages

When do we use groups in TestNG?

  • When we want to create XML files
  • When we want to define test methods separately
  • When we want to run single packages
  • When we want to ignore some test cases (correct)

What are the two mechanisms supported in TestNG for grouping test cases?

<p>Include and exclude (D)</p> Signup and view all the answers

How do you define a group in TestNG?

<p>By using logical names (A)</p> Signup and view all the answers

Which group names are used in the example XML file?

<p>bonding and strong_ties (D)</p> Signup and view all the answers

What is the purpose of the 'include' mechanism in TestNG?

<p>To group test cases (B)</p> Signup and view all the answers

What is the purpose of the 'exclude' mechanism in TestNG?

<p>To ignore (not execute) test cases (D)</p> Signup and view all the answers

What does the '@Test' annotation with 'groups' attribute indicate?

<p>To encapsulate groups of classes (D)</p> Signup and view all the answers

What types of tests can be performed using TestNG?

<p>Unit, functional, end-to-end, UI, and integration tests (C)</p> Signup and view all the answers

Which programming language is used in the code provided?

<p>Java (C)</p> Signup and view all the answers

What is the purpose of the 'groups' attribute in the '@Test' annotation?

<p>To categorize test cases (C)</p> Signup and view all the answers

What is the purpose of the 'exclude' tag in TestNG XML?

<p>To exclude a test case from execution (C)</p> Signup and view all the answers

What is the purpose of the 'include' tag in TestNG XML?

<p>To include a test case for execution (D)</p> Signup and view all the answers

What is the purpose of the 'launchPageHeading' variable in the code?

<p>To store the heading of the login page (B)</p> Signup and view all the answers

What is the purpose of the 'tc02VerifyLaunchPage' method in the code?

<p>To verify the heading on the login page (C)</p> Signup and view all the answers

What is the purpose of the 'tc03EnterCredentials' method in the code?

<p>To enter username and password on login form (B)</p> Signup and view all the answers

What is the purpose of the 'managerID' variable in the code?

<p>To store the manager ID (B)</p> Signup and view all the answers

What is the purpose of the 'newCustomer' variable in the code?

<p>To store the xpath of a link on the User Dashboard (D)</p> Signup and view all the answers

What is the purpose of the 'fundTransfer' variable in the code?

<p>To store the xpath of a link on the User Dashboard (C)</p> Signup and view all the answers

Which test case is tagged to the 'strong_ties' group?

<p>tc04VerifyLoggedInPage (A)</p> Signup and view all the answers

Which test case is tagged to the 'bonding' group?

<p>tc03EnterCredentials (C)</p> Signup and view all the answers

Which test case is tagged to both the 'strong_ties' and 'bonding' groups?

<p>tc01LaunchURL (A)</p> Signup and view all the answers

Which test cases will run if the XML is updated with the 'strong_ties' group name?

<p>tc01LaunchURL, tc04VerifyLoggedInPage (B)</p> Signup and view all the answers

Which test cases will run if the XML is updated with the 'bonding' group name?

<p>tc03EnterCredentials, tc04VerifyLoggedInPage (B)</p> Signup and view all the answers

Which test case is tagged to the 'bonding' group only?

<p>tc05VerifyHyperlinks (B)</p> Signup and view all the answers

Which scenario requires removing the Group tag from the running XML to run all test cases?

<p>Scenario 1 (B)</p> Signup and view all the answers

Which scenario includes the group name in the XML to run only test cases specific to that group?

<p>Scenario 2 (B)</p> Signup and view all the answers

Which scenario uses the Exclude mechanism to exclude a test case?

<p>Scenario 3 (C)</p> Signup and view all the answers

Which scenario uses the Include test mechanism to include specific test cases?

<p>Scenario 4 (A)</p> Signup and view all the answers

Flashcards are hidden until you start studying

Study Notes

TestNG Overview

  • TestNG covers various types of test designs.

XML File in TestNG

  • The purpose of creating an XML file in TestNG is to configure and run test cases.

Groups in TestNG

  • Groups are used in TestNG to categorize test cases based on specific criteria.
  • There are two mechanisms supported in TestNG for grouping test cases: include and exclude.
  • A group can be defined in TestNG using the @Test annotation with the groups attribute.

Group Mechanisms in TestNG

  • The include mechanism is used to specify which test cases to include in a group.
  • The exclude mechanism is used to specify which test cases to exclude from a group.

Example XML File

  • The example XML file uses group names such as strong_ties and bonding.

Test Case Grouping

  • The @Test annotation with the groups attribute indicates that a test case belongs to a specific group.
  • Test cases can be grouped based on specific criteria, such as functional areas or test environments.

Test Types in TestNG

  • TestNG supports various types of tests, including functional, regression, and integration testing.

Code Details

  • The code provided is written in Java.
  • The launchPageHeading variable is used to store the heading of the launch page.
  • The tc02VerifyLaunchPage method is used to verify the launch page.
  • The tc03EnterCredentials method is used to enter credentials.
  • The managerID variable is used to store the manager's ID.
  • The newCustomer variable is used to store the new customer's information.
  • The fundTransfer variable is used to store the fund transfer details.

Grouping and Running Test Cases

  • Test cases can be tagged to specific groups, such as strong_ties and bonding.
  • Test cases can be run by specifying the group name in the XML file.
  • If the XML file is updated with the strong_ties group name, only test cases tagged to that group will run.
  • If the XML file is updated with the bonding group name, only test cases tagged to that group will run.
  • If a test case is tagged to both the strong_ties and bonding groups, it will run when either group is specified.
  • Removing the Group tag from the running XML will run all test cases.
  • Including the group name in the XML will run only test cases specific to that group.
  • The Exclude mechanism can be used to exclude a test case from running.
  • The Include mechanism can be used to include specific test cases in a run.

Studying That Suits You

Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

Quiz Team

More Like This

Use Quizgecko on...
Browser
Browser