-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Updated Status in afterInvocation() not considered #1611
Conversation
Github1600Listener listener = new Github1600Listener(); | ||
TestListenerAdapter tla = new TestListenerAdapter(); | ||
tng.addListener((ITestNGListener) tla); | ||
tng.addListener((ITestNGListener) listener); |
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'm just thinking a TestNG#addListeners(ITestNGListener... listeners)
could be awesome.
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.
Its use would be limited to just us for writing our unit tests, and to those that use the TestNG APIs directly (perhaps the IDE plugins and the build tool plugins). I dont see much of a use for this in other places. But yes, I agree, it would be simple change.
@@ -1167,11 +1168,18 @@ private void handleInvocationResults(ITestNGMethod testMethod, | |||
} | |||
} | |||
|
|||
private static int computeTestStatusComparingTestResultAndStatusHolder(ITestResult testResult, StatusHolder holder, | |||
boolean wasResultUnaltered) { | |||
if (wasResultUnaltered) { |
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 don't understand well. What are the value of holder.status
and testResult.getStatus()
before and after handleInvocationResults, and before/after your fix?
Maybe testResult.getStatus() == holder.status
can replace wasResultUnaltered?
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.
No that wouldn't work. holder.status
represents the computed status by us, taking into account the expectedExceptions
attribute of an @Test
annotation. So for an e.g., if an @Test
method threw a org.testng.SkipException
then its status would be FAILURE
(because it threw an exception) but our computed status for holder.status
would be SKIP
(since we have a special meaning for SkipException
).
So if we merely stuck to evaluating testResult.getStatus() == holder.status
we end up using testResult.getStatus()
which is incorrect.
The testResult.getStatus()
value should be considered only if it was altered by the user defined IInvokedMethodListener
implementations (which is what #1600 is asking for).
In all other cases, we should only consider holder.status
Since 6.13
Just want to make sure :) |
It doesn't shock me in the listener context and I think it is a better practice. |
@juherr It is a regression, but I'm not sure if it is a planned change or not. After upgrading to 6.13 it stopped working, because |
Regressions are never expected :) And TestNG should be able to catch the skip exception and set the status accordingly. A new issue is a better location for the discussion and we will be able to close it if we want ;) |
Closes #1600
Fixes #1600 .
Did you remember to?
CHANGES.txt
We encourage pull requests that:
If your pull request involves fixing SonarQube issues then we would suggest that you please discuss this with the
TestNG-dev before you spend time working on it.