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

StepArgumentTransformation Async/Await support #2230

Closed
15 tasks
adison88 opened this issue Dec 9, 2020 · 4 comments · Fixed by #2660
Closed
15 tasks

StepArgumentTransformation Async/Await support #2230

adison88 opened this issue Dec 9, 2020 · 4 comments · Fixed by #2660

Comments

@adison88
Copy link

adison88 commented Dec 9, 2020

I'm trying to implement async/await all the for transform method decorated with

Before

        [StepArgumentTransformation]
        public Device TransformDevice(Table table)
        {
            return this.TransformDevices(table).FirstOrDefault();
        }

After

        [StepArgumentTransformation]
        public async Task<Device> TransformDeviceAsync(Table table)
        {
            return (await this.TransformDevicesAsync(table)).FirstOrDefault();
        }

However, it fails and errors out while doing table to Device transform. The same synchronous version works fine. Would like to if async is supported all the way?

SpecFlow Version:

  • [ *] 2.3

Used Test Runner

  • Xunit

Version number:

Project Format of the SpecFlow project

  • Classic project format using <PackageReference> tags

.feature.cs files are generated using

  • SpecFlow.Tools.MsBuild.Generation NuGet package

Visual Studio Version

  • VS 2019

Enable SpecFlowSingleFileGenerator Custom Tool option in Visual Studio extension settings

  • Disabled

Are the latest Visual Studio updates installed?

  • Yes

.NET Framework:

  • >= .NET 4.5
  • before .NET 4.5
  • .NET Core 2.0
  • .NET Core 2.1
  • .NET Core 2.2
  • .NET Core 3.0
  • .NET Core 3.1
  • .NET 5.0

Test Execution Method:

  • Visual Studio Test Explorer

<SpecFlow> Section in app.config or content of specflow.json


Issue Description

Steps to Reproduce

Repro Project

@SabotageAndi
Copy link
Contributor

Did you try it in SpecFlow 3.5? I am not sure when we added the first support for async/await.

@adison88
Copy link
Author

No but as per https://stackoverflow.com/a/40038944 it was added in 2.2 so I thought it’d work.

@gasparnagy
Copy link
Contributor

Analyzed and this is still a problem with v4.0 beta, because the transformation infrastructure does not realize that the method with return type Task<Device> can be used to get the parameter of type Device.

Looking into it...

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants