Quantcast

Re: Is Gradle supposed to automatically detect TestNG tests?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Is Gradle supposed to automatically detect TestNG tests?

Kevin Stembridge
Hi all,

From the documentation for the Java plugin, I assumed that I didn't need to do anything special for my TestNG tests to be run.

http://gradle.org/java_plugin.html

> "It automatically detects and executes all unit tests in the test source set. It also generates a report once test execution is complete. JUnit and TestNG are both supported."

But my tests were not being run. Debug output showed that a Junit scanner was being run but nothing for TestNG. I added the following to my subprojects configuration and the tests are now being run:

    tasks.test.useTestNG()


So my questions are:

Is TestNG support supposed to be enabled out of the box?
Is the documentation correct?
Is my fix the correct approach to enable TestNG tests?


Cheers,
Kevin

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Is Gradle supposed to automatically detect TestNG tests?

Adam Murdoch

On 06/03/2011, at 8:30 AM, Kevin Stembridge wrote:

Hi all,

From the documentation for the Java plugin, I assumed that I didn't need to do anything special for my TestNG tests to be run.

http://gradle.org/java_plugin.html

> "It automatically detects and executes all unit tests in the test source set. It also generates a report once test execution is complete. JUnit and TestNG are both supported."

But my tests were not being run. Debug output showed that a Junit scanner was being run but nothing for TestNG. I added the following to my subprojects configuration and the tests are now being run:

    tasks.test.useTestNG()


So my questions are:

Is TestNG support supposed to be enabled out of the box?

Not at the moment. The Java plugin assumes that you want to run junit tests unless you explicitly say otherwise, by calling test.useTestNG(). There's been some discussion on the mailing list about this behaviour, and we'll probably change it so that Gradle will run all junit and testng tests that it finds.


Is the documentation correct?

Sort of. It is a bit unclear about using testng, however.

Is my fix the correct approach to enable TestNG tests?

Yes


--
Adam Murdoch
Gradle Developer
http://www.gradle.org
Co-Founder and VP of Engineering, Gradleware Inc. - Gradle Training, Support, Consulting
http://www.gradleware.com

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Is Gradle supposed to automatically detect TestNG tests?

suprinder
This post has NOT been accepted by the mailing list yet.
@Adam

I tried tasks.test.useTestNG() but still tests are not executed. Can you show a bit more of yr gradle file.

Thanks in advance
Loading...