我有Visual Studio 2015.我想用NuGet Package Manager为C#项目添加NUnit的测试,我希望有可能在VS和VS中运行测试.
首先我创建新的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.
Run Code Online (Sandbox Code Playgroud)
然后我使用下面的代码:
namespace NUnit.Tests
{
using System;
using NUnit.Framework;
[TestFixture]
public class Tests
{
[Test]
public void t1() …Run Code Online (Sandbox Code Playgroud) 我正在研究selenium网络驱动程序项目.我能够构建测试Test Explorer并执行.
在重建解决方案时,我立即遇到以下错误.
Unit Adapter 3.2.0.0: Test discovery starting
NUnit VS Adapter 2.0.0.0 discovering tests is started
NUnit Adapter 3.2.0.0: Test discovery starting
NUnit VS Adapter 2.0.0.0 discovering tests is started
Attempt to load assembly with unsupported test framework in C:\..\CustomerTest.exe
NUnit VS Adapter 2.0.0.0 discovering test is finished
Attempt to load assembly with unsupported test framework in C:\..\LoginTest.exe
NUnit VS Adapter 2.0.0.0 discovering test is finished
Exception NUnit.Engine.NUnitEngineException, Exception thrown discovering tests in C:\..\CustomerTest.exe
Cannot …Run Code Online (Sandbox Code Playgroud) 我刚开始测试一种计算方法。我对项目进行了清理、重建、x64 调整,并且我有 nunit 测试适配器和其他相关的 dll,但我仍然看不到测试资源管理器窗格中的测试方法。有人可以帮忙吗,是否缺少代码或什么?
namespace Ninja.Tests
{
[TestFixture]
public class SinglePricingTests
{
[Test]
public void ShouldCalculate()
{
var pricingModelTest = new PricingModel();
var Sut = new PriceCalculationService(); // Sut: System under test
var Result = Sut.Calculate(pricingModelTest);
var TestParameters = new PricingCostParameters();
Assert.That(Result, Is.EqualTo(TestParameters));
}
}
}
Run Code Online (Sandbox Code Playgroud)