SpecFlow icon indicating copy to clipboard operation
SpecFlow copied to clipboard

StepArgumentTransformation Async/Await support

Open adison88 opened this issue 3 years ago • 2 comments

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

adison88 avatar Dec 09 '20 23:12 adison88

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

SabotageAndi avatar Dec 10 '20 08:12 SabotageAndi

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

adison88 avatar Dec 10 '20 11:12 adison88

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...

gasparnagy avatar Oct 24 '22 06:10 gasparnagy

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[bot] avatar Nov 24 '22 00:11 github-actions[bot]