Intellij running one test in TestNG

2019-03-30 01:41发布

问题:

So my typical workflow is

  1. I write a data driven test using TestNG in IntelliJ.
  2. I supply hundreds of data items
  3. Run the test and one or two of them fail
  4. I see the list of passed/failed tests in the "Run" pane.

I would like the ability to just right click that "instance" of the test and run that test alone (with breakpoints). Currently IntelliJ does not seem to have that feature. I would have to right click the test and when I run, it runs the whole set of tests with hundreds of data points.

Is this possible?

回答1:

TestNG supports this at the testng.xml level, where you can specify which indices of your data provider should be used. It's called "invocation-numbers" and you can see what it looks like by running a test with a data provider, failing some of its invocation numbers and looking at the testng-failed.xml that gets generated.

Back to your question: your IDE needs to support this feature in order to make it available in the UI, so I suggest you ask on the IDEA forums



回答2:

The feature has been added as of Intellij 142.1217: https://youtrack.jetbrains.com/issue/IDEA-57906