0% found this document useful (0 votes)
0 views

import java (4)

The document provides an overview of TestNG, including how to run tests, common annotations, execution sequence, and features like grouping, dependency, and timeouts. It also explains the importance of the testng.xml file for configuration, how to pass parameters, and the differences between soft and hard assertions. Additionally, it covers the use of the @Listener and @Factory annotations for enhancing test execution and management.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

import java (4)

The document provides an overview of TestNG, including how to run tests, common annotations, execution sequence, and features like grouping, dependency, and timeouts. It also explains the importance of the testng.xml file for configuration, how to pass parameters, and the differences between soft and hard assertions. Additionally, it covers the use of the @Listener and @Factory annotations for enhancing test execution and management.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Grouping of tests • Parallel test execution • Data-driven testing capabilities 3.

How do you
run a TestNG test? • You can run a TestNG test by right-clicking the test class in your IDE
and selecting "Run As" > "TestNG Test." 4. What are the annotations used in TestNG? •
Common annotations include: • @Test • @BeforeMethod • @AfterMethod • @BeforeClass
• @AfterClass • @BeforeSuite • @AfterSuite 5. What is the sequence of execution of
annotations in TestNG? • The sequence is: 1. @BeforeSuite 2. @BeforeTest 3.
@BeforeClass 4. @BeforeMethod 5. @Test 6. @AfterMethod 7. @AfterClass 8. @AfterTest
9. @AfterSuite 6. How to set priorities in TestNG? • You can set priorities using the priority
attribute in the @Test annotation: java @Test(priority = 1) public void testMethod1() { }
@Test(priority = 2) public void testMethod2() { } 7. Define grouping in TestNG? • Grouping
allows you to execute multiple test cases together under a single group name defined in
the @Test annotation. 8. What is dependency in TestNG? • Dependency allows you to
specify that one test method should run only after another method has successfully
executed. 9. What is timeOut in TestNG? • The timeOut attribute specifies the maximum
time (in milliseconds) that a test method should take to execute before it is marked as
failed. 10. What is invocationCount in TestNG? • The invocationCount attribute specifies
how many times a test method should be invoked. Intermediate TestNG Interview
Questions 11. What is the importance of testng.xml file? • The testng.xml file is used to
configure and organize tests, specify groups, and define parameters for running tests. 12.
How to pass parameters in test cases through testng.xml file? xml You can access it in
your test method using: java @Parameters({"username"}) public void login(String
username) { } 13. How can we disable a test case from running? • You can disable a test
case by setting the enabled attribute to false: java @Test(enabled = false) public void
skippedTest() { } 14. What is the difference between soft assertion and hard assertion? •
Hard assertions stop the execution of the test if an assertion fails, while soft assertions
allow the test to continue executing even if an assertion fails. 15. What is the use of
@Listener annotation in TestNG? • The @Listener annotation allows you to register
listeners that can perform actions when certain events occur during the test execution. 16.
What is the use of @Factory annotation? • The @Factory annotation allows you to create
instances of a class dynamically for running multiple tests with differen

You might also like