allure-framework / allure-framework/allure-csharp

xUnit.net: Using xRetry to retry tests throws InvalidOperationException

Open
#539 2 comments 1 reaction 0 assignees View on GitHub
bug theme:xunit
Dominant language
C#
Stars
125
Forks
76
Avg merge
1d 2h
Merged PRs (30d)
18

Description

#### I'm submitting a ...
- [x] 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?

After adding [xRetry](https://www.nuget.org/packages/xRetry/) or [Xunit.DependencyInjection.xRetry](https://www.nuget.org/packages/Xunit.DependencyInjection) to a project having Allure.Xunit package, System.InvalidOperationException is thrown when running any test.

``` System.InvalidOperationException : No fixture context is active.```

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

1. To a project having Allure.Xunit package and tests, add [xRetry](https://github.com/JoshKeegan/xRetry) or [Xunit.DependencyInjection.xRetry](https://github.com/pengweiqhca/Xunit.DependencyInjection/tree/main/src/Xunit.DependencyInjection.xRetry) package.
2. Annotate the constructor with [AllureBefore].
3. Run any test.
4. The test won't start and throws the above error.

#### What is the expected behavior?

The test should run without any errors

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

To retry failed tests

#### Please tell us about your environment:

- OS: Windows
- .NET framework: .NET 8
- Allure version: 2.12.1
- Test framework: xUnit

#### Other information

Message: 
System.InvalidOperationException : No fixture context is active.

Stack Trace: 
```AllureContext.get_CurrentFixture() line 133
AllureLifecycle.UpdateFixture(Action`1 update) line 322
AllureLifecycle.StopFixture(Action`1 beforeStop) line 345
ExtendedApi.ResolveItem(Func`2 stop, Exception error) line 625
ExtendedApi.ResolveFixture(Exception error) line 258
AllureAbstractStepAspect.ThrowFixture(MethodBase metadata, Exception e) line 79
AllureAbstractStepAspect.OnTargetInvokeException(MethodBase metadata, Exception e) line 100
AllureAbstractStepAspect.WrapSyncVoid(Func`2 target, Object[] args, MethodBase metadata, String stepName, List`1 stepParameters) line 144```

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with Allure.Xunit, xRetry, and .NET 8 using the listed constructor annotation and test steps. Start at AllureContext.CurrentFixture and trace AllureLifecycle.UpdateFixture, StopFixture, and the ExtendedApi fixture-resolution calls shown in the stack trace; done means the test runs successfully with retry support and no fixture-context exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.