【发布时间】:2018-09-28 17:11:56
【问题描述】:
我在 Visual Studio 中创建了一个项目,用于使用 nunit 的 nuget 包进行单元测试。该测试使用测试资源管理器在 Visual Studio 中运行良好,但我需要使用 nunit3 控制台运行它们。
我的项目很简单我:
- 在 C# 中创建了一个控制台项目
- 我使用 NuGet 包管理器安装了 Nunit 和 NUnitTestAdapter。
-
我用下面的代码创建了一个名为 MyMath.cs 的类:
namespace NunitDemo { class MyMath { public int add(int a, int b) { return a + b; } public int sub(int a, int b) { return a - b; } } } -
我使用以下代码创建了一个 MyTestCase 类来测试 MyMath 方法:
using NUnit.Framework; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace NunitDemo { [TestFixture] class MyTestCase { [TestCase] public void Add() { MyMath math = new MyMath(); Assert.AreEqual(31, math.add(20, 11)); } [TestCase] public void Sub() { MyMath math = new MyMath(); Assert.AreEqual(9, math.sub(20, 11)); } } } 我重建了我的解决方案并使用测试资源管理器面板我可以在 Visual Studio 中毫无问题地运行我的测试。
但是我需要使用 nunit3-console 提示符运行我的测试,那么,我如何生成(或在哪里)一个 DLL 文件以使用 nunit-gui 从控制台运行测试?
我在 C:\Users\Manuel\source\repos\ConsoleAppForNunit\ConsoleAppForNunit\bin\Debug 内搜索,但没有合适的 .DLL
【问题讨论】:
标签: c# unit-testing nunit nunit-console