I have a problem with Unit testing a Xamarin Android project.
My setup:
- Shared Xamarin project
- ClientX.Android
- ClientX.iOS
- Native.Android
- Native.iOS
Native.Android contains no resources, no MainActivity and no Androidmanifest. It's just shared Mono.Android code and normal business logic for it.
I have an Xunit testing project with which I have been able to test the Shared Xamarin project.
I need to test some business logic that is contained inside Native.Android but I get an error (which does make sense to me):
Severity Code Description Project File Line Suppression State Error NU1201 Project Client.XXXX.NativeDroid is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Project Client.XXX.NativeDroid supports: monoandroid12.0 (MonoAndroid,Version=v12.0) XXX.UnitTests
I can't find how I should go about Unit tests inside a Xamarin Android project that is not view/UI related.
1条答案
按热度按时间dwbf0jvd1#
我设法找到了答案。
使用此项目:https://github.com/xunit/devices.xunit您可以运行特定于平台(iOS/Android)的单元测试(而不是UI测试)。请查看该项目中的“Integration”文件夹以获取项目示例。更新依赖项,添加对Visual Studio中所需的其他项目的引用,它应该适用于您自己的Xamarin 5项目。