我想学习如何使用NUnit。我最好的学习方式是先阅读,然后通过实际代码来操作。请问在哪里可以找到一个小而简单的C#项目,以示范的方式使用NUnit?
我想学习如何使用NUnit。我最好的学习方式是先阅读,然后通过实际代码来操作。请问在哪里可以找到一个小而简单的C#项目,以示范的方式使用NUnit?
using System.Text;
using NUnit.Framework;
namespace Test.SampleTests
{
[TestFixture]
public class CustomerTestClass
{
[TestCase(1, true)] // valid customer
[TestCase(2, true)] // valid customer
[TestCase(1123123123132, false)] // invlaid customer
public void IsValidCustomerTest(int customerId, bool isValid)
{
Assert.AreEqual(_service.ValidateCust(customerId), isValid);
}
}
}
你可以在 NUnit 的下载文件中找到 NUnit 示例,这些示例非常好地展示了如何使用 NUnit。
我认为阅读单元测试并不像看到有人编写它们并解释他们为什么这样做那么有帮助。可以尝试一些屏幕录像。例如DimeCast.Net...