-
Notifications
You must be signed in to change notification settings - Fork 542
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
Remove TestListResolver#optionallyWildcardFilter #499
base: master
Are you sure you want to change the base?
Conversation
|
@@ -267,13 +270,16 @@ public void testShouldRunAny() | |||
public void testClassFilter() | |||
{ | |||
TestListResolver resolver = new TestListResolver( "#test" ); | |||
assertTrue( resolver.shouldRun( "pkg/MyTest.class", null ) ); | |||
assertTrue( resolver.shouldRun( "pkg/MyTest.class", "test" ) ); |
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.
Don't change the assertions.
It makes whole PR not trusty.
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.
try:
resolver = new TestListResolver( "#abc" );
assertTrue( resolver.shouldRun( "pkg/MyTest.class", null ) );
resolver = new TestListResolver( "#test" );
assertTrue( resolver.shouldRun( "pkg/Abc.class", null ) );
what we verify 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.
It means that whatever class should run.
This verifies ParentRunner in JUnit4.
If you type resolver.shouldRun( "pkg/Abc.class", "otherMethod" )
, it returns false because it verifies the child of ParentRunner. Methods do not match * = Abc but abc !=otherMethod
If shouldRun has null method then we compare classes => ParentRunner, and in this case * matches Abc => true
If shouldRun has non-null method, we evaluate test method.
@@ -401,19 +406,6 @@ public void testInclusiveWithDefaultExclusivePattern() | |||
assertTrue( runnable ); | |||
} | |||
|
|||
public void testWildcard() |
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.
This use case is still valid and the test should not be removed.
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.
but I removed ... #optionallyWildcardFilter
so what I should check?
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.
@slawekjaranowski
This test would be too simple if we have rewrite optionallyWildcardFilter
to **/*.class
.
...common-junit48/src/test/java/org/apache/maven/surefire/common/junit48/FilterFactoryTest.java
Show resolved
Hide resolved
return EMPTY; | ||
} | ||
|
||
public final boolean isWildcard() |
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.
This is still a valid case.
If TLR is empty (nothing) or a wildcard (everything), the provider would ignore TLR. But both corner cases may happen in the config.
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.
only one case is true for isWildcard
:
tlr = new TestListResolver( "*.class" );
assertTrue( tlr.isWildcard() );
@@ -432,7 +430,6 @@ private static boolean hasFilteredOutAllChildren( Description description ) | |||
|
|||
private Filter createMethodFilter() | |||
{ | |||
TestListResolver methodFilter = optionallyWildcardFilter( testResolver ); | |||
return methodFilter.isEmpty() || methodFilter.isWildcard() ? null : new TestResolverFilter( methodFilter ); | |||
return testResolver != null && testResolver.hasMethodPatterns() ? new TestResolverFilter( testResolver ) : null; |
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.
We are missing methodFilter.isWildcard()
in this PR.
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.
Wildcard class and wildcard method (i.e. *#*
, or **/*#*
) returns true
from hasMethodPatterns()
? If it is any wildcard, even this special case, the filter should be returned as null.
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.
I removed isWildcard
also ...
Test for master code:
tlr = new TestListResolver( "*.class" );
assertTrue( tlr.isWildcard() );
assertFalse( tlr.hasMethodPatterns() );
tlr = new TestListResolver( "*#*" );
assertFalse( tlr.isWildcard() );
assertTrue( tlr.hasMethodPatterns() );
tlr = new TestListResolver( "**/*#*" );
assertFalse( tlr.isWildcard() );
assertTrue( tlr.hasMethodPatterns() );
isWildicard()
return true only for *.class
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.
In expresion:
TestListResolver methodFilter = optionallyWildcardFilter( testResolver );
return methodFilter.isEmpty() || methodFilter.isWildcard()
? null : new TestResolverFilter( methodFilter );
methodFilter.isEmpty()
always return false
methodFilter.isWildcard() != methodFilter.hasMethodPatterns()
is always true
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.
@slawekjaranowski
I know what you mean but the problem is that the expression
methodFilter.isWildcard() != methodFilter.hasMethodPatterns()
talks about implementation behavior.
The whole problem is that we adapt the tests for implementation behavior to pass because we trust the current behavior more than the tests.
Maybe the wildcard was not very properly implemented. Maybe it was, I do not remember, but if we remove some test or method we should compensate it with such strong tests and assertions where we would prove your logical expression. If hasMethodPatterns()
is enough, why do not you write unit test asserting isWildcard() != hasMethodPatterns()
for wildcards. That's the reason why I started the discussion.
The filter is useless and should be null or should not be used for wildcards and empty method patterns.
Why should we slow down the JUnit or TestNG with wildcard filters or why should we let the filtering mechanism to open some unknown bug?
tlr = new TestListResolver( "*#*" );
assertFalse( tlr.isWildcard() );
assertTrue( tlr.hasMethodPatterns() );
d9d914e
to
b1315fe
Compare
b1315fe
to
d27a848
Compare
Hi @slawekjaranowski , I will have time today late evening. |
Kindly reminder @Tibor17 or someone else ... 😄 |
Following this checklist to help us incorporate your
contribution quickly and easily:
for the change (usually before you start working on it). Trivial changes like typos do not
require a JIRA issue. Your pull request should address just this issue, without
pulling in other changes.
[SUREFIRE-XXX] - Fixes bug in ApproximateQuantiles
,where you replace
SUREFIRE-XXX
with the appropriate JIRA issue. Best practiceis to use the JIRA issue title in the pull request title and in the first line of the
commit message.
mvn clean install
to make sure basic checks pass. A more thorough check willbe performed on your pull request automatically.
mvn -Prun-its clean install
).If your pull request is about ~20 lines of code you don't need to sign an
Individual Contributor License Agreement if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the Apache License Version 2.0, January 2004
you have to acknowledge this by using the following check-box.
I hereby declare this contribution to be licenced under the Apache License Version 2.0, January 2004
In any other case, please file an Apache Individual Contributor License Agreement.