Bug 18423 - Android Unit Tests fails to catch Exception on Async method
Summary: Android Unit Tests fails to catch Exception on Async method
Status: CONFIRMED
Alias: None
Product: Android
Classification: Xamarin
Component: Mono runtime / AOT Compiler (show other bugs)
Version: 4.12.0
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: ---
Assignee: Jonathan Pryor
URL:
: 20242 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-03-17 10:52 UTC by Don Jordan
Modified: 2014-07-08 14:14 UTC (History)
7 users (show)

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


Attachments
Example solution with Android/iOS library and test projects. (29.77 KB, application/zip)
2014-03-17 10:52 UTC, Don Jordan
Details

Description Don Jordan 2014-03-17 10:52:16 UTC
Created attachment 6332 [details]
Example solution with Android/iOS library and test projects.

In an android tests project any test that is async and encounters an exception will cause the test application to crash.
This includes [ExpectedException] tests, tests with a try/catch block, and when using Assert.Throws.
The iOS test project when linked to the same test code passes the test without issue.
Comment 1 Sadik Ali 2014-03-19 03:58:28 UTC
I run both test iOS and Android  and noticed that for the the "LibraryCodeTests" failed for android test and success for iOS test project. I am not getting any crashed for Android test. 

Android test Execution log: https://gist.github.com/Sadik1/9637217
Screen cast: http://screencast.com/t/96MoHGd0

Build version:

MAC
=== Xamarin Studio ===
Version 4.2.3 (build 60)
Installation UUID: ce3f5199-e126-42fd-bc8a-6a96370af9ab
Runtime:
	Mono 3.2.6 ((no/9b58377)
	GTK+ 2.24.23 theme: Raleigh
	GTK# (2.12.0.0)
	Package version: 302060000

=== Apple Developer Tools ===
Xcode 5.0 (3332.22)
Build 5A1412

=== Xamarin.Mac ===

Xamarin.Mac: Not Installed

=== Xamarin.Android ===

Version: 4.12.1 (Business Edition)
Android SDK: /Users/mac109/Desktop/android-sdk-macosx
	Supported Android versions:
		2.2   (API level 8)
		2.3   (API level 10)
		3.1   (API level 12)
		4.0   (API level 14)
		4.0.3 (API level 15)
		4.1   (API level 16)
		4.2   (API level 17)
		4.4   (API level 19)
Java SDK: /usr
java version "1.6.0_65"
Java(TM) SE Runtime Environment (build 1.6.0_65-b14-462-11M4609)
Java HotSpot(TM) 64-Bit Server VM (build 20.65-b04-462, mixed mode)

=== Xamarin.iOS ===
Version: 7.2.0.2 (Business Edition)
Hash: 58c3efa
Branch: 
Build date: 2014-10-03 18:02:26-0400

=== Build Information ===
Release ID: 402030060
Git revision: 30c4afc300c2a39ec5300851357ce02e49dd217e
Build date: 2014-03-05 22:09:33+0000
Xamarin addins: f8a9589b57c2bfab2ccd73c880e7ad81e3ecf044

=== Operating System ===
Mac OS X 10.9.0
Darwin mac109s-Mac-mini.local 13.0.0 Darwin Kernel Version 13.0.0
    Thu Sep 19 22:22:27 PDT 2013
    root:xnu-2422.1.72~6/RELEASE_X86_64 x86_64
Comment 2 Atsushi Eno 2014-06-05 22:15:57 UTC
We use NUnitLite 1.0.0 in our products (even when it was reported) but it was built without NET_4_5 condition.

Also there was difference between the original NUnitLite that we use in Xamarin.Android and NUnitLite in Xamarin.iOS which is NOT the original but the modified version in Touch.Unit, namely this:
https://github.com/spouliot/NUnitLite/commit/097a333cd590e9f45c9f40d53fbb72e94b0a3e61

... caused ArgumentNullException ("method") propagated up to unit test failures.


After fixing that issue, there still seems runtime issue. With debug.mono.trace=Xamarin.Android.NUnitLite the trace stops at:
    
    [mono] [0xb7710060: 25.11839 22]
    [mono] ENTER: NUnit.Framework.Internal.AsyncInvocationRegion/AsyncTaskInvoca
    [mono] this:0xa804ae10[.AsyncTaskInvocationRegion RootDomain],
    [mono] [System.Threading.Tasks.Task`1:0xa804ae40],
    [mono] )
    [Mono] DllImport attempting to load: '/system/lib/libc.so'.
    [Mono] DllImport loaded library '/system/lib/libc.so'.
    [Mono] DllImport searching in: '/system/lib/libc.so' ('/system/lib/libc.so')
    [Mono] Searching for 'gettid'.
    [Mono] Probing 'gettid'.
    [Mono] Found as 'gettid'.
Comment 3 Atsushi Eno 2014-07-04 04:39:54 UTC
*** Bug 20242 has been marked as a duplicate of this bug. ***

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