I have a challenge ... a backlog of hundreds of TestNG tests, but I'm
moving towards using Spock (http://spockframework.org).
Spock is a Groovy testing environment; Spock specifications are JUnit
tests; they the @RunWith annotation to hook into a custom JUnit Runner
I want to be able to keep most existing tests, and use Spock/JUnit in
parallel. TestNG has an option for that: junit="true" on the <test> element.
However, I can't get this to work in either Gradle command line build
(1.0-milestone-3), or from IDEA.
I'm using org.testng:testng:6.5.2, which itself depends on junit:junit:4.10.
I'm also using org.spockframework:spock-core:0.6-groovy-1.8 which normally
depends on junit:junit-dep:4.9 (but after initial experimentation, I've
turned off that transitive dependency, so that both TestNG and Spock depend
on the same junit:4.10).
I've added the following to my testng.xml:
<test name="Spock Specs" junit="true">
This ioc.specs package is new and separate from the location of all the
existing TestNG tests (which are under org.apache.tapestry5.ioc, and
The Gradle build recognizes my new <test> but doesn't seem to recognize the
Spock specifications inside. It shows a test with 0 test cases (the TestNG
tests specified by other <test> elements do execute normally).
Tweaking testng.xml to run with high verbosity, I see this when running
[PackageUtils] Looking for test classes in the directory:
[PackageUtils] Found class ExampleSpec, seeing it if it's included or
[PackageUtils] ... Including class ExampleSpec
[TestRunner] Running the tests in 'Spock Specs' with parallel mode:false
[RunInfo] Adding method selector:
org.testng.internal.XmlMethodSelector@3dbbd23f priority: 10
[SuiteRunner] Created 1 TestRunners
[TestRunner] Running test Spock Specs on 0 classes, included groups:
[JUnit4TestMethod] Method 'sky_is_not_blue' not found in class
===== Invoked methods
Has anyone else managed to get Spock and TestNG to co-exist. I'm pretty
reliant on running my tests from the IDE, and I vastly prefer to have one
IDE command to run the entire gamut of TestNG and Spock/JUnit tests in one
go, rather than separate commands for each (I believe I could get Gradle to
run TestNG and JUnit tests separately, though I expect some issues related
to report generation if I go down that path).
Howard M. Lewis Ship
Creator of Apache Tapestry
The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!