.net-4.0 - xUnit 1.9.2 和 .Net 4.0

标签 .net-4.0 xunit xunit.net

我正在尝试为 C# 测试实现 xUnit,但遇到了一个奇怪的错误。

我可以在 VisualStudio (2013) 中运行单元测试,但是当我尝试使用 GUI 或控制台运行相同的测试时,出现错误:

xUnit.net console test runner (32-bit .NET 2.0.50727.5472)
Copyright (C) 2013 Outercurve Foundation.

Could not load file or assembly '[...]' or one of its dependencies.
This assembly is built by a runtime newer than the currently loaded
runtime and cannot be loaded.

我的项目使用 .net 4.0,看起来 xUnit 使用 2.0。

我找到了几个帖子 herehere ,其中包括说您可以编辑配置文件,但这对我不起作用。这两个帖子都有几年的历史了,他们甚至不同意对方。一个说条目应该是'supportedRuntime',而另一个是'requiredRuntime'。然而,它们都不适合我。

我还考虑过下载源代码并使用 4.0 进行编译,但根据网站,它需要 VS 2010。

在 IDE 中运行测试很棒,但我还需要使用控制台运行器来在我们的构建机器上实现自动化测试。有没有办法让它发挥作用?还是不再维护 xUnit?

我还找到了 another post问题应该在 2010 年得到解决。也许这是回归失败?

最佳答案

谢谢,马克。但我后来发现 .net 4.0 有一个单独的 xunit.console.clr4.exe 可执行文件。

也许我在这上面浪费了 1/2 天后很痛苦,但 xUnit 网站上没有提到这一点。事实上,该站点只讨论使用 VS 运行测试。我在博客网站上找到了对控制台运行程序的引用。

开始怀疑 xUnit,也许我应该看看 nUnit。它似乎至少有文档。

关于.net-4.0 - xUnit 1.9.2 和 .Net 4.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21442312/

相关文章:

c# - 在 VS2015 上对 UWP 应用程序使用 xUnit 测试

c# - 加快 .net 4.0 搜索速度

.net - 从 3.5 调用 .NET 4 库

nunit - 运行长时间运行的 NUnit/xUnit 测试,这样它们就不会阻塞其他测试

c# - 单元测试 c# 模拟接口(interface)由另一个接口(interface)组成

unit-testing - 当测试挂起时如何停止 Visual Studio Test Runner

vb.net - 此处不能使用 '?'字符

c# - WPF DataGrid 无法更改所选行 : stuck on first row

c# - 'run all tests' 发现但未运行 XUnit 测试

ASP.NET MVC : testing a controller with XUnit