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

Async / Await support #542

Closed
alexmaie opened this Issue Jan 29, 2016 · 21 comments

Comments

Projects
None yet
@alexmaie
Copy link

alexmaie commented Jan 29, 2016

Hey guys,

I see that async/ await was added some time ago. Discussion is in issue #257 . Apparently, the modifications made with #287 have been removed by commit 8725c0B on Jan 26,2016

Was there a reason behind this change?

@AlexHayton

This comment has been minimized.

Copy link

AlexHayton commented Feb 3, 2016

We've upgraded to Specflow v2 just so that we could have access to these changes... I was wondering why methods that exposed Task still didn't work!

A lot of our code is using async/await and also many of the HTTP libraries only expose Async methods now. I think this is a key feature for any modern testing framework.

@yngndrw-sage

This comment has been minimized.

Copy link

yngndrw-sage commented Feb 22, 2016

This is an issue for us as well, I was surprised to see the issue in v2 as I was sure I'd seen it working in v1.9 but had upgraded for the parallel test handling.

@annakata

This comment has been minimized.

Copy link

annakata commented Mar 7, 2016

likewise - this is essential and it definitely used to work

@KristjanLaane

This comment has been minimized.

Copy link

KristjanLaane commented Mar 24, 2016

Same desire here, the following code passed with the v2 NuGet when it should have failed:

[Then(@"nothing really happens")]
        public Task ThenNothingReallyHappens()
        {
            return Task.Run(() =>
            {
                Console.WriteLine("Starting then nothing happens at " + DateTime.Now);
                Thread.Sleep(TimeSpan.FromSeconds(2));
                Assert.Fail("Oops, something happened");
            });            
        }
@SabotageAndi

This comment has been minimized.

Copy link
Collaborator

SabotageAndi commented Mar 24, 2016

As @gasparnagy and I created the 2.0 release, we looked at the changes from #287.
We came to the conclussion, that it does not handle all cases (particular at the exception handling). At least there could be more tests for it.
So we did not merged it into the 2.0 release.

I also think this is a needed feature, but at least I didn't had the time yet to complete it.
So if someone wants to contribute an implementation, we are happy to see a new PR for it.

gasparnagy added a commit that referenced this issue Jul 14, 2016

Merge pull request #647 from ocsurfnut/RestoreAsyncSupport
#542 - Restore Async Step Method Support - Await Task Before Continuing
@stuartleeks

This comment has been minimized.

Copy link

stuartleeks commented Jul 27, 2016

I found this thread as I tried to use async/await with SpecFlow and then discovered that it doesn't work!

@ocsurfnut - is your branch ready for a PR?

It would be great to have this supported :-)

@ocsurfnut

This comment has been minimized.

Copy link
Contributor

ocsurfnut commented Jul 27, 2016

@stuartleeks it was pulled into the master a couple weeks ago -> #647 . I'm assuming it should be in the next SpecFlow release.

@gasparnagy

This comment has been minimized.

Copy link
Collaborator

gasparnagy commented Jul 27, 2016

@ocsurfnut @stuartleeks yes, it will be included in the next release. You can access the interim builds from the CI NuGet feed: https://ci.appveyor.com/nuget/specflow-ci

@stuartleeks

This comment has been minimized.

Copy link

stuartleeks commented Jul 27, 2016

That's great news. Any idea roughly when the next release will be?

:-)

@gasparnagy

This comment has been minimized.

Copy link
Collaborator

gasparnagy commented Jul 28, 2016

@stuartleeks good question, but I think it will be sometime in September...

@stuartleeks

This comment has been minimized.

Copy link

stuartleeks commented Sep 13, 2016

Hi @gasparnagy - since it's around mid-September, I thought I'd check back to see what the ETA is for async/await? :-)

@SabotageAndi

This comment has been minimized.

Copy link
Collaborator

SabotageAndi commented Sep 14, 2016

@stuartleeks
We added first support for async/await with PR #647.
To use this, you have to use the nugets from our CI- feed.

Feedback if everything works or something is missing in the support would be appreciate.

@Oblomoff

This comment has been minimized.

Copy link

Oblomoff commented Oct 14, 2016

Hello.
Async supprоt does not work in SpecFlow 2.1.0.0 at all. This specs should throw InvalidOperationException but they do not.

Async.feature

Feature: Async specs

Scenario: Result is async Task 
    When result is async Task

Scenario: Result is Task
    When result is Task

AsyncSteps.cs

    [Binding]
    public class AsyncSteps
    {
        [When(@"result is async Task")]
        public async Task WhenResultIsAsyncTask()
        {
            // Failure
            await Task.Run(() =>
                     {
                         throw new InvalidOperationException();
                     });
        }

        [When(@"result is Task")]
        public Task WhenResultIsTask()
        {
            // Failure
            return Task.Run(() =>
            {
                throw new InvalidOperationException();
            });
        }
    }
@aberbegall

This comment has been minimized.

Copy link

aberbegall commented Jan 18, 2017

It seems to be fixed in 2.2.0-preview,
I tested the following

        [Then(@"it fails asynchronously")]
        public async Task ThenItFailsAsynchronously()
        {
            Assert.Fail();
        }

and it passes in 1.19 & 2.1 but it fails in 2.2.0-preview :)

Any idea when the 2.2.0 stable NuGet will be available?

@SabotageAndi

This comment has been minimized.

Copy link
Collaborator

SabotageAndi commented Jan 18, 2017

@aberbegall No, there is no plan when we will release 2.2.
There are still some changes open that I want to get into it.

But there is no problem to use the preview until then..

@SabotageAndi

This comment has been minimized.

Copy link
Collaborator

SabotageAndi commented Jun 30, 2017

SpecFlow 2.2 was released on Tuesday.
http://specflow.org/2017/specflow-2-2-0-released/

@mraigonsp

This comment has been minimized.

Copy link

mraigonsp commented Jul 10, 2017

Hi @SabotageAndi ,
Is included in the SpecFlow 2.2 the support for Async / Await operations commented here? The notes in http://specflow.org/2017/specflow-2-2-0-released/ doesnt mention anything about this issue number ;-)

Many thanks!

@SabotageAndi

This comment has been minimized.

Copy link
Collaborator

SabotageAndi commented Jul 10, 2017

Ups, we forgot to add this to the changelog.
2.2 has async/await support included.

We will update the information.

@mattfrear

This comment has been minimized.

Copy link

mattfrear commented May 1, 2018

Greetings from 2018. There doesn't seem to be any documentation saying that async/await is supported. I'm trying to get it working but it's failing and I don't know if it's my code or not.

https://specflow.org/documentation/Step-Definition-Styles/

Doesn't have any async/await examples. Google searching only leads me to GitHub PRs / feature requests but no published examples of it working.

@SabotageAndi

This comment has been minimized.

Copy link
Collaborator

SabotageAndi commented May 1, 2018

@mattfrear

This comment has been minimized.

Copy link

mattfrear commented May 3, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.