我正在使用 Travis CI 运行 CI 构建。我正在通过nunit3-console.exe
. 我有几个测试试图断言一个集合是有序的:
[Test]
public void FeatsAreSorted()
{
var result = controller.Generate() as JsonResult;
dynamic data = result.Data;
Assert.That(data.character.Ability.Feats, Is.Ordered.By("Name"));
}
当我在 Visual Studio 中运行这个测试时,测试通过了。但是,当我通过nunit3-console.exe
Travis CI 运行测试时,出现以下错误:
1) Error : DNDGenSite.Tests.Unit.Controllers.CharacterControllerTests.GenerateSortsCharacterFeats
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException : `NUnit.Framework.Assert.That<System.Linq.OrderedEnumerable<CharacterGen.Common.Abilities.Feats.Feat,string>>(System.Linq.OrderedEnumerable<CharacterGen.Common.Abilities.Feats.Feat,string>, NUnit.Framework.Constraints.IResolveConstraint)' is inaccessible due to its protection level
这是我的.travis.yml
:
language: csharp
solution: DNDGenSite.sln
install:
- nuget restore DNDGenSite.sln
- nuget install NUnit.Runners -OutputDirectory testrunner
- nuget install Chutzpah -OutputDirectory testrunner
script:
- xbuild DNDGenSite.sln /p:TargetFrameworkVersion="v4.5.1" /p:Configuration=Release
- mono ./testrunner/NUnit.Console.*/tools/nunit3-console.exe ./Tests/bin/Release/DNDGenSite.Tests.dll
- mono ./testrunner/Chutzpah.*/tools/chutzpah.console.exe ./Tests/Unit/Scripts
有什么想法吗?
更新:如果我在 git bash 中运行测试,一切都会正确通过,无论是在构建模式下Debug
还是在Release
构建模式下。因此,Travis CI 构建控制台运行器的环境有所不同。