归志宁无五亩园,读书本意在元元。这篇文章主要讲述Xamarin Android Nunit测试在测试资源管理器中可被发现,但在运行测试时未被发现。 (VS2017)相关的知识,希望能为你提供帮助。
【Xamarin Android Nunit测试在测试资源管理器中可被发现,但在运行测试时未被发现。 (VS2017)】正如标题所示,我正在尝试为我的android应用程序创建一些测试,该应用程序正在使用Xamarin.Android。我已经下载了Nunit VS模板,并按照here的步骤创建了一个NUnit 3测试项目(Android)。
我可以在测试资源管理器中看到默认测试,但如果我尝试运行测试,我会在输出窗口中看到以下内容:
[18/03/2019 11:24:21 Informational] ------ Discover test started ------
[18/03/2019 11:24:25 Warning] No test is available in C:ProjectNUnit.Tests.Droid1NUnit.Tests.Droid1.csproj C:ProjectSpringboard WarehouseSpringboard Warehouse.csproj. Make sure that test discoverer &
executors are registered and platform &
framework version settings are appropriate and try again.
[18/03/2019 11:24:25 Informational] ========== Discover test finished: 0 found (0:00:04.1467419) ==========
[18/03/2019 11:24:51 Informational] ------ Discover test started ------
[18/03/2019 11:24:53 Warning] No test is available in C:ProjectNUnit.Tests.Droid1NUnit.Tests.Droid1.csproj C:ProjectSpringboard WarehouseSpringboard Warehouse.csproj. Make sure that test discoverer &
executors are registered and platform &
framework version settings are appropriate and try again.
[18/03/2019 11:24:53 Informational] ========== Discover test finished: 0 found (0:00:01.6753664) ==========
[18/03/2019 11:24:53 Informational] ------ Discover test started ------
[18/03/2019 11:24:54 Informational] NUnit Adapter 3.13.0.0: Test discovery starting
[18/03/2019 11:24:54 Warning] Exception NUnit.Engine.NUnitEngineException, Exception thrown discovering tests in C:ProjectNUnit.Tests.Droid1inDebugNUnit.Tests.Droid1.dll
[18/03/2019 11:24:54 Warning] The NUnit 3 driver cannot support this test assembly. Use a platform specific runner.
[18/03/2019 11:24:54 Warning]at NUnit.Engine.Drivers.NUnit3FrameworkDriver.Load(String testAssemblyPath, IDictionary`2 settings)
at NUnit.Engine.Runners.DirectTestRunner.LoadDriver(IFrameworkDriver driver, String testFile, TestPackage subPackage)
at NUnit.Engine.Runners.DirectTestRunner.LoadPackage()
at NUnit.Engine.Runners.TestDomainRunner.LoadPackage()
at NUnit.Engine.Runners.DirectTestRunner.EnsurePackageIsLoaded()
at NUnit.Engine.Runners.DirectTestRunner.Explore(TestFilter filter)
at NUnit.Engine.Runners.MasterTestRunner.Explore(TestFilter filter)
at NUnit.VisualStudio.TestAdapter.NUnit3TestDiscoverer.DiscoverTests(IEnumerable`1 sources, IDiscoveryContext discoveryContext, IMessageLogger messageLogger, ITestCaseDiscoverySink discoverySink) in D:
eposNUnit
unit3-vs-adaptersrcNUnitTestAdapterNUnit3TestDiscoverer.cs:line 96
[18/03/2019 11:24:54 Warning] Innerexception: System.Runtime.Serialization.SerializationException: Type 'NUnit.Framework.Api.FrameworkController' in assembly 'nunit.framework, Version=3.6.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb' is not marked as serializable.
at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes)
at NUnit.Engine.Drivers.NUnit3FrameworkDriver.CreateObject(String typeName, Object[] args)
at NUnit.Engine.Drivers.NUnit3FrameworkDriver.Load(String testAssemblyPath, IDictionary`2 settings)
[18/03/2019 11:24:54 Informational] NUnit Adapter 3.13.0.0: Test discovery complete
[18/03/2019 11:24:54 Informational] NUnit VS Adapter 2.1.1.0 discovering tests is started
[18/03/2019 11:24:54 Warning] Dependent Assembly Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065 of C:ProjectNUnit.Tests.Droid1inDebugNUnit.Tests.Droid1.dll not found. Can be ignored if not a NUnit C:Project.
[18/03/2019 11:24:54 Warning] Dependent Assembly Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065 of C:ProjectSpringboard WarehouseinDebugSpringboard Warehouse.dll not found. Can be ignored if not a NUnit C:Project.
[18/03/2019 11:24:54 Informational] NUnit VS Adapter 2.1.1.0 discovering test is finished
[18/03/2019 11:24:54 Warning] No test is available in C:ProjectNUnit.Tests.Droid1inDebugNUnit.Tests.Droid1.dll C:ProjectSpringboard WarehouseinDebugSpringboard Warehouse.dll. Make sure that test discoverer &
executors are registered and platform &
framework version settings are appropriate and try again.
[18/03/2019 11:24:54 Informational] ========== Discover test finished: 0 found (0:00:01.6691257) ==========
[18/03/2019 11:25:31 Informational] ------ Run test started ------
[18/03/2019 11:25:32 Informational] NUnit Adapter 3.13.0.0: Test execution started
[18/03/2019 11:25:32 Informational] Running all tests in C:ProjectNUnit.Tests.Droid1inDebugNUnit.Tests.Droid1.dll
[18/03/2019 11:25:33 Warning] Exception NUnit.Engine.NUnitEngineException, Exception thrown executing tests
[18/03/2019 11:25:33 Warning] The NUnit 3 driver cannot support this test assembly. Use a platform specific runner.
[18/03/2019 11:25:33 Warning]at NUnit.Engine.Drivers.NUnit3FrameworkDriver.Load(String testAssemblyPath, IDictionary`2 settings)
at NUnit.Engine.Runners.DirectTestRunner.LoadDriver(IFrameworkDriver driver, String testFile, TestPackage subPackage)
at NUnit.Engine.Runners.DirectTestRunner.LoadPackage()
at NUnit.Engine.Runners.TestDomainRunner.LoadPackage()
at NUnit.Engine.Runners.DirectTestRunner.EnsurePackageIsLoaded()
at NUnit.Engine.Runners.DirectTestRunner.Explore(TestFilter filter)
at NUnit.Engine.Runners.MasterTestRunner.Explore(TestFilter filter)
at NUnit.VisualStudio.TestAdapter.NUnit3TestExecutor.RunAssembly(String assemblyPath, TestFilter filter) in D:
eposNUnit
unit3-vs-adaptersrcNUnitTestAdapterNUnit3TestExecutor.cs:line 310
at NUnit.VisualStudio.TestAdapter.NUnit3TestExecutor.RunTests(IEnumerable`1 sources, IRunContext runContext, IFrameworkHandle frameworkHandle) in D:
eposNUnit
unit3-vs-adaptersrcNUnitTestAdapterNUnit3TestExecutor.cs:line 103
[18/03/2019 11:25:33 Warning] Innerexception: System.Runtime.Serialization.SerializationException: Type 'NUnit.Framework.Api.FrameworkController' in assembly 'nunit.framework, Version=3.6.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb' is not marked as serializable.
at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityAttributes)
at NUnit.Engine.Drivers.NUnit3FrameworkDriver.CreateObject(String typeName, Object[] args)
at NUnit.Engine.Drivers.NUnit3FrameworkDriver.Load(String testAssemblyPath, IDictionary`2 settings)
[18/03/2019 11:25:33 Informational] NUnit Adapter 3.13.0.0: Test execution complete
[18/03/2019 11:25:33 Informational] NUnit VS Adapter 2.1.1.0 executing tests is started
[18/03/2019 11:25:33 Warning] Dependent Assembly Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065 of C:ProjectNUnit.Tests.Droid1inDebugNUnit.Tests.Droid1.dll not found. Can be ignored if not a NUnit C:Project.
[18/03/2019 11:25:33 Informational] NUnit VS Adapter 2.1.1.0 executing tests is finished
[18/03/2019 11:25:33 Warning] No test is available in C:ProjectNUnit.Tests.Droid1inDebugNUnit.Tests.Droid1.dll. Make sure that test discoverer &
executors are registered and platform &
framework version settings are appropriate and try again.
[18/03/2019 11:25:33 Informational] ========== Run test finished: 0 run (0:00:01.7390314) ==========
我从nuget安装了NUnit v3.11.0,nunit.xamarin v3.6.1和Nunit3TestAdapter v3.13.0,以及安装的Nunit 3 Test Adapter扩展。什么可能导致这个问题的想法?
答案NUnit测试适配器不支持在Visual Studio Test Runner中运行Android测试。 (我认为这是VS测试跑步者的限制,但我不是100%肯定!)
您应该在模拟器或设备上将
NUnit.Tests.Droid1
作为Android应用程序启动。该应用程序将是一个GUI测试运行器,它将允许您运行测试。它看起来有点像这样:
文章图片
另一件事 - 你的app应该引用与nunit.xamarin相同版本的NUnit- 所以你真的想要引入NUnit 3.6.1而不是NUnit 3.11。计划在未来改变!
推荐阅读
- 锁定AppendAllText与TextWriter
- 有人可以建议我为https://jpetstore.cfapps.io/catalog/categories/FISH创建动态xpath
- android中的自定义,禁用和空白地图
- 添加Google地图活动后,Android内置错误
- 无法找到类com.google.android.gms.maps.SupportMapFragment
- Android google Places API超出了每日配额
- 在我的屏幕上显示给我的区域中的android上的地图中显示标记
- 如何在现有的旧版Android项目中使用最新的API添加Google Map()
- Android onLocationChanged with Direction使用Google Map Api v2