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

Add support for async step functions returning ValueTask #456

Open
1 of 3 tasks
delatrie opened this issue Mar 11, 2024 · 0 comments
Open
1 of 3 tasks

Add support for async step functions returning ValueTask #456

delatrie opened this issue Mar 11, 2024 · 0 comments
Labels
task:new feature Requesting new capability or software feature theme:core

Comments

@delatrie
Copy link
Contributor

delatrie commented Mar 11, 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?

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

Given the following test:

using System.Threading.Tasks;
using NUnit.Framework;
using NUnit.Allure.Attributes;

class MyTestClass
{
    [Test]
    public async ValueTask MyTest()
    {
        await MyStep();

        static async ValueTask MyStep()
        {
            await Task.Delay(1000);
            throw new Exception();
        }
    }
}

The following can be observed:

  • The step's status is incorrectly set to passed
  • The step's duration is unexpectedly low

image

What is the expected behavior?

  • The step's status is broken.
  • The step's duration is close to 1000ms.

Please tell us about your environment:

Other information

The issue occurs because the aspect doesn't await the return value of the step in a manner similar to how it's done for steps returning Task or Task<T>. We check for Task and Task<T> explicitly, so we should add similar branches for ValueTask and ValueTask<T> (the System.Threading.Tasks.Extensions package should be used to access the types).

@delatrie delatrie added theme:core task:new feature Requesting new capability or software feature labels Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
task:new feature Requesting new capability or software feature theme:core
Projects
None yet
Development

No branches or pull requests

1 participant