Bug 22665 - Nested async unit tests with Timeout attribute don't assert
Summary: Nested async unit tests with Timeout attribute don't assert
Status: CONFIRMED
Alias: None
Product: iOS
Classification: Xamarin
Component: Tools (show other bugs)
Version: 7.4.x
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-09-04 18:56 UTC by falz.x1
Modified: 2014-09-05 03:28 UTC (History)
3 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description falz.x1 2014-09-04 18:56:35 UTC
I came across the following bug report and discovered the solution to stop the touch runner freezing while running was to add a timeout attribute to the test. Whilst this does resolve the freezing issue and the test reports successful - 0 assertions are made.

https://bugzilla.xamarin.com/show_bug.cgi?id=15104

To reproduce:

[Test]
[Timeout (Int32.MaxValue)]
public async Task AsyncTest()
{
	await Task.Run(async() =>
	{
		await Task.Delay(1000);
	});

	Assert.AreEqual(1, 1);
}
Comment 1 falz.x1 2014-09-04 19:03:01 UTC
I've just discovered changing the return type to async void rather than async task gets this working as expected and assertions are made.

However, shouldn't this still be the behaviour when returning a task?
Comment 2 Sadik Ali 2014-09-05 03:28:47 UTC
I have checked this issue and I am able to reproduce this issue.

Steps I followed:

1. Created iOS unit test project.
2. Add a new test file and named it "Tests.cs".
3. Debug test on simulator.
4. Run created test "AsyncTest" 

When I run the case with async and await keywords, I observed the assertions are never made. For the testing, I just write the assert statement before the await Task.Run()  the assertion is working. However, assertions are working without the "async and await" keywords.

Screencast: http://www.screencast.com/t/0qDlexOMJ6

Environment Info:

Mac OS X 10.9.3
Xamarin Studio: 5.3 (build 440)
Mono 3.8.0 ((no/62a857e)
Xcode 5.1 (5084)
Xamarin.iOS : 7.4.0.108 
=== Build Information ===
Release ID: 503000440
Git revision: accb55419539e512cff857b14b80ec3107996511
Build date: 2014-09-01 08:53:05-04
Xamarin addins: 6dbac4b3a32df080bf98cde838ce89e573a92859

Note You need to log in before you can comment on or make changes to this bug.