Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xamarin Android runner sample is Xamarin.Forms-specific #219

Closed
jnm2 opened this issue Jun 28, 2017 · 12 comments
Closed

Xamarin Android runner sample is Xamarin.Forms-specific #219

jnm2 opened this issue Jun 28, 2017 · 12 comments

Comments

@jnm2
Copy link
Contributor

jnm2 commented Jun 28, 2017

The Xamarin Android runner sample can't be used unless you're referencing Xamarin.Forms.
https://github.com/nunit/docs/wiki/Getting-Started-in-Visual-Studio#android

Can we add one that works in an out-of-the-box Xamarin Android unit test project without Xamarin.Forms? I'm just starting to get my head in this game and would appreciate an example.

@jnm2
Copy link
Contributor Author

jnm2 commented Jun 28, 2017

Specifically, I'm not sure what to replace the LoadApplication call with.

Or- perhaps I should just reference Xamarin.Forms in the unit test project?

@jnm2
Copy link
Contributor Author

jnm2 commented Jun 28, 2017

Okay, I'm making progress! I couldn't get it to work starting from the Xamarin Android unit test project and removing Xamarin.Android.NUnitLite and adding nunit.xamarin and trying to follow https://github.com/nunit/docs/wiki/Getting-Started-in-Visual-Studio#android, I couldn't get it to work to use the template files as a project (duh), but installing the NUnit VS templates extension and creating an NUnit 3 Android project does work. =)

@ChrisMaddock
Copy link
Member

Are you using Android 7? I don't believe it works with our runner in it's current state, as it tries to read the .NET Standard package rather than the PCL. (VS is quite pushy about upgrading you to the latest version)

There's issues on it here, but I haven't had the time to get back to them yet. 😞 Please feel free to take those on if you're interested - I have an idea of what's going on I detail on the issues, but haven't managed to verify it at all yet.

nunit/nunit.xamarin#87
nunit/nunit#2237

@rprouse
Copy link
Member

rprouse commented Jun 28, 2017

Starting from the Xamarin unit test template is a bad idea, it pulls in their port of NUnitLite and and entirely different runner.

As for Xamarin.Forms, it is required because that is what the test UI is written in. It was easier than writing it for each platform. You should be able to test any Xamarin project, but you need forms for the test runner.

@jnm2
Copy link
Contributor Author

jnm2 commented Jun 28, 2017

Yeah, monoandroid71.

@jnm2
Copy link
Contributor Author

jnm2 commented Jun 28, 2017

Too bad you have to start the project all the way over from a new template instead of changing settings and references, but I'm happy that I understand it now at least.

@jnm2
Copy link
Contributor Author

jnm2 commented Jun 28, 2017

@ChrisMaddock Yep, that's what I'm running into.

@jnm2
Copy link
Contributor Author

jnm2 commented Jun 28, 2017

@ChrisMaddock I can successfully target monoandroid71 if I use packages.config.

@ChrisMaddock
Copy link
Member

@jnm2 - Thanks for trying. Unfortunately not ideal for indirect references.

If you still have it to hand, would you be able to try this? nunit/nunit.xamarin#87 (comment) No worries if not. I want to revisit xamarin/templates soon, as I broke some things, but had been keen to get distribution/adapter changes done for the next releases first.

@jnm2
Copy link
Contributor Author

jnm2 commented Jun 28, 2017

@ChrisMaddock I was looking at that. I already updated to Android 7.1 and NUnit 3.7.1 with success, but I still want to move away from packages.config to <PackageReference> or project.json. I'll start playing with the NuGet package.

@ChrisMaddock
Copy link
Member

Awesome, thanks! :-) Look forward to finding out what was actually going on!

@jnm2
Copy link
Contributor Author

jnm2 commented Jun 28, 2017

Hang on a second... NuGet won't let me install NUnit 3.7.1 via the interface because of the [3.6.1] version restriction in the nunit.xamarin package. It does work, but only if the 3.7.1 has been downloaded to \packages. NuGet refuses to restore it. I'll stick with 3.6.1 for simplicity till we get the project.json issue figured out.

So this is the list of dlls that end up in the output when targeting monoandroid71 and NUnit 3.6.1:

Name Version
FormsViewGroup.dll 1.5.0.0
nunit.framework.dll 3.6.1.0
nunit.runner.Droid.dll 3.6.1.0
PCLStorage.Abstractions.dll 1.0.2.0
PCLStorage.dll 1.0.2.0
Xamarin.Android.Support.v4.dll (none)
Xamarin.Forms.Core.dll 1.5.0.0
Xamarin.Forms.Platform.Android.dll 1.5.0.0
Xamarin.Forms.Platform.dll 1.0.0.0
Xamarin.Forms.Xaml.dll 1.5.0.0

So maybe the goal is to ensure the same output with project.json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants