-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
--filter option implemented. #647
Conversation
@@ -304,6 +308,63 @@ private static boolean hasNull(Class<?>... classes) { | |||
} | |||
return false; | |||
} | |||
|
|||
private static class CategoryFilterWrapper extends Filter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? CategoryFilter extends Filter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CategoryFilterWrapper removed. Code changed to use CategoryFilter.
@noel-yap Overall looks very nice. Like the tests :-) |
@noel-yap, looking forward to checking this out. Your comments indicate that another commit is on its way, so I may wait to get all the changes at once. SuiteTest.suiteShouldBeOKwithNonDefaultConstructor() is asserting that since we never try to construct the class to which @RunWith(Suite.class) is attached, we shouldn't do any validation of any constructors we might find on that class. I forget now what the use case is, but if it's possible to not break it, it would be ideal. |
@dsaff , after making some of the changes @kcooney suggested, all tests now pass. I slightly suspect it's from replacing PassThroughFilter with Filter.ALL (since all other changes have been more aesthetic), but even that change doesn't look like it does much different. Anyway, all tests pass now so I'm not gonna investigate further. |
Some stuff I still need to do:
Some open issues:
|
Yes, I'd really prefer to avoid a third-party command-line parser. My hope (fingers crossed) is that we can keep it simple enough to make rolling our own cost-effective. |
List<Class<?>> categoryClasses = new ArrayList<Class<?>>(); | ||
|
||
for (String category : categories.split(",")) { | ||
Class<?> categoryClass = Class.forName(category); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here you are using Class.forName() instead of the context class loader
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
Fixed the one in JUnitCore, too.
"--filter arg" support added (as opposed to "--filter=arg"). Command line parser factored into JUnitCommandLineParser class. Unit tests added.
Looks like this has drifted against HEAD. Can you pull/merge/push? Thanks. |
Conflicts: src/test/java/org/junit/tests/AllTests.java
*/ | ||
public final class ExcludeCategories extends CategoryFilterFactory { | ||
@Override | ||
public Filter createFilter(Class<?>[] categories) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use varargs here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@noel-yap, thanks for the updates. It may be a day or two before I can review again. |
@dsaff , ping. |
Thanks. Merging. Can you add a section to the release notes at https://github.com/junit-team/junit/wiki/4.12-release-notes? Thanks. |
The Jenkins build failed after merging this pull request:
See https://junit.ci.cloudbees.com/job/JUnit/46/console for details. |
I'll get on it ASAP.
|
@marcphilipp and @dsaff , I am unable to reproduce this error. Also, CategoryFilterFactory implements FilterFactory which is part of the pull request so I'm not sure how this error can be occurring. I looked through the workspace in https://junit.ci.cloudbees.com/job/JUnit/ and both https://junit.ci.cloudbees.com/job/JUnit/ws/src/main/java/org/junit/experimental/categories/CategoryFilterFactory.java/*view*/ and https://junit.ci.cloudbees.com/job/JUnit/ws/src/main/java/org/junit/runner/FilterFactory.java/*view*/ look good. Any ideas what may be causing this error? Is it complaining about the @OverRide annotation? |
We're still using JDK5 in order to stay useable by "old" projects. In JDK5 you cannot annotate a method that implements an interface method with Does it compile in Eclipse? |
I use IntelliJ and it compiles fine there as well as from the command line.
|
Thanks, @noel-yap. I'm going on vacation in a couple hours--any chance of a pull request before then? Thanks! |
I just pushed an update. On Wed, Jun 5, 2013 at 12:19 PM, David Saff [email protected]:
|
Your commit doesn't show up in this pull request, probably because it has already been merged. I think you have to create a new pull request. |
Done. On Wed, Jun 5, 2013 at 1:04 PM, Marc Philipp [email protected]:
|
Unfortunately, there are a couple more of those in the test source folder:
|
I think the I caught the rest in the latest pull request. Let me know if Thanks,
|
You could verify locally by running the tests in ant
|
I don't think this ever got added to the 4.12 release notes. It's a major feature in 4.12 (IMHO). Would anyone on this thread like to add it, or should I? |
@dsaff Do you have time to add this pull request to the release notes? |
Sure, I can do it in the next day or so. |
@dsaff Any news on this? I would not like to release 4.12 without this being documented. |
OK, sorry for the delay. Taking a look now. |
OK, tried my hand at a draft: Thanks! |
LGTM, thanks! |
Currently SuiteTest.suiteShouldBeOKwithNonDefaultConstructor() fails but I don't know what ought to be done about that. Under what circumstances does it make sense to have a Suite with no SuiteClasses? Suggestions?
I'll also be refactoring out the command line processing as per @kcooney and will writing more tests for the code that has changed.