TestNG Multiple-Choice Questions (MCQs)

TestNG is a testing framework for the Java programming language created by Cédric Beust and inspired by JUnit and NUnit.

TestNG MCQs: This section contains multiple-choice questions and answers on the various topics of TestNG. Practice these MCQs to test and enhance your skills on TestNG.

List of TestNG MCQs

1. TestNG is also known as -

  1. Testing Frame
  2. Testing Framework
  3. Testing Final
  4. Testing Phenomena

Answer: B) Testing Framework

Explanation:

TestNG is also known as Testing Framework.

Discuss this Question


2. A more powerful and easier-to-use framework, TestNG framework came ____ JUnit.

  1. Before
  2. After
  3. Alongwith
  4. None

Answer: B) After

Explanation:

A more powerful and easier-to-use framework, TestNG framework came after Junit.

Discuss this Question


3. What is meant by NG in TestNG?

  1. New Generation
  2. Next Generation
  3. Name Generation
  4. No Generation

Answer: B) Next Generation

Explanation:

NG in TestNG means Next Generation.

Discuss this Question


4. What is TRUE about TestNG?

  1. With TestNG, you are in complete control of what is happening in the test cases and how they are executed.
  2. Prior to running test case X, run multiple test cases as a pre-request.
  3. By utilizing easy annotations, grouping, sequencing, and parametrizing, the TestNG framework eliminates the limitations of the older framework.
  4. All of the above

Answer: D) All of the above

Explanation:

The things TRUE about TestNG are -

  1. With TestNG, you are in complete control of what is happening in the test cases and how they are executed.
  2. Prior to running test case X, run multiple test cases as a pre-request.
  3. By utilizing easy annotations, grouping, sequencing, and parametrizing, the TestNG framework eliminates the limitations of the older framework.

Discuss this Question


5. What is/are the advantage(s) of TestNG?

  1. It is easier to understand annotations in TestNG than in Junit.
  2. For implementation, it produces HTML reports.
  3. Logs are also generated by it.
  4. All of the above

Answer: D) All of the above

Explanation:

The advantages of TestNG are -

  1. It is easier to understand annotations in TestNG than in Junit.
  2. For implementation, it produces HTML reports.
  3. Logs are also generated by it.

Discuss this Question


6. Unlike Junit, TestNG does not have constraints like ____.

  1. @beforeclass
  2. @afterclass
  3. Both A and B
  4. None of the above

Answer: C) Both A and B

Explanation:

Unlike Junit, TestNG does not have constraints like @beforeclass and @afterclass.

Discuss this Question


7. ____ are all supported by TestNG.

  1. A suite before/after
  2. A test before/after
  3. A group of tests before/after
  4. All of the above

Answer: D) All of the above

Explanation:

A suite before/after, a test before/after, or a group of tests before/after are all supported by TestNG.

Discuss this Question


8. In the TestNG framework, test cases can be defined ____ one another.

  1. Dependently on
  2. Independently of
  3. Interdependently on
  4. Intradependently on

Answer: B) Independently of

Explanation:

In the TestNG framework, test cases can be defined independently of one another.

Discuss this Question


9. Which of the following ways can be used to add TestNG in your Eclipse?

  1. TestNG can be installed either by adding the TestNG jar file to the Build Path or by installing the TestNG plug-in.
  2. The TestNG plug-in is preferable to the testng.jar file since you don't have to install it for every project. Testng.jar files, on the other hand, must be added to every project's build path.
  3. Both A and B
  4. None of the above

Answer: C) Both A and B

Explanation:

The following ways can be used to add TestNG in your eclipse -

  1. TestNG can be installed either by adding the TestNG jar file to the Build Path or by installing the TestNG plug-in.
  2. The TestNG plug-in is preferable to the testng.jar file since you don't have to install it for every project. Testng.jar files, on the other hand, must be added to every project's build path.

Discuss this Question


10. What is/are the feature(s) of TestNG?

  1. Before and After annotations
  2. Dependent methods
  3. Better reporting
  4. All of the above

Answer: D) All of the above

Explanation:

The features of TestNG are -

  1. Before and After annotations
  2. Dependent methods
  3. Better reporting

Discuss this Question


11. It is possible to execute specific code ____ testing by using before and after annotations.

  1. Before
  2. After
  3. Both A and B
  4. None of the above

Answer: C) Both A and B

Explanation:

It is possible to execute specific code before and after testing by using before and after annotations.

Discuss this Question


12. In order to set variables or configuration ____ executing a test method, and to clean up all variables afterward, before and after annotations are used.

  1. Before
  2. After
  3. While
  4. None

Answer: A) Before

Explanation:

In order to set variables or configuration before executing a test method, and to clean up all variables afterward, before and after annotations are used.

Discuss this Question


13. Annotations like ____, or @BeforeClass are examples of Before and After annotations.

  1. @BeforeSuite
  2. @BeforeTest
  3. @BeforeGroups
  4. All of the above

Answer: D) All of the above

Explanation:

Annotations like @BeforeSuite, @BeforeTest, @BeforeGroups, or @BeforeClass are examples of Before and After annotations.

Discuss this Question


14. ____-based files are used to configure TestNG test suites.

  1. HTML
  2. CSS
  3. XML
  4. PHP

Answer: C) XML

Explanation:

XML-based files are used to configure Testng test suites.

Discuss this Question


15. The test suites are organized and run using the ____ file.

  1. Testng.html
  2. Testng.xml
  3. Testng.php
  4. Testng.pl

Answer: B) Testng.xml

Explanation:

The test suites are organized and run using the Testng.xml file.

Discuss this Question


16. A testng.xml file defines ____, and test groups that are used to create test suites.

  1. Classes
  2. Methods
  3. Packages
  4. All of the above

Answer: D) All of the above

Explanation:

A testng.xml file defines classes, methods, packages, and test groups that are used to create test suites.

Discuss this Question


17. Using Testng's dependencies, a test method can be ____ on one or more other test methods.

  1. Interdependent
  2. Intradependent
  3. Independent
  4. Dependent

Answer: D) Dependent

Explanation:

Using Testng's dependencies, a test method can be dependent on one or more other test methods.

Discuss this Question


18. Based on the '____' principle, dependencies work only when they are in the same class or in the inherited base class.

  1. No-depend-method
  2. Depend-on-method
  3. Depend-to-method
  4. None-depend-method

Answer: B) Depend-on-method

Explanation:

Based on the 'depend-on-method' principle, dependencies work only when they are in the same class or in the inherited base class.

Discuss this Question


19. It is possible to parameterize test methods by passing arguments as parameters, which is achieved by using ____ annotations.

  1. testing@Parameters
  2. testng@Parameters
  3. Parameters@testng
  4. Parameters@testing

Answer: B) testng@Parameters

Explanation:

It is possible to parameterize test methods by passing arguments as parameters, which is achieved by using testng@Parameters annotations.

Discuss this Question


20. ____ files can be used to pass parameters to test methods.

  1. DataProviders
  2. Testng.xml
  3. Both A and B
  4. None of the above

Answer: C) Both A and B

Explanation:

DataProviders and testng.xml files can be used to pass parameters to test methods.

Discuss this Question


21. Using the ____ method, multiple sets of data are used to execute the test method.

  1. DataFetcher
  2. DataAddition
  3. DataProvider
  4. DataModification

Answer: C) DataProvider

Explanation:

Using the DataProvider method, multiple sets of data are used to execute the test method.

Discuss this Question


22. Parallel execution of tests is known as ____.

  1. Better Reporting
  2. Multithreaded Execution
  3. Data-Driven Testing
  4. Parameterization of Test Methods

Answer: B) Multithreaded Execution

Explanation:

Parallel execution of tests is known as multithreaded execution.

Discuss this Question


23. Test methods are executed in multiple threads based on the configuration in the ____ file.

  1. HTML
  2. CSS
  3. XML
  4. C

Answer: C) XML

Explanation:

Test methods are executed in multiple threads based on the configuration in the XML file.

Discuss this Question


24. Reports for test execution using TestNG are provided in ____ formats by default.

  1. XML
  2. HTML
  3. Both A and B
  4. None of the above

Answer: C) Both A and B

Explanation:

Reports for test execution using TestNG are provided in XML and HTML formats by default.

Discuss this Question


25. Java allows only one test to be defined in a single class in the main() method, while TestNG allows ____ tests in a single class.

  1. Two
  2. Three
  3. Four
  4. Multiple

Answer: D) Multiple

Explanation:

Java allows only one test to be defined in a single class in the main() method, while TestNG allows multiple tests in a single class.

Discuss this Question


26. By using the @____ annotation, you can create multiple test cases.

  1. Test
  2. Before
  3. After
  4. BeforeClass

Answer: A) Test

Explanation:

By using the @Test annotation, you can create multiple test cases.

Discuss this Question


27. There is a feature in TestNG that allows you to ____ test cases.

  1. Enable
  2. Disable
  3. Both A and B
  4. None of the above

Answer: C) Both A and B

Explanation:

There is a feature in TestNG that allows you to enable or disable test cases.

Discuss this Question


28. In how many ways can test cases be disabled in TestNG?

  1. 2
  2. 3
  3. 4
  4. 5

Answer: A) 2

Explanation:

Test cases can be disabled in two ways in TestNG.

Discuss this Question


29. By which of the following way(s) can the test cases be disabled in TestNG?

  1. @Test annotations allow you to disable test cases.
  2. XML files can be edited to disable test cases.
  3. Both A and B
  4. None of the above

Answer: C) Both A and B

Explanation:

By the following ways the test cases can be disabled in TestNG -

  1. @Test annotations allow you to disable test cases.
  2. XML files can be edited to disable test cases.

Discuss this Question


30. A TestNG ____ is a piece of code that comes into play during test execution and controls the flow of the test.

  1. Groups
  2. Annotation
  3. Code
  4. Tags

Answer: B) Annotation

Explanation:

A TestNG Annotation is a piece of code that comes into play during test execution and controls the flow of the test.

Discuss this Question


31. Which of the following is/are the TestNG Annotation(s)?

  1. @BeforeSuite
  2. @AfterSuite
  3. @BeforeTest
  4. All of the above

Answer: D) All of the above

Explanation:

The following are the TestNG Annotations -

  1. @BeforeSuite
  2. @AfterSuite
  3. @BeforeTest

Discuss this Question


32. All test methods in the suite will be executed before the @____ method runs.

  1. BeforeSuite
  2. BeforeClass
  3. BeforeTest
  4. BeforeMethod

Answer: A) BeforeSuite

Explanation:

All test methods in the suite will be executed before the @BeforeSuite method runs.

Discuss this Question


33. After all test methods in a suite have been executed, the @____ annotation will run.

  1. AfterSuite
  2. AfterTest
  3. AfterClass
  4. AfterMethod

Answer: A) AfterSuite

Explanation:

After all test methods in a suite have been executed, the @AfterSuite annotation will run.

Discuss this Question


34. All test methods in that folder will be executed before the @____ annotated method is executed.

  1. BeforeClass
  2. BeforeSuite
  3. BeforeTest
  4. BeforeMethod

Answer: C) BeforeTest

Explanation:

All test methods in that folder will be executed before the @BeforeTest annotated method is executed.

Discuss this Question


35. Upon completion of all the test methods of the classes in the folder, the @____ method will be executed.

  1. AfterSuite
  2. AfterTest
  3. AfterClass
  4. AfterMethod

Answer: B) AfterTest

Explanation:

Upon completion of all the test methods of the classes in the folder, the @AfterTest method will be executed.

Discuss this Question


36. This method is called before the class's first method is invoked using the @____ annotation.

  1. BeforeSuite
  2. BeforeClass
  3. BeforeTest
  4. BeforeMethod

Answer: B) BeforeClass

Explanation:

This method is called before the class's first method is invoked using the @BeforeClass annotation.

Discuss this Question


37. After all test methods of the current class have been executed, the @____ method will be invoked.

  1. AfterMethod
  2. AfterSuite
  3. AfterClass
  4. AfterTest

Answer: C) AfterClass

Explanation:

After all test methods of the current class have been executed, the @AfterClass method will be invoked.

Discuss this Question


38. Every test method will be run prior to the @____ annotation.

  1. BeforeMethod
  2. BeforeTest
  3. BeforeClass
  4. BeforeSuite

Answer: A) BeforeMethod

Explanation:

Every test method will be run prior to the @BeforeMethod annotation.

Discuss this Question


39. After each test method is executed, the @____ annotation is executed.

  1. AfterTest
  2. AfterClass
  3. AfterMethod
  4. AfterSuite

Answer: C) AfterMethod

Explanation:

After each test method is executed, the @AfterMethod annotation is executed.

Discuss this Question


40. Before all test cases in a group are executed, the @____ annotation is run only once.

  1. BeforeTest
  2. BeforeClass
  3. BeforeSuite
  4. BeforeGroups

Answer: D) BeforeGroups

Explanation:

Before all test cases in a group are executed, the @BeforeGroups annotation is run only once.

Discuss this Question


41. After the execution of all test cases belonging to a group, the @____ annotated method runs only once.

  1. AfterTest
  2. AfterGroups
  3. AfterSuite
  4. AfterClass

Answer: B) AfterGroups

Explanation:

After the execution of all test cases belonging to a group, the @AfterGroups annotated method runs only once.

Discuss this Question


42. Which of the following comes first in the hierarchy of TestNG Annotations?

  1. BeforeSuite
  2. BeforeClass
  3. BeforeTest
  4. BeforeMethod

Answer: A) BeforeSuite

Explanation:

BeforeSuite comes first in the hierarchy of TestNG Annotations.

Discuss this Question


43. Which of the following comes last in the hierarchy of TestNG Annotations?

  1. AfterClass
  2. AfterTest
  3. AfterSuite
  4. AfterMethod

Answer: C) AfterSuite

Explanation:

AfterSuite comes last in the hierarchy of TestNG Annotations.

Discuss this Question


44. What is/are the benefit(s) of TestNG Annotations?

  1. It was very easy for testers to work with TestNG Annotations.
  2. The additional parameters can be passed to TestNG Annotations.
  3. A test class does not need to be extended to use TestNG annotations.
  4. All of the above

Answer: D) All of the above

Explanation:

The benefits of TestNG Annotations are -

  1. It was very easy for testers to work with TestNG Annotations.
  2. The additional parameters can be passed to TestNG Annotations.
  3. A test class does not need to be extended to use TestNG annotations.

Discuss this Question


45. What is/are the TestNG Annotation Attribute(s)?

  1. Description
  2. TimeOut
  3. Priority
  4. All of the above

Answer: D) All of the above

Explanation:

The TestNG Annotation Attributes are -

  1. Description
  2. TimeOut
  3. Priority

Discuss this Question


46. An @Test annotation contains a string called ____ that describes the test.

  1. Priority
  2. Enabled
  3. Description
  4. TimeOut

Answer: C) Description

Explanation:

An @Test annotation contains a string called description that describes the test.

Discuss this Question


47. The "____" attribute can be used when the second test method wants to be dependent on the first.

  1. Priority
  2. TimeOut
  3. dependOnMethods
  4. Groups

Answer: C) dependOnMethods

Explanation:

The "dependOnMethods" attribute can be used when the second test method wants to be dependent on the first.

Discuss this Question


48. The TestNG will run the test cases ____ if the 'priority' attribute is not specified.

  1. Alphabetically
  2. Numerically
  3. Alphanumerically
  4. Randomly

Answer: A) Alphabetically

Explanation:

The TestNG will run the test cases alphabetically if the 'priority' attribute is not specified.

Discuss this Question


49. A test case's ____ determines its execution sequence.

  1. Priority
  2. Groups
  3. TimeOut
  4. dependOnMethods

Answer: A) Priority

Explanation:

A test case's priority determines its execution sequence.

Discuss this Question


50. -_000 to _000 are the integer values that can be stored in the priority.

  1. 4
  2. 5
  3. 6
  4. 7

Answer: B) 5

Explanation:

-5000 to 5000 are the integer values that can be stored in the priority.

Discuss this Question


51. Priority settings determine how the test cases are executed, with the lowest priority running ____ and the highest priority running ____.

  1. First, Last
  2. Last, First
  3. Middle, Last
  4. Middle, First

Answer: A) First, Last

Explanation:

Priority settings determine how the test cases are executed, with the lowest priority running first and the highest priority running last.

Discuss this Question


52. '____' contains a boolean value that is set to true by default.

  1. TimeOut
  2. Priority
  3. Enabled
  4. Groups

Answer: C) Enabled

Explanation:

'enabled' contains a boolean value that is set to true by default.

Discuss this Question


53. Different test cases belonging to the same functionality are grouped using the '____' attribute.

  1. TimeOut
  2. Priority
  3. Groups
  4. Enabled

Answer: C) Groups

Explanation:

Different test cases belonging to the same functionality are grouped using the 'groups' attribute.

Discuss this Question


54. Testing cases are provided with a ____ during which they can complete their execution.

  1. timeIn
  2. timeOut
  3. timeZone
  4. Time

Answer: B) timeOut

Explanation:

Testing cases are provided with a timeOut during which they can complete their execution.

Discuss this Question


55. A test method can be parameterized in ___ ways.

  1. Two
  2. Three
  3. Four
  4. Five

Answer: A) Two

Explanation:

A test method can be parameterized in two ways.

Discuss this Question


56. A test method can be parameterized in the following way(s) -

  1. TestNG Parameters
  2. TestNG DataProviders
  3. Both A and B
  4. None of the above

Answer: C) Both A and B

Explanation:

A test method can be parameterized in the following ways -

  1. TestNG Parameters
  2. TestNG DataProviders

Discuss this Question


57. Annotations like @____ in TestNG enable you to listen to every event in your Selenium code.

  1. Speakers
  2. Listeners
  3. Ears
  4. Earpods

Answer: B) Listeners

Explanation:

Annotations like @Listeners in TestNG enable you to listen to every event in your Selenium code.

Discuss this Question


58. It is possible to activate the listeners ____ the test case.

  1. Before
  2. After
  3. Both A and B
  4. None of the above

Answer: C) Both A and B

Explanation:

It is possible to activate the listeners either before or after the test case.

Discuss this Question


59. A listener is implemented by an interface called ____.

  1. TestListener
  2. ITestListener
  3. IListener
  4. Listener

Answer: B) ITestListener

Explanation:

A listener is implemented by an interface called ITestListener.

Discuss this Question


60. Which of the following is/are the method(s) in ITestListener Interface?

  1. onTestStart()
  2. onTestSuccess()
  3. onTestFailure()
  4. All of the above

Answer: D) All of the above

Explanation:

The following are the methods in ITestListener Interface -

  1. onTestStart()
  2. onTestSuccess()
  3. onTestFailure()

Discuss this Question




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.