Support async methods in usage scenarios of Throws constraints
Bug #1071164 reported by
Simone Busoli
This bug affects 1 person
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
NUnit Framework |
Fix Released
|
High
|
Charlie Poole | ||
NUnit V2 |
Fix Released
|
High
|
Simone Busoli | ||
NUnitLite |
Fix Released
|
High
|
Charlie Poole |
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://
Related branches
lp:~simone.busoli/nunitv2/1071164
Merged
into
lp:nunitv2
- Charlie Poole: Approve
-
Diff: 2428 lines (+1194/-982)19 files modifiednunit2012.sln (+282/-280)
src/NUnitCore/core/AsyncInvocationRegion.cs (+138/-0)
src/NUnitCore/core/NUnitAsyncTestMethod.cs (+19/-74)
src/NUnitCore/core/Reflect.cs (+3/-7)
src/NUnitCore/core/TestMethod.cs (+2/-2)
src/NUnitCore/core/nunit.core.build (+1/-0)
src/NUnitCore/core/nunit.core.dll.csproj (+228/-227)
src/NUnitCore/tests-net45/NUnitAsyncTestMethodTests.cs (+2/-2)
src/NUnitCore/tests-net45/ThrowsTests.cs (+84/-0)
src/NUnitCore/tests-net45/nunit.core.tests.net45.build (+1/-0)
src/NUnitCore/tests-net45/nunit.core.tests.net45.csproj (+80/-77)
src/NUnitCore/tests/EventQueueTests.cs (+2/-2)
src/NUnitFramework/framework/Assert.cs (+23/-3)
src/NUnitFramework/framework/Constraints/ThrowsConstraint.cs (+27/-6)
src/NUnitFramework/framework/nunit.framework.build (+2/-0)
src/NUnitFramework/framework/nunit.framework.dll.csproj (+233/-227)
src/tests/test-assembly-net45/AsyncRealFixture.cs (+6/-7)
src/tests/test-assembly-net45/test-assembly-net45.build (+0/-3)
src/tests/test-assembly-net45/test-assembly-net45.csproj (+61/-65)
Changed in nunitv2: | |
assignee: | nobody → Simone Busoli (simone.busoli) |
status: | New → In Progress |
Changed in nunitv2: | |
importance: | Undecided → High |
Changed in nunitlite: | |
importance: | Undecided → High |
status: | New → Triaged |
Changed in nunit-3.0: | |
status: | New → Triaged |
importance: | Undecided → High |
Changed in nunitv2: | |
milestone: | none → 2.6.3 |
Changed in nunitv2: | |
status: | In Progress → Fix Committed |
Changed in nunitlite: | |
milestone: | none → 0.9 |
Changed in nunit-3.0: | |
milestone: | none → 2.9.6 |
Changed in nunitlite: | |
assignee: | nobody → Charlie Poole (charlie.poole) |
status: | Triaged → Fix Committed |
Changed in nunitlite: | |
status: | Fix Committed → Fix Released |
Changed in nunit-3.0: | |
assignee: | nobody → Charlie Poole (charlie.poole) |
Changed in nunit-3.0: | |
status: | Triaged → Fix Committed |
Changed in nunit-3.0: | |
status: | Fix Committed → Fix Released |
Changed in nunitv2: | |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
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: stackoverflow. com/questions/ 13056716 unit-tests- not-working- as-expected /bugs.launchpad .net/bugs/ 1071164 stackoverflow. com/questions/ 13056716 unit-tests- not-working- as-expected /bugs.launchpad .net/nunitv2/ +bug/1071164/ +subscriptions
>
> 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://
> /async-
>
> ** 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:/
>
> 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://
> /async-
>
> To manage notifications about this bug go to:
> https:/
>
--
Regards,
Ravichandran Jv ravichandranjv. blogspot. com
http://