hakandilek / spock

Automatically exported from code.google.com/p/spock
0 stars 0 forks source link

Enable ability to run one test, or a select group of tests #318

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Right now.. I cannot use syntax such as:

gradle -Dtest.single=K* test

to control test execution for spock (only junit)

It would be great to have this ability with spock and/or some type of test 
suite capability.

I have about 500 tests.. and at times I'd love to not have to run ALL OF THEM 
every time :)

Original issue reported on code.google.com by rstud...@gmail.com on 25 Jun 2013 at 12:03

GoogleCodeExporter commented 9 years ago
Works fine for me.

Original comment by pnied...@gmail.com on 25 Jun 2013 at 4:30

GoogleCodeExporter commented 9 years ago
hrm.. 100% of the times I try, it runs 100% of my tests hah.

Original comment by rstud...@gmail.com on 25 Jun 2013 at 6:14

GoogleCodeExporter commented 9 years ago
Note the correct syntax is 

-D{testTask}.single=MyTest

If your tests are executed in a task called `testRelease` for instance, you 
have to specify 

-DtestRelease.single=MyTest

But as reported by the author of this issue, using this seems to force the 
usage of JUnit test runner rather than the Spock one. So for me there is still 
an issue.

Original comment by thomas.bruyelle@gmail.com on 6 Nov 2013 at 7:51

GoogleCodeExporter commented 9 years ago
I'd need a way to reproduce this. We regularly use `-Dtest.single` for Spock 
tests without any problems.

Original comment by pnied...@gmail.com on 6 Nov 2013 at 6:05

GoogleCodeExporter commented 9 years ago
Just tried again with Gradle 1.8 and it worked fine. If there is a problem 
here, it's likely on Gradle's side. If you could provide a self-contained 
reproducible example over at http://forums.gradle.org, that would be great.

In general, it's better to let the build tool or IDE control which tests to 
execute. In terms of test suites, you can use JUnit test suites. There is also 
Spock's `@IgnoreRest`, and you can use includes/excludes in Spock's 
configuration file (the latter isn't currently documented much).

I'm closing this issue as I think there isn't much that Spock can do here. 
Perhaps we can one day provide something better than JUnit's test suites, but 
that's a different story.

Original comment by pnied...@gmail.com on 6 Nov 2013 at 6:18

GoogleCodeExporter commented 9 years ago
Did your test still run if you use closure in a then: block ?

Something like

then:
1 * view.setAttachments({ it?.size == 3 })

That's the way I reproduce the issue. Without the closure, it works fine. 
Please give a try and tell us.

Original comment by thomas.bruyelle@gmail.com on 6 Nov 2013 at 8:37

GoogleCodeExporter commented 9 years ago
Works fine for me even in that case. If you can provide a self-contained 
reproducible example over at http://forums.gradle.org, I'll have another look.

Original comment by pnied...@gmail.com on 6 Nov 2013 at 10:10