我刚刚开始使用 Travis CI 在git hub上构建项目,但我很难让NUnit测试成功运行。我遇到了System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
。
我的run-test.sh
看起来像是:
nunit-console Code/Shared/ORMS.Shared.SharedKernel.UnitTests/bin/Release/netcoreapp2.0/ORMS.Shared.SharedKernel.UnitTests.dll
应该是我的测试项目的正确路径。我的.travis.yml
看起来像是:
language: csharp
dist: trusty
sudo: required
mono: none
dotnet: 2.0.0
solution: OpenRMS.sln
branches:
only:
- master-net-core
before_install:
- sudo apt-get install nunit-console
before_script:
- chmod +x build.sh
- chmod +x run-tests.sh
script:
- ./build.sh
- ./run-tests.sh
应该从the output加载NUnit测试运行器,但是还有另一个依赖加载问题,我无法深入到底。 p>
输出失败:
$ ./run-tests.sh
NUnit-Console version 2.6.0.0
Copyright (C) 2002-2012 Charlie Poole.
Copyright (C) 2002-2004 James W. Newkirk, Michael C. Two, Alexei A. Vorontsov.
Copyright (C) 2000-2002 Philip Craig.
All Rights Reserved.
Runtime Environment -
OS Version: Unix 4.4.0.93
CLR Version: 4.0.30319.17020 ( Mono 4.0 ( 3.2.8 (Debian 3.2.8+dfsg-4ubuntu1.1) ) )
ProcessModel: Default DomainUsage: Single
Execution Runtime: mono-4.0
Unhandled Exception:
System.Reflection.ReflectionTypeLoadException: The classes in the module cannot be loaded.
Server stack trace:
at (wrapper managed-to-native) System.Reflection.Assembly:GetTypes (System.Reflection.Assembly,bool)
at System.Reflection.Assembly.GetExportedTypes () [0x00000] in <filename unknown>:0
at NUnit.Core.CoreExtensions.InstallAdhocExtensions (System.Reflection.Assembly assembly) [0x00000] in <filename unknown>:0
at NUnit.Core.Builders.TestAssemblyBuilder.Load (System.String path) [0x00000] in <filename unknown>:0
at NUnit.Core.Builders.TestAssemblyBuilder.Build (System.String assemblyName, Boolean autoSuites) [0x00000] in <filename unknown>:0
at NUnit.Core.Builders.TestAssemblyBuilder.Build (System.String assemblyName, System.String testName, Boolean autoSuites) [0x00000] in <filename unknown>:0
at NUnit.Core.TestSuiteBuilder.BuildSingleAssembly (NUnit.Core.TestPackage package) [0x00000] in <filename unknown>:0
at NUnit.Core.TestSuiteBuilder.Build (NUnit.Core.TestPackage package) [0x00000] in <filename unknown>:0
at NUnit.Core.SimpleTestRunner.Load (NUnit.Core.TestPackage package) [0x00000] in <filename unknown>:0
at NUnit.Core.ProxyTestRunner.Load (NUnit.Core.TestPackage package) [0x00000] in <filename unknown>:0
at NUnit.Core.ProxyTestRunner.Load (NUnit.Core.TestPackage package) [0x00000] in <filename unknown>:0
at NUnit.Core.RemoteTestRunner.Load (NUnit.Core.TestPackage package) [0x00000] in <filename unknown>:0
at (wrapper xdomain-dispatch) NUnit.Core.RemoteTestRunner:Load (object,byte[]&,byte[]&)
Exception rethrown at [0]:
at (wrapper xdomain-invoke) NUnit.Core.RemoteTestRunner:Load (NUnit.Core.TestPackage)
at NUnit.Util.TestDomain.Load (NUnit.Core.TestPackage package) [0x00000] in <filename unknown>:0
The command "./run-tests.sh" exited with 156.
我认为关键是......
at NUnit.Util.TestDomain.Load (NUnit.Core.TestPackage package) [0x00000] in <filename unknown>:0
...所以它看起来好像在加载一个未知文件?
任何建议如何缩小范围。我是Travis的新手,通常在工作中使用MSTest,但是想使用NUnit,因为它有一些我认为MSTest尚未实现的功能。
答案 0 :(得分:3)
您正在尝试从基于单声道版本的NUnit控制台运行程序运行.NET Core单元测试,该运行程序不支持.NET Core dll(请参阅GitHub issue)。
要运行测试,请在测试项目上使用dotnet test
,或在测试项目上运行dotnet vstest
创建的发布输出上使用dotnet publish
。