Ashish Anand has Published 140 Answers

How does TestNG invoke a test method using multiple threads?

Ashish Anand

Ashish Anand

Updated on 09-Mar-2022 11:44:46

TestNG supports multi-threading, i.e., a @Test method can be invoked multiple times in parallel. A test method should be invoked from multiple threads so that multiple invocation is also required. If we want to run a single @Test at multi-thread, it is of no use. Therefore, multi-thread is useful if ... Read More

How to disable a TestNG test based on a condition?

Ashish Anand

Ashish Anand

Updated on 09-Mar-2022 11:43:08

TestNG supports multiple ways to skip or ignore a @Test execution. Based on the requirement, a user can skip a complete test without executing it at all or skip a test based on a specific condition. If the condition meets at the time of execution, it skips the remaining code ... Read More

How to get the result status from TestNG in @AfterMethod?

Ashish Anand

Ashish Anand

Updated on 09-Mar-2022 11:40:01

TestNG supports native dependency injection. It allows to declare additional parameters in methods. At the runtime, TestNG automatically fills these parameters with the right values. Here is a list of some native dependencies in TestNG:ITestContextXmlTestMethodITestResultYou can use these dependencies to get the execution status of a test in TestNG.Usually, @AfterMethod ... Read More

How to make TestNG print a detailed message about a failure?

Ashish Anand

Ashish Anand

Updated on 09-Mar-2022 11:28:15

TestNG supports a lot of assertions. It has the org.testng.Assert class that extends the Java object class java.lang.object.Whenever there is a failure, a user would want to get a detailed failure report in order to perform a root cause analysis. But, sometimes the displayed failure information is not sufficient and ... Read More

How to execute a single test from a large testing suite using TestNG.xml?

Ashish Anand

Ashish Anand

Updated on 09-Mar-2022 11:23:54

testNG.xml is very flexible and it can work as a harness file to execute the test cases. It keeps the development and execution separate from each other. A user can develop "N" number of test cases in testNG but can run a limited number of test methods based on the ... Read More

How to run a specific group of tests in TestNG from command line?

Ashish Anand

Ashish Anand

Updated on 09-Mar-2022 11:21:05

Group test is a new innovative feature in TestNG, which doesn't exist in JUnit framework. It permits you to dispatch methods into proper portions and perform sophisticated groupings of test methods.Not only can you declare those methods that belong to groups, but you can also specify groups that contain other ... Read More

How to turn off TestNG's default reporters programmatically?

Ashish Anand

Ashish Anand

Updated on 09-Mar-2022 11:14:00

TestNG allows to run the test suites from IntelliJ IDE as well as from the command line. When user runs the testNG.xml either from an IDE or the command line, TestNG generates a default report. It saves all the reports and respective HTML files in the Project->test-output folder. If this ... Read More

How to get a list of all the test methods in a TestNG class?

Ashish Anand

Ashish Anand

Updated on 09-Mar-2022 11:04:30

TestNG supports native dependency injection. It allows to declare additional parameters in methods. At the runtime, TestNG automatically fills these parameters with the right values. Here is a list of some native dependencies in TestNG:ITestContextXmlTestMethodITestResultThese dependencies help to retrieve the names of test methods depending on where they are called. ... Read More

How to use TestNG SkipException?

Ashish Anand

Ashish Anand

Updated on 09-Mar-2022 10:57:10

TestNG supports multiple ways to skip or ignore a @Test execution. Based on requirement, a user can skip a complete test without executing it at all or skip a test based on a specific condition. If the condition meets at the time of execution, it skips the remaining code in ... Read More

How to use regular expression in class path in TestNG.xml?

Ashish Anand

Ashish Anand

Updated on 09-Mar-2022 10:51:25

testNG.xml has a format <classes> where we define all the test classes that should be executed. There is no any specific way to provide regular expression in a class in <classes>. But there are workarounds of course which are quite useful in case you want to run a specific @Test ... Read More

1 2 3 4 5 6 7 ... 14 Next
Advertisements