Does Spock have any Test Suite support

2,520 views
Skip to first unread message

bpilati

unread,
Mar 14, 2011, 5:34:02 PM3/14/11
to spockfr...@googlegroups.com
Does Spock have any Test Suite support like this?

public class MyTestSuite extends TestSuite {
// Since Eclipse launches tests relative to the project root,
// declare the relative path to the test scripts for convenience
private static final String TEST_ROOT = "src/test/com/foo/bar/";
public static TestSuite suite() throws Exception {
TestSuite suite = new TestSuite();
GroovyTestSuite gsuite = new GroovyTestSuite();
suite.addTestSuite(FooTest.class); // non-groovy test cases welcome, too.
suite.addTestSuite(gsuite.compile(TEST_ROOT + "BarTest.groovy"));
suite.addTestSuite(gsuite.compile(TEST_ROOT + "FooFactoryTest.groovy"));
suite.addTestSuite(gsuite.compile(TEST_ROOT + "BaazTest.groovy"));
return suite;
}
}

If not, is there any way to specify what order the specs run in beside alphabetical?

-- Brian



View this message in context: Does Spock have any Test Suite support
Sent from the Spock Framework mailing list archive at Nabble.com.

Peter Niederwieser

unread,
Mar 14, 2011, 5:51:40 PM3/14/11
to spockfr...@googlegroups.com
On 14.03.2011, at 22:34, bpilati wrote:

Does Spock have any Test Suite support like this?

You can use any of the approaches that JUnit 4 provides for writing test suites, and also third-party extensions like http://johanneslink.net/projects/cpsuite.jsp. GroovyTestSuite is based on JUnit 3 and therefore probably won't work. 

If not, is there any way to specify what order the specs run in beside alphabetical?

Unless you are using a test suite, execution order is controlled by the environment that's running the specs (build tool, IDE, etc.). So it depends on whether your environment allows to specify an order. For Grails and Maven 2 projects, Spock alternatively offers to run specs in "failed first" order.

Cheers,
Peter

bpilati

unread,
Mar 15, 2011, 3:20:59 PM3/15/11
to spockfr...@googlegroups.com
Peter,

I am using IntelliJ.

Do you have an example of JUnit 4 test suite for Spock tests and the
accompanying Command line and VM Parameters for the IntelliJ project?

Currently I use these inputs:

Command line: test-app functional: -echoOut
VM Parameters: -DbaseURL= -Dgeb.driver=<driver?

This would really help me a lot!

--Thanks,
Brian

<quote author="Peter Niederwieser">

Cheers,
Peter

--
You received this message because you are subscribed to the Google Groups
"Spock Framework - User" group.
To post to this group, send email to spockfr...@googlegroups.com.
To unsubscribe from this group, send email to
spockframewor...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/spockframework?hl=en.

--
View this message in context: http://spock-framework.3207229.n2.nabble.com/Does-Spock-have-any-Test-Suite-support-tp6170800p6173976.html

Peter Niederwieser

unread,
Mar 15, 2011, 3:58:58 PM3/15/11
to spockfr...@googlegroups.com
It seems that you are trying to run Grails functional tests from IDEA. I can't help you with that because I don't have any experience with it. Anyway, it might be better to ask this question on the Grails list. Any solution that works with JUnit 4 should also work with Spock.

Personally, I've never had the need for test suites. Instead I use the features provided by my build tool and IDE to run a particular subset of tests. The Grails command line also allows you to do this, but I don't know what the state of IDE integration is.

Cheers,
Peter

Luke Daley

unread,
Mar 15, 2011, 7:22:21 PM3/15/11
to spockfr...@googlegroups.com
Hi Brian,

The Grails way of doing this is to arrange your “suites” into packages, then invoke what you like by targeting.

Let's say you have two packages, one for the functional tests for admin related tasks and one for cart tasks.

// Run all tests in the “admin” package
grails test-app functional: admin.**.*

// Run all tests in the “cart” package
grails test-app functional: cart.**.*

If this is not satisfactory, then please raise your query on the Grails list as this is specific to Grails.

Reply all
Reply to author
Forward
0 new messages