Monday, 28 August 2023

TestNG MCQ

Question :What is TestNG?

A programming language

A test automation framework

A browser

An operating system

Correct Answer :  A test automation framework

 

Question :Which file is used to configure TestNG settings?

testng.properties

testng.xml

testng.cfg

testng.settings

Correct Answer :  testng.xml

 

Question :How do you define a test method in TestNG?

public void testMethod()`

public void testMethod()` with `@Test` annotation

public void testMethod()` with `@startTest` annotation

`@TestMethod`

Correct Answer :  public void testMethod()` with `@Test` annotation

 

Question :What is the purpose of the `@Test` annotation in TestNG?

It marks a method as a test method

It defines the test data

It specifies the test priority

It handles test dependencies

Correct Answer :  It marks a method as a test method

 

Question :How do you group test methods in TestNG?

Using the `@Group` annotation

Using the `@Test` annotation

Using the `@Group` annotation with the group name

Using the `@Test` annotation with the group name

Correct Answer :  Using the `@Test` annotation with the group name

 

Question :How do you specify test dependencies in TestNG?

Using the `@Dependency` annotation

Using the `@Test` annotation with `dependsOnMethods` attribute

Using the `@DependsOn` annotation

Using the `@Test` annotation with `dependsOn` attribute

Correct Answer :  Using the `@Test` annotation with `dependsOnMethods` attribute

 

Question :What is the purpose of the `@DataProvider` annotation in TestNG?

It provides data for test methods

It defines test execution order

It configures test groups

It handles test parallelism

Correct Answer :  It provides data for test methods

 

Question :How do you configure TestNG to run tests in parallel?

Using the `parallel` attribute in the `testng.xml` file

Using the `@Parallel` annotation

Using the `parallel` attribute in the `@Test` annotation

Using the `@Parallel` annotation with `true` value

Correct Answer :  Using the `parallel` attribute in the `testng.xml` file

 

Question :What is the purpose of the `@BeforeSuite` annotation in TestNG?

It runs before every test method

It runs before the test suite

It runs before the test class

It runs before every test method in a class

It runs before the test suite

 

Question :How do you disable a test method in TestNG?

Using the `@Test(enabled = false)` annotation

By commenting out the method

Using the `@Ignore` annotation

Using the `@Disabled` annotation

Using the `@Test(enabled = false)` annotation

 

Question :What is the purpose of the `@DataProvider` name attribute in TestNG?

It specifies the data provider name

It provides a unique identifier for the data provider

It links the data provider to a test method

It sets a custom name for the data provider

It specifies the data provider name

 

Question :How do you set the test execution order in TestNG?

Using the `@Order` annotation

Using the `@Sequence` annotation

Using the `@Test` annotation with the `priority` attribute

Using the `@Order` annotation with the order number

Correct Answer :  Using the `@Test` annotation with the `priority` attribute

 

Question :What is the purpose of the `@Listeners` annotation in TestNG?

It defines the test listeners

It specifies the test groups

It sets up the test data

It handles test configurations

Correct Answer :  It defines the test listeners

 

Question :How do you pass parameters to a test method in TestNG?

Using the `@Parameter` annotation

Using the `@Test` annotation with the `params` attribute

Using the `@Parameters` annotation

Using the `@Test` annotation with the `parameters` attribute

Correct Answer :  Using the `@Parameters` annotation

 

Question :What is the purpose of the `@BeforeTest` annotation in TestNG?

It runs before every test method

It runs before the test suite

It runs before the test class

It runs before every test method in a class

Correct Answer :  It runs before the test suite

 

Question :How do you handle test timeouts in TestNG?

Using the `@Timeout` annotation

Using the `@Test` annotation with the `timeout` attribute

Using the `@Time` annotation

Using the `@Test` annotation with the `time` attribute

Correct Answer :  Using the `@Test` annotation with the `timeout` attribute

 

Question :What is the purpose of the `@AfterTest` annotation in TestNG?

It runs after every test method

It runs after the test suite

It runs after the test class

It runs after every test method in a class

Correct Answer :  It runs after the test suite

 

Question :How do you handle test retries in TestNG?

Using the `@Retry` annotation

Using the `@Test` annotation with the `retryOnFailure` attribute

Using the `@Test` annotation with the `retryAnalyzer` attribute

Using the `@Test` annotation with the `retry` attribute

Using the `@Test` annotation with the `retryAnalyzer` attribute

 

Question :What is the purpose of the `@AfterSuite` annotation in TestNG?

It runs after every test method

It runs after the test suite

It runs after the test class

It runs after every test method in a class

It runs after the test suite

 

Question :How do you configure TestNG to run tests in a specific order?

By using the `preserve-order` attribute in the `testng.xml` file

By using the `@Order` annotation

By using the `order` attribute in the `@Test` annotation

By using the `@Order` annotation with the order number

By using the `preserve-order` attribute in the `testng.xml` file

 

Question :What is the purpose of the `@BeforeClass` annotation in TestNG?

It runs before every test method

It runs before the test suite

It runs before the test class

It runs before every test method in a class

It runs before the test class

 

Question :How do you handle test data providers in TestNG?

By implementing the `DataProvider` interface

By using the `@DataProvider` annotation with the `dataProviderClass` attribute

By using the `DataProviderFactory` class

By using the `@DataProvider` annotation with the `dataProvider` attribute

By using the `@DataProvider` annotation with the `dataProviderClass` attribute

 

Question :What is the purpose of the `@AfterClass` annotation in TestNG?

It runs after every test method

It runs after the test suite

It runs after the test class

It runs after every test method in a class

It runs after the test class

 

Question :How do you configure TestNG to run tests multiple times?

Using the `@Repeat` annotation

Using the `@Test` annotation with the `repeatCount` attribute

Using the `@Repeatable` annotation

Using the `@Test` annotation with the `invocationCount` attribute

Using the `@Test` annotation with the `invocationCount` attribute

 

Question :What is the purpose of the `@BeforeMethod` annotation in TestNG?

It runs before every test method

It runs before the test suite

It runs before the test class

It runs before every test method in a class

It runs before every test method

 

Question :How do you handle test parameterization in TestNG?

Using the `@Test` annotation with the `param` attribute

Using the `@Param` annotation

Using the `@Test` annotation with the `parameters` attribute

Using the `@Parameters` annotation

Using the `@Parameters` annotation

 

Question :What is the purpose of the `@AfterMethod` annotation in TestNG?

It runs after every test method

It runs after the test suite

It runs after the test class

It runs after every test method in a class

It runs after every test method

 

Question :How do you configure TestNG to run only specific test methods?

Using the `@Test` annotation with the `includeMethods` attribute

Using the `@IncludeMethods` annotation

Using the `@Test` annotation with the test method name

Using the `@Test` annotation with the `include` attribute

Using the `@Test` annotation with the `include` attribute

 

Question :What is the purpose of the `@Factory` annotation in TestNG?

It defines the test factories

It creates test instances

It runs the test suite

It specifies the test groups

It defines the test factories

 

Question :How do you configure TestNG to run tests in a specific thread pool size?

Using the `@ThreadPoolSize` annotation

Using the `@Test` annotation with the `threadPoolSize` attribute

Using the `@Thread` annotation

Using the `@Test` annotation with the `threadPool` attribute

Using the `@Test` annotation with the `threadPoolSize` attribute

No comments:

Post a Comment

Featured

Software Testing

Question: What is software testing, and why is it important?  Answer: Software testing is the process of evaluating a software application ...

popular