-
Notifications
You must be signed in to change notification settings - Fork 541
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
Surefire-1584: Add option to rerun failing tests for JUnit5 #245
Conversation
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.
@sormuras this is your realm :)
@jon-bell |
7406a95
to
2558e28
Compare
@Tibor17 - This was prepared by my student and I - that's why you see both of our names. As you requested, I have rebased all of the changes into a single commit. I confirm that All of the changed/added files are formatted as-per the Maven/IntelliJ code formatter. |
...junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/RunListenerAdapter.java
Show resolved
Hide resolved
@@ -259,4 +261,50 @@ else if ( testSource.filter( ClassSource.class::isInstance ).isPresent() ) | |||
return new String[] { source, source, display, display }; | |||
} | |||
} | |||
|
|||
public String[] toClassMethodNameWithoutPlan( TestIdentifier testIdentifier ) |
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 am not totally convinced about this method because there is already one which returns String[4]
. I would vote for a generic approach avoiding code duplication in single 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.
Are you referring to toClassMethodName
? That couldn't be used because at the time of requesting class names for reruns the plan is set to null
. Perhaps adding a null check in the original method that provides the same logic as what's implemented in this extra method would suffice? Or were you thinking of a different approach?
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.
@Tibor17 - We've been trying hard to come up with a work around so that the existing toClassMethodName
can be used for both cases, but are stumped with an approach that would be more generic. Do you have any suggestions?
...it-platform/src/main/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProvider.java
Outdated
Show resolved
Hide resolved
surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformRerunFailingTestsIT.java
Outdated
Show resolved
Hide resolved
@jon-bell |
surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformRerunFailingTestsIT.java
Outdated
Show resolved
Hide resolved
I found docs for |
We of course have to mention JUnit 5 in JavaDoc. You can see the practice in another parameters that we say |
@Col-E Additionally, we have to update the chart |
So
Is the remark for clarifying support as of 3.0.0-M4? |
yes, for both, that's ok and enough as you have mentioned. |
Ok, all suggestions have been addressed except for the usage of |
The diff in Github is not enough for me, so I have to see the entire class for |
surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformRerunFailingTestsIT.java
Show resolved
Hide resolved
surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformRerunFailingTestsIT.java
Outdated
Show resolved
Hide resolved
@Tibor17 do you have any thoughts about refactoring |
Are there any plans when this will be merged an available? |
@jon-bell So I have compared these two methods, namely: The solution is very simple:
with
|
One can see that the method must alter the behavior . In practice we do it easily the way that we have algorithm in one method
and another public method:
In our case true: real class/method names without plan |
@Col-E |
I noticed that: source = testPlan.getParent( testIdentifier )
.map( this::toClassMethodName ) should probably be: source = testPlan.getParent( testIdentifier )
.map( i -> toClassMethodName( i, usePlan ) ) I think that should be it for any possible regressions. Fixed in 9886eb5. |
@Col-E |
See: this discussion for the new commit's reasoning. It resolves the ITS failures. |
@quiram |
I have managed to create a sample project to reproduce this, it's as simple as using Since @Col-E will need a new PR, shall I create a new issue to handle this? |
@quiram |
@quiram |
I've created https://issues.apache.org/jira/browse/SUREFIRE-1701 Also, I fixed the code so the tests will pass as soon as the functionality is fixed (the previous version simply showed the difference in retries as part of the output, but all tests failed nonetheless). |
This is actually a one character fix 🤦♂️ JUnitPlatformProvider - Line 195 When writing
Changing |
@Col-E |
@Col-E |
I've seen your post and it didn't change behavior in this case, but I think it would be wise to implement just to be safe. And yes, |
I wish all fixes were as easy as this 😄. I'm glad we got to the bottom of it. |
Did you check how this feature works with parameterized tests from JUnit5? I know it's an experimental feature, but we use it quite a lot in our environment. As off now I tried it myself with the latest snapshot version and with a few simple tests, with the results that parameterized tests aren't rerun when they fail, and if one of the tests does succeed the whole test case is marked as a success. This does defy the purpose of the parameterized tests, as they test different behaviours in our case. |
@Seijan |
@Seijan |
@Tibor17 Your For this use case, I'd recommend using a |
@Col-E |
@Col-E |
Just to be sure, we're on the same page, the test tree looks like this:
If you're looking for a technical name for |
@Col-E |
@Tibor17 |
@Tibor17 Applied the changes using What title do you want for the PR? |
@Col-E And then the next issue would go with ParmeterizedTest only and not rerun saying that the Parameterize test should have different name for every combination of parameters. If we use |
Yes it is a fix for this PR. I would not call this "new code" though if we are talking in terms of code coverage.
I agree.
I do not understand why the legacy name should be used over We can even roll back the changes to |
@Col-E |
@Col-E |
Hi,
@Col-E and I have put together a patch (with test) to support
rerunFailingTestCount
forJunitPlatformProvider
. Please let us know if you have any questions or need any edits.