I have a TestNG suite with large amount of methods. I execute this suite using wrapper built on top of TestNG runner. All tests in the suite fail except one. What should I write in testng.xml to execute just that one failed test?
Obvious solution is to assign unique group names to all of the methods and then specify name in testng.xml. This can work in case of 2-3 methods, but it gets harder as number of tests grow.
Yes, look up the <suite-files> tag in the testng. xml documentation.
TestNG gives an option to execute multiple test in parallel in a single configuration file (XML).
How to run same test multiple times using TestNG? First, create a TestNG class file and add all the required annotations. Identify that @Test annotation which you want to run multiple times. Once you identified the @Test annotation then design the test format as below.
Instead of exclude
, you may use include
. It'll exactly what you want. Only this test will be executed.
<classes>
<class name="test.IndividualMethodsTest">
<methods>
<include name="testMethod" />
</methods>
</class>
</classes>
Try this:
<classes>
<class name="test.IndividualMethodsTest">
<methods>
<exclude name="testMethod" />
</methods>
</class>
</classes>
After each run, TestNG creates a filed called testng-failed.xml that contains only the tests that failed. Just invoke TestNG again on that file:
java org.testng.TestNG testng.xml java org.testng.TestNG testng-failed.xml
(replace org.testng.TestNG with your own runner since you seem to use a customized one).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With