How to update test scenario status at runtime with Reqnroll+MSTest #529
-
Hello, In my C# Reqnroll + MSTest + Allure.Reqnroll plugin project, test scenario execution is being intentionally skipped based on some flag, for eg: execute test for US and skip using Assert.Inconclusive("This test is intentionally skipped for other countries") if any other country is specified in Feature file test data. Note: Initially, when I am getting TestResults object --> testResult.status for current Test is set to none After the scenario is executed, I am updating test status in AfterScenario hook using following code AllureLifecycle.Instance.UpdateTestCase(testResult =>
{
foreach (var x in testResult.steps)
{
if ((x.status.Equals(Status.failed) || x.status.Equals(Status.broken)) && x.statusDetails != null && !string.IsNullOrWhiteSpace(x.statusDetails.message) && (x.statusDetails.message.Contains("intentionally skipped") || x.statusDetails.message.Contains("ignored tests")))
{
x.status = Status.skipped;
}
}
testResult.status = Status.skipped;
testResult.statusDetails.message = "intentionally skipped";
}); While debugging, I can see that the testResult.Status is updated to skipped in the Current TestContext . Can anyone please look into this and suggest the right way to update test 'status' based on exception thrown? Note: This is working fine with Specflow+Xunit and Specflow +MSTest using AllureLifecycle.Instance.UpdateTestcase. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Isn't this a question for Allure.Reqnroll? |
Beta Was this translation helpful? Give feedback.
-
@singh-swati28 Have you tried to set an order for your after scenario hook to be delayed? Like |
Beta Was this translation helpful? Give feedback.
Hi, @gasparnagy !
Allure.Reqnroll plugin developer confirmed that this is a bug which will be fixed eventually. They have not given any ETA for this.
(https://github.com/orgs/allure-framework/discussions/2921)
In the meantime, could you please suggest some workarounds or how to override Reqnroll test listener to update test status based on certain exceptions/stacktrace? Something like, override method OnScenarioFailure/OnStepFailure to update status?
Thank you for your help!
Regards,
Swati