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

Allure throwing uncaught exception that crashes entire XUnit test host process in Theory test methods with multiple cases #528

Open
1 of 3 tasks
Ryanaldo34 opened this issue Jul 8, 2024 · 1 comment

Comments

@Ryanaldo34
Copy link

Ryanaldo34 commented Jul 8, 2024

I'm submitting a ...

  • bug report
  • feature request
  • support request => Please do not submit support request here, see note at the top of this template.

What is the current behavior?

Allure seems to be crashing the entire XUnit due to an uncaught exception internally. This results in all tests not being ran completely.

If the current behavior is a bug, please provide the steps to reproduce and, if possible, a minimal demo of the problem

I am not sure how to reproduce this as it happens seemingly at random and on random tests. The only pattern I am noticing is it usually happens on XUnit Theory methods where there are multiple test cases. From the stack trace, it seems like it is happening when a failure is being applied to the report for the test case.

What is the expected behavior?

The test suite runs completely through without crashing completely before all tests have a chance to run.

What is the motivation / use case for changing the behavior?

So the test host process doesn't completely crash.

Please tell us about your environment:

Other information

Stack trace that appears on both windows and linux. The test it is thrown on varies and is usually at random points of the test suite run. This usually results in varied test results and number of tests ran because the entire test suite run crashes from this error. This is thrown in our Azure Pipelines runs. We are using the Allure API to log all of actions on the selenium driver, and to attach driver screenshots. If I am not mistaken, this doesn't look like it is originating from a Allure.Step() call so I am not sure how to handle this or if it is a bug. If this is not a bug, is there a way to prevent this error from crashing the suite or what is the most likely cause?

[xUnit.net 00:07:47.96]     Salescloud.Tests.NOB.CreateAndApproveNOBTest.CreateAndApproveNob(data: [["Login"] = "false", ["TestName"] = "Equity Deal", ["Deal Name"] = "Equity-NOB-", ["CompanyName"] = "ASD Logistics, Inc.", ["Property"] = "ABC MHP", ···]) [FAIL]
The active test run was aborted. Reason: Test host process crashed : Unhandled exception. System.InvalidOperationException: No test context is active.
   at Allure.Net.Commons.AllureContext.get_CurrentTest()
   at Allure.Net.Commons.AllureLifecycle.UpdateTestCase(Action`1 update)
   at Allure.Xunit.AllureXunitHelper.ApplyTestFailure(IFailureInformation failure)
   at Allure.Xunit.AllureMessageSink.<>c__DisplayClass11_0.<OnTestFailed>b__0()
   at Allure.Net.Commons.AllureLifecycle.RunInContext(AllureContext context, Action action)
   at Allure.Xunit.AllureMessageSink.RunInTestContext(ITest test, Action action)
   at Allure.Xunit.AllureMessageSink.OnTestFailed(MessageHandlerArgs`1 args)
   at Xunit.ExecutionEventSink.OnMessageWithTypes(IMessageSinkMessage message, HashSet`1 messageTypes) in /_/src/xunit.runner.utility/Sinks/EventSinks/ExecutionEventSink.cs:line 167
   at Xunit.AggregateMessageSink.OnMessageWithTypes(IMessageSinkMessage message, HashSet`1 messageTypes) in /_/src/xunit.runner.utility/Sinks/AggregateMessageSink.cs:line 65
   at Xunit.Runner.VisualStudio.VsExecutionSink.OnMessageWithTypes(IMessageSinkMessage message, HashSet`1 messageTypes) in /_/src/xunit.runner.visualstudio/Sinks/VsExecutionSink.cs:line 319
   at Xunit.ExecutionSink.OnMessageWithTypes(IMessageSinkMessage message, HashSet`1 messageTypes) in /_/src/xunit.runner.utility/Sinks/ExecutionSink.cs:line 457
   at Xunit.Sdk.SynchronousMessageBus.QueueMessage(IMessageSinkMessage message) in /_/src/xunit.execution/Sdk/SynchronousMessageBus.cs:line 37
   at Xunit.Sdk.ExecutionErrorTestCaseRunner.RunTestAsync() in /_/src/xunit.execution/Sdk/Frameworks/Runners/ExecutionErrorTestCaseRunner.cs:line 43
   at Xunit.Sdk.TestCaseRunner`1.RunAsync() in /_/src/xunit.execution/Sdk/Frameworks/Runners/TestCaseRunner.cs:line 82
   at Xunit.Sdk.TestMethodRunner`1.RunTestCasesAsync() in /_/src/xunit.execution/Sdk/Frameworks/Runners/TestMethodRunner.cs:line 136
   at Xunit.Sdk.TestMethodRunner`1.RunAsync() in /_/src/xunit.execution/Sdk/Frameworks/Runners/TestMethodRunner.cs:line 106
   at Xunit.Sdk.TestClassRunner`1.RunTestMethodsAsync() in /_/src/xunit.execution/Sdk/Frameworks/Runners/TestClassRunner.cs:line 228
   at Xunit.Sdk.TestClassRunner`1.RunAsync() in /_/src/xunit.execution/Sdk/Frameworks/Runners/TestClassRunner.cs:line 175
   at Xunit.Sdk.TestCollectionRunner`1.RunTestClassesAsync() in /_/src/xunit.execution/Sdk/Frameworks/Runners/TestCollectionRunner.cs:line 130
   at Xunit.Sdk.TestCollectionRunner`1.RunAsync() in /_/src/xunit.execution/Sdk/Frameworks/Runners/TestCollectionRunner.cs:line 101
   at Xunit.Sdk.XunitTestAssemblyRunner.RunTestCollectionAsync(IMessageBus messageBus, ITestCollection testCollection, IEnumerable`1 testCases, CancellationTokenSource cancellationTokenSource) in /_/src/xunit.execution/Sdk/Frameworks/Runners/XunitTestAssemblyRunner.cs:line 326
   at Xunit.Sdk.XunitTestAssemblyRunner.RunTestCollectionsAsync(IMessageBus messageBus, CancellationTokenSource cancellationTokenSource) in /_/src/xunit.execution/Sdk/Frameworks/Runners/XunitTestAssemblyRunner.cs:line 247
   at Xunit.Sdk.TestAssemblyRunner`1.RunAsync() in /_/src/xunit.execution/Sdk/Frameworks/Runners/TestAssemblyRunner.cs:line 211
   at Xunit.Sdk.XunitTestFrameworkExecutor.RunTestCases(IEnumerable`1 testCases, IMessageSink executionMessageSink, ITestFrameworkExecutionOptions executionOptions) in /_/src/xunit.execution/Sdk/Frameworks/XunitTestFrameworkExecutor.cs:line 96
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
   at System.Threading.QueueUserWorkItemCallbackDefaultContext.Execute()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
   at System.Threading.Thread.StartCallback()
@StanislavKlo
Copy link

StanislavKlo commented Nov 20, 2024

Hello, I'm facing an issue where my tests are not marked as failed, and consequently, they are not included in the Allure report or shown in the dotnet test command output. I observe that approximately 100 tests fail due to the above-mentioned error, but I cannot see which ones failed. This is a blocker for us because it might allow some issues to slip through our release process.

@delatrie Can you help with this? If there is any other alternative, please let us know.

Im using [Xunit.DependencyInjection](https://github.com/pengweiqhca/Xunit.DependencyInjection/) library to automate my tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants