I notice that tests run orders of magnitude faster than under Maven or in my IDE. What’s the explanation for this? FYI - I’m using TestNG.
Do you run tests in parallel with Gradle (‘test.maxParallelForks=n’), or does your Gradle build configure TestNG to run them in parallel?
There’s nothing specifically setting parallel
I’d be very suspicious about this. You might want to check that all of your tests are indeed running.
I’m beginning to think that the tests are not running. The test report is empty. I’m using testng on a multi-project build. Are there known bugs with this setup? gradle clean test doesn’t seem to be working.
After some research, it appears I have to add this?
Man - Gradle feels as obtuse as Maven sometimes.
Yes, you have to inform Gradle that you are using TestNG.
Can’t Gradle infer that from the code? I don’t have to do this with Maven.
The documentation explicitly states that Gradle will figure it out, 23.12.3. Test detection. Likewise, it could look at the testCompile configuration to figure it out, if not the source. It might be a bug in the detection code.
This specific project has junit annotations in one submodule, in TestMapsWithJersey.java and TestStringsWithJersey.java, TestStringsWithRestEasy.java. Everything else is TestNG.
That documentation is poorly worded.
What it’s trying to say is that once you tell Gradle what the test framework is, it will scan and find the potential test classes for you so you don’t have to manually construct a suite.
Can explain the decision on this? IMO Gradle, at minimum, should be as convenient as Maven.
It would have to do more scanning work (something which Maven doesn’t do at all), and if it found both JUnit and TestNG tests, it would have to ask you for a decision anyway (because it can’t run both in one task). In the future, we might split up JUnit and TestNG into two separate tasks.
The combination of JUnit and TestNG is a mistake (caused by auto-import with my IDE). It doesn’t make much sense for Gradle to default to using JUnit. It seems arbitrary. It came as a big surprise to me. Software should help us where it can and Gradle can easily detect with test framework to use.
It’s not completely arbitrary in the sense that JUnit is much more widely used than TestNG. I agree that there are better solutions, but that’s what we have today. I invite you to get involved and help move things forward.
Do you happen to have a reference of all these magical Gradle flags available?
What’s magical about them? They are documented in the DSL reference and Javadoc.