2021年2月10日星期三

Simple modern Gradle configuration to mimic default Maven Failsafe configuration

What is a simple (but modern best-practices) way to configure Gradle so that it allows me to run integration tests similar to how a default Maven Failsafe configuration would work? I've read the Gradle docs for tests—in particular the Gradle docs for integration tests—but they seem pretty complicated (in comparison with Maven Failsafe), and moreover I don't believe the examples work in the same way.

What I'm looking for is pretty straightforward:

  • There would be some separate task—let's call it integrationTest for the sake of discussion.
  • The integrationTest task would not run when I invoke gradle test.
  • The integrationTest task would run (after the test task) when I invoke gradle integrationTest.
  • The integrationTest task would run (after the test task) when I invoke gradle check.
  • The integrationTest task would have identical dependencies and classpath configurations as the test task.
  • The integrationTest task would use the same source path (i.e. src/test/java) as the test task, but would only run tests ending in *IT (just to simplify the default Failsafe inclusion pattern for this discussion).
  • The test task would ignore all tests ending in *IT.

That's actually a pretty simple use case. (I just went into details so there would be no ambiguity.) I can turn that on in Failsafe using two lines to indicate goals, and three lines to indicate a dependency. Since Gradle takes the XML verbosity out of the equation, I should be able to configure that in two lines, right?

Just to be clear, I don't want to use Maven Failsafe in Gradle. I just want to configure Gradle to behave in a similar way as the default Failsafe configuration, as I detailed above.

https://stackoverflow.com/questions/66111459/simple-modern-gradle-configuration-to-mimic-default-maven-failsafe-configuration February 09, 2021 at 08:49AM

没有评论:

发表评论