How can you run a specific group of tests in TestNG?
A) By specifying the group name in the testng.xml file
B) By using the @RunGroup annotation
C) By using the @TestGroup annotation
D) By creating a new TestNG instance
Answer:
A) By specifying the group name in the testng.xml file
Explanation:
In TestNG, you can run a specific group of tests by specifying the group name in the testng.xml
file. This allows you to selectively run only the tests that belong to the specified group.
For example:
<groups>
<run>
<include name="group1"/>
</run>
</groups>
In this example, only the tests that belong to “group1” will be executed during the test run.