Maven Failsafe Plugin:

Maven Surefire Plugin:

Someone asked me then what is the advantage of using one over the another.

The advantage is the way they fail:

Failsafe > runs all the integration tests, but if any tests fail during the integration-test phase, the plugin does not fail the build immediately. It still executes the post-integration-test phase. Therefore we can still perform any cleanup and environment tear-down as part of the post-integration-test phase. The subsequent verify phase of the build process reports any test failures.

Surefire > It binds with the test phase, in case of any test failures, the build fails, and no further phases execute during the build process.



Test Data Supplier (TestNG DataProvider wrapper)

If you are a big fan of Stream and Collection API for data manipulation in the modern Java world, give a shot to this library that contains TestNG DataProvider wrapper (as of writing this article, the latest version is based on TestNG 7.4.0) which helps to supply test data in a more flexible way.

Supported return types

  • Collection
  • Map
  • Entry
  • Object[]
  • double[]
  • int[]
  • long[]
  • Stream / StreamEx
  • Tuple
  • A single Object of any common or custom type

As it can return StreamEx, it gives you more power to play with flatmap, indices, transposing, etc.

You can find more details and sample Gradle/Maven projects on their official GitHub repository page: