using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
namespace NUnitTesting
{
class Program
{
static void Main(string[] args)
{
}
}
public class Maths
{
public int Add(int a, int b)
{
int x = a + b;
return x;
}
}
[TestFixture]
public class TestLogging
{
[Test]
public void Add()
{
Maths add = new Maths();
int expectedResult = add.Add(1, 2);
Assert.That(expectedResult, Is.EqualTo(3));
}
}
}
将 NUnit 和 NunitTestAdapter 包从 ManageNunit 包安装到您的测试项目中,以执行相同的操作:
1右键单击菜单项目→单击“管理 NuGet 软件包”。
2进入“ Browse”选项卡-> Search for the Nunit (or any other package that you want to install)
3点击包-> 一个侧面屏幕将打开“选择项目,点击安装。