[GRADLE-1553] -Dtest.single causes errors if there are projects with test tasks in buildSrc Created: 16/May/11  Updated: 06/Nov/14  Resolved: 06/Nov/14

Status: Resolved
Project: Gradle
Affects Version/s: 1.0-milestone-3
Fix Version/s: None

Type: Bug
Reporter: Luke Daley Assignee: Szczepan Faber
Resolution: Won't Fix Votes: 7

Attachments: Zip Archive gradle_test_single.zip    

 Description   

Gradle will fail when running the tests of the projects in buildSrc with:

Cause: Could not find matching test for pattern: «test.single pattern»


 Comments   
Comment by Luke Daley [ 15/Jun/11 ]

The solution is to use -D«project path».test.single to target a specific project.

Comment by Adam Murdoch [ 21/Jun/11 ]

Should we close this? It's a pretty poor behaviour, that we want to fix at some point.

Comment by Luke Daley [ 21/Jun/11 ]

I think you're right. I haven't been able to come up with any good ideas to this point though.

The best I've come up with is stopping command line system properties from propagating to the buildSrc build. I think you could make a case for this as the buildSrc build probably shouldn't be environmentally sensitive, but this still feels a bit drastic.

Comment by Luke Daley [ 21/Jun/11 ]

Assigning to m4 and downgrading to minor as there is a usable workaround in -D«target project path»:«test task name».single=«test»

So given a project named “thing” and a test task named “test”, this would be…

gradle -D:thing:test.single=«class name»
Comment by Davide Cavestro [ 29/Nov/13 ]

Please update the user guide with a reference to the workaround (at least until this issue is not fixed): I've struggled some hours to understand how to get selective tests running fine.

Comment by Luke Daley [ 29/Nov/13 ]

1.10 will have a new mechanism that will supersede this. We'll probably remove this method from the docs. Thanks for the reminder.

Comment by Davide Cavestro [ 29/Nov/13 ]

In the meantime I've attached into gradle_test_single.zip a reproducible test case for a side effect that I've not seen reported into this issue: when there are sources into the buildSrc folder of a multiproject root, then launching sub-projects tests with the -Dsingle.test property always fails (at least with gradle 1.9).

i.e.

./gradlew -Dtest.single=foo/ prj1:test

fails complaining Could not find matching test for pattern: foo/, while if you rename buildSrc to buildSrc.bak it works. However

./gradlew -Dprj1.test.single=foo/ prj1:test

always works

Comment by Davide Cavestro [ 29/Nov/13 ]

I've just updated gradle_test_single.zip with additional tests under the prj1 baz package, in order to demonstrate that running

./gradlew -Dprj1.test.single=foo/ :prj1:test

the foo pattern does not prevent tests under the baz package to be run.
I could be wrong, but at this point I find no ways to run only a subset of tests under a certain subproject.

Comment by Szczepan Faber [ 06/Nov/14 ]

Please use --tests for selecting the tests.

Generated at Wed Jun 30 11:58:26 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.