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

Hooks async await support #1969

Open
20 tasks
xmegacorel opened this issue May 4, 2020 · 5 comments
Open
20 tasks

Hooks async await support #1969

xmegacorel opened this issue May 4, 2020 · 5 comments

Comments

@xmegacorel
Copy link

It's possible to add support async/await for any kind of Hooks.
I have some case to setup specflow tests.

  1. I want to start my services in docker-compose env
  2. => I have some code that process in loop to ping all services, I have to wait with timeout that all services will startup and give me /version or /healthz good response.
    So, in brief I have this code:
    [BeforeTestRun]
    public static Task BeforeTestRun()
    {
    ..... // to check that code below execute only once
    .....
    PermissionService.SetUpAuthorizedUserRoleAsync(FindServiceUrl(Names.PermissionService)).GetAwaiter().GetResult();
    }

async Task SetUpAuthorizedUserRoleAsync(..)
{
// for example
var tasks = services.Select(x => checker.CheckAsync(url)).ToList();
await Task.WaitAll(tasks); // if some task fail, test engine don't respond.
// but if I change code that:
Task.WaitAll(tasks).GetAwaiter().GetResult(); // ok
}

SpecFlow Version:

  • [*] 3.1

Used Test Runner

  • SpecFlow+Runner
  • MSTest
  • NUnit
  • [*] Xunit

Version number: Version=2.4.1

Project Format of the SpecFlow project

  • Classic project format using packages.config
  • Classic project format using <PackageReference> tags
  • [*] Sdk-style project format

.feature.cs files are generated using

  • [*] SpecFlow.Tools.MsBuild.Generation NuGet package
  • SpecFlowSingleFileGenerator custom tool

Visual Studio Version

  • [*] VS 2019
  • VS 2017
  • VS 2015

Enable SpecFlowSingleFileGenerator Custom Tool option in Visual Studio extension settings

  • Enabled
  • Disabled

Are the latest Visual Studio updates installed?

  • [*] Yes
  • No, I use Visual Studio version <Major>.<Minor>.<Patch>

.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

Test Execution Method:

  • Visual Studio Test Explorer
  • TFS/VSTS/Azure DevOps – Task – PLEASE SPECIFY THE NAME OF THE TASK
  • Command line – PLEASE SPECIFY THE FULL COMMAND LINE
  • [*] Resharper test explorer

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

{
  "bindingCulture": {
    "language": "en-us"
  },
  "language": {
    "feature": "en-us"
  },
  "ApiUrls": [
    {
      "ApiUrl": "http://localhost:5005",
      "DataBaseName": "",
      "Name": "AuthService"
    },
.....
   }
}
@eliitzh17
Copy link

@SabotageAndi Hey, there is any update on the subject?

@SabotageAndi
Copy link
Contributor

No, sadly not.

@william-li-ry
Copy link

@SabotageAndi Sorry if this is not related, however does it mean we can't bind an async operation in a [BeforeFeature] hook as well? Thanks

@septst
Copy link

septst commented Sep 1, 2022

@SabotageAndi Sorry if this is not related, however does it mean we can't bind an async operation in a [BeforeFeature] hook as well? Thanks

I am using Specflow.xunit v3.9.74 and am able to use as below

    public static async Task CleanupOnStart()
    {
        await DoSomethingAsync();
        await DoSomethingElseAsync();
    }

@Rayzbam
Copy link

Rayzbam commented Jul 12, 2023

Any update ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants