正如标题所示,我正在尝试为我的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:\Project\NUnit.Tests.Droid1\NUnit.Tests.Droid1.csproj C:\Project\Springboard Warehouse\Springboard 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:\Project\NUnit.Tests.Droid1\NUnit.Tests.Droid1.csproj C:\Project\Springboard Warehouse\Springboard 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:\Project\NUnit.Tests.Droid1\bin\Debug\NUnit.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:\repos\NUnit\nunit3-vs-adapter\src\NUnitTestAdapter\NUnit3TestDiscoverer.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:\Project\NUnit.Tests.Droid1\bin\Debug\NUnit.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:\Project\Springboard Warehouse\bin\Debug\Springboard 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:\Project\NUnit.Tests.Droid1\bin\Debug\NUnit.Tests.Droid1.dll C:\Project\Springboard Warehouse\bin\Debug\Springboard 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:\Project\NUnit.Tests.Droid1\bin\Debug\NUnit.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:\repos\NUnit\nunit3-vs-adapter\src\NUnitTestAdapter\NUnit3TestExecutor.cs:line 310
at NUnit.VisualStudio.TestAdapter.NUnit3TestExecutor.RunTests(IEnumerable`1 sources, IRunContext runContext, IFrameworkHandle frameworkHandle) in D:\repos\NUnit\nunit3-vs-adapter\src\NUnitTestAdapter\NUnit3TestExecutor.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:\Project\NUnit.Tests.Droid1\bin\Debug\NUnit.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:\Project\NUnit.Tests.Droid1\bin\Debug\NUnit.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测试适配器扩展。有什么想法可能导致这个问题?
1条答案
按热度按时间ax6ht2ek1#
NUnit测试适配器不支持在Visual Studio测试运行器中运行Android测试。(我 * 认为 * 这是VS测试运行器的限制,但我不能100%肯定!)
您应该将
NUnit.Tests.Droid1
作为Android应用程序启动,无论是在模拟器中还是在设备上。该应用程序将是一个GUI测试运行器,它将允许您运行测试。它看起来有点像这样:
还有一件事-你的应用程序应该引用与nunit.xamarin相同的NUnit版本-所以你真的希望引入NUnit 3.6.1而不是NUnit 3.11。这是计划在未来改变的!