NUnit是一个非常好用的单元测试工具,在Visual Studio使用NUnit能够非常方便的进行单元测试。

1.下载Nunit

NUnit官方网站下载最新版Nunit,并安装

2.下载在Visual Studio中使用NUnit的插件。

我使用的Testdriven.net插件,比较好用。

可以在其官方网站下载个人免费版使用。

 

这样就完成了整个安装过程,比较简单吧,呵呵。下面一个简单的示例。

新建C#项目,在reference中添加

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework; 

namespace Test
{
    [TestFixture]
    class Worker
    {
        bool GetPrice()
        {
            return true;
        } 

        [Test]
        public void TestGetPrice()
        {
            Assert.IsTrue(GetPrice());
        }
    }
}

相关文章:

  • 2021-07-28
  • 2021-08-01
  • 2022-01-03
  • 2021-11-20
  • 2021-06-05
  • 2021-12-14
  • 2022-02-05
猜你喜欢
  • 2021-09-09
  • 2021-11-02
  • 2021-07-23
  • 2021-12-16
  • 2021-07-31
相关资源
相似解决方案