How to execute one test from large TestNG suite using testng.xml?

Sad Developer picture Sad Developer · Nov 4, 2009 · Viewed 48.7k times · Source

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.

Answer

smaant picture smaant · Jan 15, 2014

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>