[英]Cannot install “Microsoft.AspNet.Razor 3.2.3” at the nuget package manager visual studio 2015
[英]How to install NUnit for C# with NuGet Package Manager on Visual Studio 2015
我有Visual Studio 2015.我想用NuGet Package Manager为C#项目添加NUnit的测试,我希望有可能用Visual Studio和Visual Studio运行测试。
首先我创建新的C#项目:菜单文件 → 新建 → 项目 → 已安装 → 模板 → Visual C# → 控制台应用程序 → 确定 。
然后我安装NUnit:菜单工具 → NuGet包管理器 → 管理解决方案的NuGet包...然后我安装包:
在输出中我看到:
Successfully installed 'NUnit 3.0.0-beta-4' to Tmp. Successfully installed 'NUnit.Runners 2.6.4' to Tmp. Successfully installed 'NUnitTestAdapter 2.0.0' to Tmp.
我要做的下一步是添加带有代码的新类:右键单击项目→ 添加 → 类 → Visual C#项目 → 类名称Tests.cs → 添加
然后我使用下面的代码:
namespace NUnit.Tests { using System; using NUnit.Framework; [TestFixture] public class Tests { [Test] public void t1() { } [Test] public void t2() { } } }
最后,当我在Test Explorer上按RunAll时,我看到:
------ Discover test started ------ NUnit VS Adapter 2.0.0.0 discovering tests is started Attempt to load assembly with unsupported test framework in C:\\Users\\Grzegorz\\Desktop\\Tmp\\Tmp\\bin\\Debug\\Tmp.exe NUnit VS Adapter 2.0.0.0 discovering test is finished ========== Discover test finished: 0 found (0:00:00,0720041) ========== No tests are being discovered.
奇怪的是,当任何人使用NuGet在Visual Studio 2015中安装NUnit并在Visual Studio中运行测试时,我找不到任何教程。
看起来你正在使用NUnit 3 beta。 从错误消息我猜测试运行器不支持它。 尝试将NUnit包更改为2.x版本,看看是否有所作为。
我有同样的问题,我的同事通过安装解决了这个问题:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.