Comment 4 for bug 1071164

Revision history for this message
Simone Busoli (simone.busoli) wrote : Re: [Bug 1071164] [NEW] Support async methods in usage scenarios of Throws constraints

Jv, Assert.That is a static, non-async void method, there is no chance on
earth that you could await it. Also, to my best understanding attributes
cannot be awaited either.
If you have any basic questions about how async/await works you should ask
them on StackOverflow or similar websites, not here.

On Thu, Oct 25, 2012 at 1:38 PM, Jv <email address hidden> wrote:

> Yes, but since the async lambda is within the Assert statement, it means
> that either the "Assert" should be awaited as "await Assert" or the [Test]
> attribute should be with [await Test} because the "async" is part of the
> CLR and not the NUnit framework.
>
> If the lambda is to be awaited, it means that the CLR would await it, which
> is how an unhandled exception works, no?
>
> Jv
>
> On Thu, Oct 25, 2012 at 4:54 PM, Simone Busoli
> <email address hidden>wrote:
>
> > No. The lambda itself should be waited for completion.
> >
> > On Thu, Oct 25, 2012 at 11:43 AM, Jv <email address hidden> wrote:
> >
> > > Hi Simone,
> > >
> > > As you have mentioned, the statement Assert is used on whether the
> async
> > > lambda throws a specific exception or not but since the lambda itself
> is
> > > async-ed, do you mean to say that the assertion itself should be
> awaited
> > ?
> > >
> > > Jv
> > >
> > > On Thu, Oct 25, 2012 at 12:51 PM, Simone Busoli
> > > <email address hidden>wrote:
> > >
> > > > Public bug reported:
> > > >
> > > > Although we support async test methods, we're not handling other
> async
> > > > things properly. For instance this is not working as expected:
> > > >
> > > > Assert.That(async () => await DoSomething(), Throws.Exception);
> > > >
> > > > The reasons is the same as why we didn't support async methods: we
> are
> > > > not waiting until the function has completed its execution.
> > > >
> > > > Additional details here: http://stackoverflow.com/questions/13056716
> > > > /async-unit-tests-not-working-as-expected
> > > >
> > > > ** Affects: nunitv2
> > > > Importance: Undecided
> > > > Status: New
> > > >
> > > > --
> > > > You received this bug notification because you are a member of NUnit
> > > > Developers, which is subscribed to NUnit V2.
> > > > https://bugs.launchpad.net/bugs/1071164
> > > >
> > > > Title:
> > > > Support async methods in usage scenarios of Throws constraints
> > > >
> > > > Status in NUnit V2 Test Framework:
> > > > New
> > > >
> > > > Bug description:
> > > > Although we support async test methods, we're not handling other
> > async
> > > > things properly. For instance this is not working as expected:
> > > >
> > > > Assert.That(async () => await DoSomething(), Throws.Exception);
> > > >
> > > > The reasons is the same as why we didn't support async methods: we
> > are
> > > > not waiting until the function has completed its execution.
> > > >
> > > > Additional details here:
> http://stackoverflow.com/questions/13056716
> > > > /async-unit-tests-not-working-as-expected
> > > >
> > > > To manage notifications about this bug go to:
> > > > https://bugs.launchpad.net/nunitv2/+bug/1071164/+subscriptions
> > > >
> > >
> > >
> > > --
> > > Regards,
> > >
> > > Ravichandran Jv
> > > http://ravichandranjv.blogspot.com
> > >
> > > --
> > > You received this bug notification because you are subscribed to the
> bug
> > > report.
> > > https://bugs.launchpad.net/bugs/1071164
> > >
> > > Title:
> > > Support async methods in usage scenarios of Throws constraints
> > >
> > > Status in NUnit V2 Test Framework:
> > > New
> > >
> > > Bug description:
> > > Although we support async test methods, we're not handling other
> async
> > > things properly. For instance this is not working as expected:
> > >
> > > Assert.That(async () => await DoSomething(), Throws.Exception);
> > >
> > > The reasons is the same as why we didn't support async methods: we
> are
> > > not waiting until the function has completed its execution.
> > >
> > > Additional details here: http://stackoverflow.com/questions/13056716
> > > /async-unit-tests-not-working-as-expected
> > >
> > > To manage notifications about this bug go to:
> > > https://bugs.launchpad.net/nunitv2/+bug/1071164/+subscriptions
> > >
> >
> > --
> > You received this bug notification because you are a member of NUnit
> > Developers, which is subscribed to NUnit V2.
> > https://bugs.launchpad.net/bugs/1071164
> >
> > Title:
> > Support async methods in usage scenarios of Throws constraints
> >
> > Status in NUnit V2 Test Framework:
> > New
> >
> > Bug description:
> > Although we support async test methods, we're not handling other async
> > things properly. For instance this is not working as expected:
> >
> > Assert.That(async () => await DoSomething(), Throws.Exception);
> >
> > The reasons is the same as why we didn't support async methods: we are
> > not waiting until the function has completed its execution.
> >
> > Additional details here: http://stackoverflow.com/questions/13056716
> > /async-unit-tests-not-working-as-expected
> >
> > To manage notifications about this bug go to:
> > https://bugs.launchpad.net/nunitv2/+bug/1071164/+subscriptions
> >
>
>
> --
> Regards,
>
> Ravichandran Jv
> http://ravichandranjv.blogspot.com
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1071164
>
> Title:
> Support async methods in usage scenarios of Throws constraints
>
> Status in NUnit V2 Test Framework:
> New
>
> Bug description:
> Although we support async test methods, we're not handling other async
> things properly. For instance this is not working as expected:
>
> Assert.That(async () => await DoSomething(), Throws.Exception);
>
> The reasons is the same as why we didn't support async methods: we are
> not waiting until the function has completed its execution.
>
> Additional details here: http://stackoverflow.com/questions/13056716
> /async-unit-tests-not-working-as-expected
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/nunitv2/+bug/1071164/+subscriptions
>