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

--filter option implemented. #647

Merged
merged 23 commits into from
Jun 5, 2013
Merged

--filter option implemented. #647

merged 23 commits into from
Jun 5, 2013

Conversation

noel-yap
Copy link
Contributor

@noel-yap noel-yap commented Mar 1, 2013

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.

@@ -304,6 +308,63 @@ private static boolean hasNull(Class<?>... classes) {
}
return false;
}

private static class CategoryFilterWrapper extends Filter {
Copy link
Member

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

Copy link
Contributor Author

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.

@kcooney
Copy link
Member

kcooney commented Mar 1, 2013

@noel-yap Overall looks very nice. Like the tests :-)

@dsaff
Copy link
Member

dsaff commented Mar 1, 2013

@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.

@noel-yap
Copy link
Contributor Author

noel-yap commented Mar 1, 2013

@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.

@noel-yap
Copy link
Contributor Author

noel-yap commented Mar 1, 2013

Some stuff I still need to do:

  • JavaDoc
  • tests for new code (yeah, I didn't TDD this)
  • factor out the command line parsing

Some open issues:

  • Is it OK to introduce a dependency on a third-party command-line parser? I'm guessing it's not OK, but I don't want to make assumptions.

@dsaff
Copy link
Member

dsaff commented Mar 1, 2013

@noel-yap,

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);
Copy link
Member

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

Copy link
Contributor Author

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.
@dsaff
Copy link
Member

dsaff commented Mar 7, 2013

@noel-yap,

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) {
Copy link
Member

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@dsaff
Copy link
Member

dsaff commented May 29, 2013

@noel-yap, thanks for the updates. It may be a day or two before I can review again.

@noel-yap
Copy link
Contributor Author

noel-yap commented Jun 4, 2013

@dsaff , ping.

@dsaff
Copy link
Member

dsaff commented Jun 5, 2013

Thanks. Merging. Can you add a section to the release notes at https://github.com/junit-team/junit/wiki/4.12-release-notes? Thanks.

dsaff pushed a commit that referenced this pull request Jun 5, 2013
--filter option implemented.
@dsaff dsaff merged commit aeaecd2 into junit-team:master Jun 5, 2013
@marcphilipp
Copy link
Member

The Jenkins build failed after merging this pull request:

[ERROR] https://junit.ci.cloudbees.com/job/JUnit/ws/src/main/java/org/junit/experimental/categories/CategoryFilterFactory.java:[22,5] method does not override a method from its superclass

See https://junit.ci.cloudbees.com/job/JUnit/46/console for details.

@noel-yap
Copy link
Contributor Author

noel-yap commented Jun 5, 2013

I'll get on it ASAP.
On Jun 5, 2013 6:22 AM, "Marc Philipp" [email protected] wrote:

The Jenkins build failed after merging this pull request:

[ERROR]
https://junit.ci.cloudbees.com/job/JUnit/ws/src/main/java/org/junit/experimental/categories/CategoryFilterFactory.java:[22,5]
method does not override a method from its superclass

See https://junit.ci.cloudbees.com/job/JUnit/46/console for details.


Reply to this email directly or view it on GitHubhttps://github.com//pull/647#issuecomment-18974939
.

@noel-yap
Copy link
Contributor Author

noel-yap commented Jun 5, 2013

@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?

@marcphilipp
Copy link
Member

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 @Override.

Does it compile in Eclipse?

@noel-yap
Copy link
Contributor Author

noel-yap commented Jun 5, 2013

I use IntelliJ and it compiles fine there as well as from the command line.
I'll take out the annotation ASAP.
On Jun 5, 2013 11:41 AM, "Marc Philipp" [email protected] wrote:

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
@OverRide.

Does it compile in Eclipse?


Reply to this email directly or view it on GitHubhttps://github.com//pull/647#issuecomment-18998756
.

@dsaff
Copy link
Member

dsaff commented Jun 5, 2013

Thanks, @noel-yap. I'm going on vacation in a couple hours--any chance of a pull request before then? Thanks!

@noel-yap
Copy link
Contributor Author

noel-yap commented Jun 5, 2013

I just pushed an update.

On Wed, Jun 5, 2013 at 12:19 PM, David Saff [email protected]:

Thanks, @noel-yap https://github.com/noel-yap. I'm going on vacation in
a couple hours--any chance of a pull request before then? Thanks!


Reply to this email directly or view it on GitHubhttps://github.com//pull/647#issuecomment-19001831
.

@marcphilipp
Copy link
Member

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.

@noel-yap
Copy link
Contributor Author

noel-yap commented Jun 5, 2013

Done.

On Wed, Jun 5, 2013 at 1:04 PM, Marc Philipp [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.


Reply to this email directly or view it on GitHubhttps://github.com//pull/647#issuecomment-19004630
.

@marcphilipp
Copy link
Member

Unfortunately, there are a couple more of those in the test source folder:

[ERROR] /scratch/jenkins/workspace/JUnit/src/test/java/org/junit/experimental/categories/CategoryFilterFactoryTest.java:[45,25] createFilter(java.lang.Class[]) in org.junit.experimental.categories.CategoryFilterFactoryTest.CategoryFilterFactoryStub cannot override createFilter(java.lang.Class...) in org.junit.experimental.categories.CategoryFilterFactory; overriding method is missing '...'
[ERROR] /scratch/jenkins/workspace/JUnit/src/test/java/org/junit/experimental/categories/CategoryFilterFactoryTest.java:[45,25] createFilter(java.lang.Class[]) in org.junit.experimental.categories.CategoryFilterFactoryTest.CategoryFilterFactoryStub cannot override createFilter(java.lang.Class...) in org.junit.experimental.categories.CategoryFilterFactory; overriding method is missing '...'
[ERROR] /scratch/jenkins/workspace/JUnit/src/test/java/org/junit/runner/FilterFactoriesTest.java:[68,9] method does not override a method from its superclass
[ERROR] /scratch/jenkins/workspace/JUnit/src/test/java/org/junit/runner/FilterFactoriesTest.java:[75,9] method does not override a method from its superclass
[ERROR] /scratch/jenkins/workspace/JUnit/src/test/java/org/junit/runner/JUnitCommandLineParseResultTest.java:[139,9] method does not override a method from its superclass

@noel-yap
Copy link
Contributor Author

noel-yap commented Jun 5, 2013

I think the I caught the rest in the latest pull request. Let me know if
there's still brokenness.

Thanks,
Noel
On Jun 5, 2013 1:44 PM, "Marc Philipp" [email protected] wrote:

Unfortunately, there are a couple more of those in the test source folder:

[ERROR]
/scratch/jenkins/workspace/JUnit/src/test/java/org/junit/experimental/categories/CategoryFilterFactoryTest.java:[45,25]
createFilter(java.lang.Class[]) in org.junit.experimental.categories.CategoryFilterFactoryTest.CategoryFilterFactoryStub cannot override createFilter(java.lang.Class...) in
org.junit.experimental.categories.CategoryFilterFactory; overriding method
is missing '...'
[ERROR]
/scratch/jenkins/workspace/JUnit/src/test/java/org/junit/experimental/categories/CategoryFilterFactoryTest.java:[45,25]
createFilter(java.lang.Class[]) in org.junit.experimental.categories.CategoryFilterFactoryTest.CategoryFilterFactoryStub cannot override createFilter(java.lang.Class...) in
org.junit.experimental.categories.CategoryFilterFactory; overriding method
is missing '...'
[ERROR]
/scratch/jenkins/workspace/JUnit/src/test/java/org/junit/runner/FilterFactoriesTest.java:[68,9]
method does not override a method from its superclass
[ERROR]
/scratch/jenkins/workspace/JUnit/src/test/java/org/junit/runner/FilterFactoriesTest.java:[75,9]
method does not override a method from its superclass
[ERROR]
/scratch/jenkins/workspace/JUnit/src/test/java/org/junit/runner/JUnitCommandLineParseResultTest.java:[139,9]
method does not override a method from its superclass


Reply to this email directly or view it on GitHubhttps://github.com//pull/647#issuecomment-19007115
.

@kcooney
Copy link
Member

kcooney commented Jun 6, 2013

You could verify locally by running the tests in ant
On Jun 5, 2013 4:04 PM, "Noel Yap" [email protected] wrote:

I think the I caught the rest in the latest pull request. Let me know if
there's still brokenness.

Thanks,
Noel
On Jun 5, 2013 1:44 PM, "Marc Philipp" [email protected] wrote:

Unfortunately, there are a couple more of those in the test source
folder:

[ERROR]

/scratch/jenkins/workspace/JUnit/src/test/java/org/junit/experimental/categories/CategoryFilterFactoryTest.java:[45,25]

createFilter(java.lang.Class<?>[]) in

org.junit.experimental.categories.CategoryFilterFactoryTest.CategoryFilterFactoryStub

cannot override createFilter(java.lang.Class<?>...) in
org.junit.experimental.categories.CategoryFilterFactory; overriding
method
is missing '...'
[ERROR]

/scratch/jenkins/workspace/JUnit/src/test/java/org/junit/experimental/categories/CategoryFilterFactoryTest.java:[45,25]

createFilter(java.lang.Class<?>[]) in

org.junit.experimental.categories.CategoryFilterFactoryTest.CategoryFilterFactoryStub

cannot override createFilter(java.lang.Class<?>...) in
org.junit.experimental.categories.CategoryFilterFactory; overriding
method
is missing '...'
[ERROR]

/scratch/jenkins/workspace/JUnit/src/test/java/org/junit/runner/FilterFactoriesTest.java:[68,9]

method does not override a method from its superclass
[ERROR]

/scratch/jenkins/workspace/JUnit/src/test/java/org/junit/runner/FilterFactoriesTest.java:[75,9]

method does not override a method from its superclass
[ERROR]

/scratch/jenkins/workspace/JUnit/src/test/java/org/junit/runner/JUnitCommandLineParseResultTest.java:[139,9]

method does not override a method from its superclass


Reply to this email directly or view it on GitHub<
https://github.com/junit-team/junit/pull/647#issuecomment-19007115>
.


Reply to this email directly or view it on GitHubhttps://github.com//pull/647#issuecomment-19015104
.

@marcphilipp
Copy link
Member

It did not compile in Eclipse either. Now it does! I will merge #691.

@noel-yap Thanks! For the future, please check whether you can change your compiler settings in IntelliJ or use JDK5 to compile.

@dsaff
Copy link
Member

dsaff commented Nov 18, 2014

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?

@marcphilipp
Copy link
Member

@dsaff Do you have time to add this pull request to the release notes?

@dsaff
Copy link
Member

dsaff commented Nov 24, 2014

Sure, I can do it in the next day or so.

@marcphilipp
Copy link
Member

@dsaff Any news on this? I would not like to release 4.12 without this being documented.

@dsaff
Copy link
Member

dsaff commented Dec 3, 2014

OK, sorry for the delay. Taking a look now.

@dsaff
Copy link
Member

dsaff commented Dec 3, 2014

@stefanbirkner stefanbirkner added this to the 4.12 milestone Dec 4, 2014
@marcphilipp
Copy link
Member

LGTM, thanks!

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

Successfully merging this pull request may close these issues.

6 participants