xunit / devices.xunit

xUnit.net Runners for Devices
Other
73 stars 36 forks source link

Running on Android under the native debugger crashes #54

Closed dmitrykm closed 6 years ago

dmitrykm commented 7 years ago

Tags: Android, native, C++, NDK, Visual Studio, xunit, GDB, power fail/restart, crash

Microsoft Visual Studio Community 2017
Version 15.0.26228.4 D15RTWSVC
Microsoft .NET Framework
Version 4.7.02046

Installed Version: Community

Visual Basic 2017   00369-60000-00001-AA033
Microsoft Visual Basic 2017

Visual C# 2017   00369-60000-00001-AA033
Microsoft Visual C# 2017

Visual C++ 2017   00369-60000-00001-AA033
Microsoft Visual C++ 2017

Common Azure Tools   1.9
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

EclipseAndroidImporter   1.0
Import Android projects from Eclipse.

GitHub.VisualStudio   2.2.0.8
A Visual Studio Extension that brings the GitHub Flow into Visual Studio.

JavaScript Language Service   2.0
JavaScript Language Service

KofePackagePackage Extension   1.0
KofePackagePackage Visual Studio Extension Detailed Info

Markdown Editor   1.11.201
A full featured Markdown editor with live preview and syntax highlighting. Supports GitHub flavored Markdown.

Microsoft MI-Based Debugger   1.0
Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual Studio VC Package   1.0
Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio   Mono.Debugging.VisualStudio
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager   4.0.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

Visual C++ for Cross Platform Mobile Development (Android)   15.0.26228.00
Visual C++ for Cross Platform Mobile Development (Android)

Visual Studio Spell Check Everywhere   VSSpellCheckEverywhere
An extension that enables spell checking within any Visual Studio file editor or tool window that uses WPF text boxes.
https://GitHub.com/EWSoftware/VSSpellChecker

Visual Studio Spell Checker   VSSpellChecker
An editor extension that checks the spelling of comments, strings, and plain text as you type or interactively with tool windows.
https://GitHub.com/EWSoftware/VSSpellChecker

Xamarin   4.3.0.784 (73f58d6)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin.Android SDK   7.1.0.41 (9578cdc)
Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK   10.4.0.123 (35d1ccd)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.`

Here are the steps:

With this code

 [Activity(Label = "xUnit Android Runner", MainLauncher = true, Theme= "@android:style/Theme.Material.Light")]
    public class MainActivity : RunnerActivity
    {
        protected override void OnCreate(Bundle bundle)
        {
            AutoStart = false;

            var gea = Assembly.GetExecutingAssembly();

            AddTestAssembly(gea);

            // you cannot add more assemblies once calling base
            base.OnCreate(bundle);
        }
    }

I get the following error at startup right after launching the test project: image

The target device is x86 Google's emulator.

With AddTestAssembly(..) commented out:

var gea = Assembly.GetExecutingAssembly();

//AddTestAssembly(gea);

the project launches. Therefore there is a bug somewhere in AddTestAssembly(...), associated XamarinForms code, and/or the GDB used by VS for Android debugging.

clairernovotny commented 7 years ago

This seems like a bug in Xamarin's tools...I'd recommend filing an issue on Bugzilla and cross-referencing the issue. The code is all portable code, we're not doing anything that could be causing that.

dmitrykm commented 7 years ago

Yes, this is very likely a Xamarin/GDB bug. There were some scary discussions like https://bugzilla.xamarin.com/show_bug.cgi?id=14129 in the past. I've referenced this page from https://developercommunity.visualstudio.com/content/problem/49039/android-native-debugging-reports-global-signals.html , but the chances that it will be fixed soon are not high... For those who need to debug unit tests under the native debugger now, the workaround is to use Xamarin.NUnitLite tests (project template is included in VS).