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

Make listener finished method work with reverse insertion order #2627

Merged
merged 1 commit into from
Aug 24, 2021

Conversation

dianny123
Copy link
Contributor

Now the listener start method and finished method worked with insertion
order, this commit changes the finished method worked with reverse
order.

Fixes #2558 .

@dianny123 dianny123 force-pushed the listenerOrder branch 2 times, most recently from 0facded to 4d1b3f1 Compare August 16, 2021 03:15
@dianny123
Copy link
Contributor Author

comments fixed, pls have a look, thanks!

@krmahadevan
Copy link
Member

@dianny123 - Thanks for taking the time to help raise this PR. Once @juherr takes a quick look and approves, we can get this merged. I believe that @juherr is on a personal time off. So lets wait for him to be back

@@ -54,7 +55,12 @@ protected void runInvokedMethodListeners(

InvokedMethodListenerInvoker invoker =
new InvokedMethodListenerInvoker(listenerMethod, testResult, testResult.getTestContext());
for (IInvokedMethodListener currentListener : m_invokedMethodListeners) {
boolean isBeforeInvocation = InvokedMethodListenerMethod.BEFORE_INVOCATION == listenerMethod;
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 add a comment which explains why we have a specific behavior for BEFORE_INVOCATION?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For BEFORE_INVOCATION method, still run as insert order, but regarding AFTER_INVOCATION, it should be reverse order.

Copy link
Member

Choose a reason for hiding this comment

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

Why not, but why is it important? How/where can we track the rule?

Could you implement what you describe by replacing isBeforeInvocation with isAfterInvocation?

@@ -232,7 +233,12 @@ public FailureContext retryFailed(
}

public void runTestResultListener(ITestResult tr) {
TestListenerHelper.runTestListeners(tr, m_notifier.getTestListeners());
boolean isStarted = tr.getStatus() == ITestResult.STARTED;
Copy link
Member

Choose a reason for hiding this comment

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

@@ -87,7 +84,12 @@ public void endTest(Test test) {

org.testng.internal.TestResult tr = recordResults(test, tri);

TestListenerHelper.runTestListeners(tr, m_parentRunner.getTestListeners());
boolean isStarted = tr.getStatus() == ITestResult.STARTED;
Copy link
Member

Choose a reason for hiding this comment

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

Now the listener start method and finished method worked with insertion
order, this commit changes the finished method worked with reverse
order.
@krmahadevan krmahadevan merged commit b703fdc into testng-team:master Aug 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants