allure-framework / allure-framework/allure-csharp
Confusing error message if [AllureNUnit] is missing
- Dominant language
- C#
- Stars
- 125
- Forks
- 76
- Avg merge
- 1d 2h
- Merged PRs (30d)
- 18
Description
#### I'm submitting a ...
- [ ] bug report
- [x] feature request
- [ ] support request => Please do not submit support request here, see note at the top of this template.
#### What is the current behavior?
Currently, if one forgets to apply `[AllureNUnit]` to a test fixture while using an API function that requires some part of Allure context to be active, the following error is shown (example):
```
Message:
System.InvalidOperationException : No fixture, test, or step context is active.
Stack Trace:
AllureContext.get_CurrentStepContainer()
AllureLifecycle.StartStep(StepResult result)
CoreStepsHelper.StartStep(String name)
CoreStepsHelper.ExecuteAction[T](String name, Action`1 start, Func`1 action, Action pass, Action fail)
CoreStepsHelper.ExecuteStep[T](String name, Func`1 action)
CoreStepsHelper.Step(String name, Action action)
CoreStepsHelper.Step(String name)
MyTestFixture.MyTest() line 11
```
#### If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem
```csharp
using Allure.Net.Commons.Steps;
using NUnit.Allure.Core;
using NUnit.Framework;
class MyTestFixture
{
[Test]
public void MyTest()
{
CoreStepsHelper.Step("My step");
}
}
```
#### What is the expected behavior?
A more helpful message identifying the missing attribute problem should be generated.
#### What is the motivation / use case for changing the behavior?
Such message would be of a great help for newcomers.
#### Please tell us about your environment:
- Test framework: NUnit@3.13.3
- Allure adaptor: Allure.NUnit@2.10.0
Contributor guide
Research direction
Start by reproducing the issue with the provided MyTestFixture example and inspect the CoreStepsHelper.Step call and AllureContext.get_CurrentStepContainer stack trace. Trace how the missing [AllureNUnit] attribute leaves the context inactive, then verify that the resulting error identifies the missing attribute problem instead of only reporting that no context is active.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100