xunit / devices.xunit

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

Difficulties using XUnit Runner on iOS #2

Closed Planverlust closed 9 years ago

Planverlust commented 10 years ago

I followed the instructions here

http://blog.novotny.org/2014/07/10/getting-started-with-xunit-for-xamarin/

I copied the the content of AppDelegate.cs.txt to AppDelegate.cs, but when i run it, the Simulator window stays black. When i look to Application Output window, there is a logged error:

Could not register the assembly 'xunit.runner.ios': System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded. at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (System.Reflection.Assembly,bool) at System.Reflection.Assembly.GetTypes () [0x00000] in /Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/Assembly.cs:351 at MonoTouch.Registrar.DynamicRegistrar.CollectTypes (System.Reflection.Assembly assembly) [0x00000] in /Developer/MonoTouch/Source/maccore/src/ObjCRuntime/DynamicRegistrar.cs:228 at MonoTouch.Registrar.Registrar.RegisterAssembly (System.Reflection.Assembly assembly) [0x00049] in /Developer/MonoTouch/Source/maccore/src/ObjCRuntime/Registrar.cs:1307

Here is all my version information

xunit version is 2.0.0-beta4-build-2738 xunit.runner.xamarin version is 0.99.3-beta4-build-1017

=== Xamarin Studio ===

Version 5.5 (build 227) Installation UUID: 671bdca8-d671-4579-9ae2-006dce0e536d Runtime: Mono 3.10.0 ((detached/47db868) GTK+ 2.24.23 (Raleigh theme)

Package version: 310000019

=== Apple Developer Tools ===

Xcode 6.0.1 (6528) Build 6A317

=== Xamarin.iOS ===

Version: 8.2.0.193 (Indie Edition) Hash: 959c1e4 Branch: Build date: 2014-10-03 00:25:37-0400

=== Build Information ===

Release ID: 505000227 Git revision: 7b721eeec7a2fa4c4f4de0ecd2aed4dc25edac95 Build date: 2014-10-02 15:53:38-04 Xamarin addins: 99ed56b428b31eba1efaace4d82188d6f334e6ca

=== Operating System ===

Mac OS X 10.9.5 Darwin lfwdev08.local 13.4.0 Darwin Kernel Version 13.4.0 Sun Aug 17 19:50:11 PDT 2014 root:xnu-2422.115.4~1/RELEASE_X86_64 x86_64

goodlaff commented 10 years ago

I am having exactly the same problem after following the same steps. The runner is working fine for Android project in same solution.

xunit.2.0.0-beta4-build2738 xunit.runner.xamarin.0.99.3-beta4-build1017

=== Xamarin Studio === Version 5.5.3 (build 6) Runtime: Mono 3.10.0 ((detached/e204655) GTK+ 2.24.23 (Raleigh theme) === Apple Developer Tools === Xcode 6.1 (6604) Build 6A1052d === Xamarin.iOS === Version: 8.4.0.16 (Business Edition) === Operating System === Mac OS X 10.10.0

@Planverlust - did you find a solution?

Planverlust commented 10 years ago

Unfortunately no. It was a experiment that i gave up.

goodlaff commented 10 years ago

For anyone interested I've hopefully solved this problem.

In the appdelegate.cs example you must uncomment line 37: // We need this to ensure the execution assembly is part of the app bundle runner.AddExecutionAssembly(typeof(ExtensibilityPointFactory).Assembly);

And explicitly install the unit.runner.utility package: Install-Package xunit.runner.utility -Pre

These two changes ensure that these two assemblies are bundled in with the compiled app, otherwise the linker will optimise them away as they are not directly referenced in the code.

I have created a fork with these changes in it and will add a pull request: https://github.com/goodlaff/xamarin.xunit

clairernovotny commented 10 years ago

Hi,

You're right, for iOS/Android we need to have a code reference to the execution library to ensure it gets pulled into the package. Looks like beta 4's template missed that part... :/

Can you please try the new beta 5? It refactored the entry point to hide a lot more, so please be sure to update the AppDelegate/MainActivity with the new ones from the templates.

Thanks!

goodlaff commented 10 years ago

Hi @onovotny,

Thanks for looking at this and getting back to me.

I added the latest packages from nuget and tested them out.

The problems with iOS seem to have been fixed and I was able to remove the xunit.runner.utilty package from the project.

However, the android package is now missing the xunit.runner.utilty dll so I had to add the package explicitly to the project to be able to compile and run. After changing the MainActivity to match the new syntax I was able to run tests as before, however the AutoStart and TerminateAfterExecution facilities no longer seem to work, or at least setting the properties to true has no effect.

Cheers

Keith

clairernovotny commented 10 years ago

The xunit.runner.utility is bundled with the Xamarin runner NuGet and included via a props file as content, so it shouldn't need to be referenced separately. I had this working, but I'll dig in again to see what's going on. There's a lot of MSBuild voodoo in the various xUnit packages to get test discovery/execution working properly in VS and the runners, so something might have slipped through.

As for AutoStart and AutoTerminate, that was an oversight as code was moving to use Xam Forms (to eliminate duplicate UI elements). It's fixed in 6b3cb6a and I'll have that out very soon -- I just want to look into the runner.utility isuse you saw in android first.

goodlaff commented 10 years ago

No problem, I look forward to the next release, apart from these couple of issues it's all working as expected.

Great job!

clairernovotny commented 9 years ago

@Planverlust Please try the latest NuGet, 0.99.6-beta5 as they should have these issues resolved.

Planverlust commented 9 years ago

Sorry for the late answer. Tried the latest version and it works perfectly! I am happy that i can continue my adventures in xUnit now! Can't stand NUnit any more ;-)