-
Notifications
You must be signed in to change notification settings - Fork 132
MQE-1884: MFTF - <after> failures override other failures #507
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
Conversation
attaching suppressed exception before _after hook failure to current step.
fixed static checks
fixed static checks
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.
} | ||
}; | ||
$firstException = $change->call($exception); | ||
$bind = function () use ($firstException) { |
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 not sure what 173~176 do. ExceptionWrapper.php
does not have a variable named $exception
, and at this point you already have the thing you need to log.
Is this leftover test flow or something like that?
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.
removed the redundant code.
bumped up codeception version to 2.4.5 to be inline with magento version. Removed method runAfterBlock, 2.4.5 runs _after hook implicitly.
* @param \Exception $exception | ||
* @return mixed | ||
*/ | ||
public function logPreviousException(\Exception $exception) |
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.
Question:
- Should we attach every exception, not just the buried one? It feels strange to see a test fail in two steps but only see one
Exception
attached. We could even label itBefore/Test/After Exception
using some functions in this class already.
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.
Those were my initial thoughts too, but looks like After
block's exception stack trace appears in the allure report twice - one at the top and another at the bottom after test steps. Will it be a duplication in some way? Capturing context and appending it to attachment name would work, however, there will only be 1 exception in Before + Test body
scope, would context be redundant to display? Also looks like Allure doesn't show clear separation of Before/Test/After
blocks of the test. What are your thoughts?
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.
So good news is that with just Codeception 2.4.0 we can do a couple things:
- Stop iterating over errors on line 88, they will only now be parent->previous() relationship
- Given above, we can instead iterate by doing logError($error), wherein we log the parent, check for child and call logError($childError) to pop the full stack
- remove the
testFail()
hook entirely, just usetestEnd()
to log these
We can modify the hook to look something like:
...
$testResultObject = call_user_func(\Closure::bind(
function () use ($cest) {
return $cest->getTestResultObject();
},
$cest
));
if (!empty($testResultObject->errors())) {
foreach ($testResultObject->errors() as $error) {
$this->attachExceptionToAllure($error->thrownException());
}
}
if (!empty($testResultObject->failures())) {
foreach ($testResultObject->failures() as $error) {
$this->attachExceptionToAllure($error->thrownException());
}
}
...
We can end up with something like this
You could add to the signature of attachExceptionToAllure
to inlcude a prefix like Error
vs Failure
as well for clearer deliniation.
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.
Even if we have some duplication, I think if we lean on prefixing the attachments it would be best in case someone needs the info. Those can be ignored by simply not expanding them.
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.
Added context as a prefix to the attachment. Including a prefix like Error
or Failure
may need more investigation. From what I understood, PHPUnit\Framework\Exception
are marked as failures and Magento\Framework\Exception
are marked as Errors. Maybe there are exceptions which don't follow this criteria.
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 think you are right in not trusting that the exception types are necessarily linked to failure vs error. You could include them in the signature of your new attachExceptionToAllure
but I think having the prefix is enough for now.
Attached stack trace of full stack of exceptions Attachment name now has the test hook method in which the exception occured Removed test fail method
removed redundant var; code cleanup.
fixed static checks
src/Magento/FunctionalTestingFramework/Extension/TestContextExtension.php
Show resolved
Hide resolved
Added mapping to contexts for allure attachments.
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 left a comment on the internal ticket, check that out before merging please!
attaching suppressed exception before _after hook failure to current step.
Description
Fixed Issues (if relevant)
Contribution checklist