-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[JUnit] Add --[no-]step-notifications options to JunitOptions #1135
Conversation
3affec7
to
a9605e9
Compare
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.
@mpkorstanje I think the handling of the different versions of AssumptionViolatedException
needs to be fixed. Apart from that I think the PR looks good.
import gherkin.pickles.PickleStep; | ||
import org.junit.internal.runners.model.EachTestNotifier; | ||
import org.junit.internal.AssumptionViolatedException; |
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.
AFAIK this is the JUnit <4.12 class for the assume feature, JUnit 4.12 use another class, as we handle both classes in other places we should do it here to (see comment on usage).
public void addFailure(Throwable targetException) { | ||
if (targetException instanceof MultipleFailureException) { | ||
addMultipleFailureException((MultipleFailureException) targetException); | ||
} else if (targetException instanceof AssumptionViolatedException) { |
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.
The different versions of AssumtionViolatedException
s are kept in the array PENDING_EXCEPTIONS
, isPending()
searches the array, it could done here to (if also removing the cast of the argument to addFailedAssumption
- as it uses its argument it could accept a Throwable
)
As the PendingException
now is identified with an annotation instead of as a member of PENDING_EXCEPTIONS
, there is a case for renaming PENDING_EXCEPTIONS
to something with ASSUMPTION_VIOLATED
or something - but it does not directly has anything to do with this pull request.
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.
Mmh. Good point. I'm not happy about using junit internal here either.
d46384f
to
a2f06e0
Compare
@brasmusson Fixed and I've added tests for good measure. |
f2888f0
to
a2f06e0
Compare
When interacting with cucumber in an IDE it is nice to see the step executions. However presenting step executions to surefire as tests results in strange test counts and weird reports. The --no-step-notifications options ensures steps are not included in descriptions and no events are fired for the execution of steps. Related issues: - #263 - #577
a2f06e0
to
6beaa7e
Compare
* Extract Runtime.isAssumptionViolated from Runtime.isPending. * Use Runtime.isAssumptionViolated as the condition for fireTestAssumptionFailed
@@ -202,7 +203,7 @@ public void fireTestFinished() { | |||
public void addFailure(Throwable targetException) { | |||
if (targetException instanceof MultipleFailureException) { | |||
addMultipleFailureException((MultipleFailureException) targetException); | |||
} else if (isPending(targetException)) { | |||
} else if (isAssumptionViolated(targetException)) { |
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.
Do you intend to count the pending exception as a failure? I'm not entirely sure how pending items should be reported? I guess this should depend on the strict setting.
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.
The Cucumber-JVM statuses passed
, skipped
, undefined
, pending
, failed
are mapped to the JUnit statuses passed
, skipped
, failure
, error
, as:
passed
->passed
skipped
->skipped
failed
->failure
undefined
,pending
->skipped
unless in strict mode where they are mapped tofailure
We do not end up here for apending
result unless in strict mode, if in non-strict mode we go straight tofireTestIgnored
With this PR there is a change in how AssumptionViolatedException
s are notified, previously they would cause a fireTestIgnored
in non-strict mode and fireTestFailure
in strict mode, now they will cause a fireTestIgnored
in non-strict mode and fileTestAssumptionFailed
in strict mode. I intended to accept that and view it as a part of the fix to #1007.
Now that I know about the fileTestAssumptionFailed
I think it should be used instead of fireTestIgnored
to signal "skipped" for passed
, skipped
, undefined
and pending
statuses (the latter only in non-strict mode of course), but that is another 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.
Makese sense.
That made not sense. Surefire is using a test name as the name of scenario. I think it's cause by misfiring a notifier but I can't say for sure. <testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-failsafe-plugin/xsd/failsafe-test-report.xsd" name="Say hello" time="0.367" tests="8" errors="0" skipped="0" failures="1"> |
It appears there are lots of implicit assumptions in junit4/surefire about the name of tests. Somebody already reported it as #865. So I think we're good to go here. This problem needs its own PR. |
@mpkorstanje Could we release a new version with this fix? Rather annoying bug :( |
Hey @longtimeago we're currently working on releasing 2.0.0. There are a few issues we have to clean up first and then we'll be good to go. This may take some time as we're working with 3 people and spare time at the moment. You can however get our snapshot builds by using:
|
@mpkorstanje Sure, no problem :) Just wanted to know some if there is a movement towards that :) |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Summary
Improve surefire integration.
Motivation and Context
Because cucumber presents the steps as tests to junit surefire provides
an incorrect test counts and reports strange names. By adding
--[no-]step-notifications
to JunitOptions this can be avoided.Related Issues:
How Has This Been Tested?
Added PickleRunnerWithNoStepDescriptionsTest and PickleRunnerWithStepDescriptionsTest to
ensure both work as expected.
Types of changes
Checklist: