Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Problems using Spock and TestNG together
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Howard Lewis Ship  
View profile  
 More options Jun 18 2012, 5:17 pm
From: Howard Lewis Ship <hls...@gmail.com>
Date: Mon, 18 Jun 2012 14:17:01 -0700
Local: Mon, Jun 18 2012 5:17 pm
Subject: Problems using Spock and TestNG together

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
class.

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">
        <packages>
            <package name="ioc.specs"/>
        </packages>
    </test>

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
sub-packages).

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
inside IDEA:

[PackageUtils] Looking for test classes in the directory:
/Users/hlship/workspaces/tapestry/tapestry5/out/test/tapestry-ioc/ioc/specs
[PackageUtils] Found class ExampleSpec, seeing it if it's included or
excluded
[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
[TestNG] Running:

/Users/hlship/workspaces/tapestry/tapestry5/tapestry-ioc/src/test/conf/test ng.xml

[SuiteRunner] Created 1 TestRunners
[TestRunner] Running test Spock Specs on 0  classes,  included groups:[]
excluded groups:[]
[JUnit4TestMethod] Method 'sky_is_not_blue' not found in class
'ioc.specs.ExampleSpec': ioc.specs.ExampleSpec.sky_is_not_blue()
===== 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!

(971) 678-5210
http://howardlewisship.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Peter Niederwieser  
View profile  
 More options Jun 18 2012, 5:33 pm
From: Peter Niederwieser <pnied...@gmail.com>
Date: Mon, 18 Jun 2012 23:33:24 +0200
Local: Mon, Jun 18 2012 5:33 pm
Subject: Re: Problems using Spock and TestNG together

To my knowledge, TestNG can only run JUnit3 tests, but not JUnit4 tests. In theory, execution environments like IDEs and build tools could support running TestNG and JUnit4 tests in one go, but I don't know of any that do. In Maven you need two Surefire executions. In Gradle you need two test tasks (and will get two reports). Not sure about IDEs.

If you find a way, let us know. But I'm not optimistic.

Cheers,
Peter

On Jun 18, 2012, at 11:17 PM, Howard Lewis Ship wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »