What is the purpose of the @BeforeSuite annotation in TestNG?

What is the purpose of the @BeforeSuite annotation in TestNG?

A) To execute a method before all tests in a suite
B) To execute a method after all tests in a suite
C) To execute a method before each test method
D) To execute a method after each test method

Answer:

A) To execute a method before all tests in a suite

Explanation:

The @BeforeSuite annotation in TestNG is used to execute a method before all tests in a suite are run. This annotation is typically used for setting up the initial state or configurations required for the test suite.

For example:


@BeforeSuite
public void setUpSuite() {
    // Code to set up test suite
}

In this example, setUpSuite() will be executed before any test methods in the suite are run.

Reference links:

https://www.javaguides.net/p/top-java-libraries.html

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top