Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for single test method execution (GRADLE-2865) #193

Closed
wants to merge 1 commit into from

Conversation

matthauck
Copy link

Add support to specify list of test method names using test.single property, with the (optional) format: -Dtest.single=TestClassName#method1,method2.

I show all tests passing on subprojects/plugins. Played around with some real testng and junit test code and was able to successfully run only the method(s) specified. Also tested to make sure not specifying any test method names still does indeed run all test methods in the class.

Add support to specify list of test method names using `test.single` property, with the (optional) format: `-Dtest.single=TestClassName#method1,method2`.
@matthauck
Copy link
Author

Haven't seen any responses yet... Is this a suitable implementation?

@matthauck
Copy link
Author

Started to look at this a week or two ago. I actually didn't find much guidance in that doc at all in terms of how these options would be passed via command line.

If the internal implementation is agreeable, then I would request the change be merged as is since it provides the functionality that is missing now without adding any new -D style options, but simply adds on the use of a current existing option. It seems that this does not make the issue any worse than it is today.

Also, I would say that the way the settings get propagated internally is not the most important part of this feature, and it would be good to have the basic capability merged now, and deal later with the interface change of how to configure it when that change actually begins to take place.

@mockitoguy
Copy link
Contributor

Thanks for feedback.

There's a value in pushing back on improving features that are based on legacy APIs. This is our way to force ourselves and the community to keep on improving the quality. Even if it means longer wait times for improvements, in the long term it pays off.

Nevertheless, I'm really tempted to get some traction on this feature. I also completely respect your opinion that you'd rather have the feature in place and the API sorted out later. I should have some time this week to get started on this. Not sure what comes out it, at least we should get the spec detailed properly.

I ask you for a little bit of more patience. I'll be back :)

@mockitoguy
Copy link
Contributor

Hey Matt,

I've started working on this. Take a look at the spec: https://github.com/gradle/gradle/blob/master/design-docs/test-selection.md#single-test-method-execution

I will definitely inspire on your implementation

@matthauck
Copy link
Author

Glad to hear this got into 1.10! Hope my initial work on it was somewhat helpful.

I'm trying this on 1.10 and running into a bit of an issue. It's including more test classes than I want it to. If I do gradle test --tests *JdbcConfigTest.testDerbyWithURL, it does properly only test that one method from the JdbcConfigTest class, but it also includes all tests from a BetterFileUtilsTests class... Am I doing something wrong here?

Also, this pull request and issue gradle-2865 should probably be closed, no?

@pniederw
Copy link
Contributor

Other people have reported similar issues. Looks like it isn't working as it should.

@adammurdoch
Copy link
Member

Thanks again for the pull request.

@matthauck
Copy link
Author

doh. looks like it doesn't work on 1.11 either. any chance to see this fixed soon?

@ldaley
Copy link
Member

ldaley commented Feb 19, 2014

@matthauck can you please raise this problem on the forum with details. It could get lost here.

@mockitoguy
Copy link
Contributor

@matthauck we don't really know about a problem with test filtering. It works for our codebase and for our integration tests. If you provide enough details we will be able to reproduce and fix the problem. Does the BetterFileUtilsTests test is peculiar in any way? Does it use a custom runner? It would be ideal if you posted the details of the problem to the forums.

@matthauck
Copy link
Author

ok. posted. http://forums.gradle.org/gradle/topics/test_selection_with_tests_argument_does_not_appear_to_work

Matt Hauck

On Wednesday, February 19, 2014 at 11:50 PM, Szczepan Faber wrote:

@matthauck (https://github.com/matthauck) we don't really know about a problem with test filtering. It works for our codebase and for our integration tests. If you provide enough details we will be able to reproduce and fix the problem. Does the BetterFileUtilsTests test is peculiar in any way? Does it use a custom runner? It would be ideal if you posted the details of the problem to the forums.


Reply to this email directly or view it on GitHub (#193 (comment)).

@naimdjon
Copy link

Seems like ability to run a single test method is still relevant today. Any progress on this issue?

@larisagrecu
Copy link

larisagrecu commented Sep 19, 2016

I am trying to run a single test method with *gradlew test --tests TestName.testMethod, but I have this error:

 What went wrong:
Execution failed for task ':test'.
> No tests found for given includes: [*TestName.testMethod]

Can someone tell me what am I doing wrong?
Thank you!

@jjohannes
Copy link
Contributor

Please post this kind of questions in the Gradle discussion forum:
https://discuss.gradle.org/c/help-discuss

Anyhow, the test section you described above should work with the current Gradle release (3.1).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants