NUnit单元测试下篇---TestDriven.NET
<div id="cnblogs_post_body"> 前面DebugLZQ写了一篇博文,介绍的是如何使用Nunit编写.NET单元测试。但是使用NUnti进行单元测试有一个致命的弱点:无法调试。因为我们的测试本省也是代码,同样我们不能确定我们的代码是对的。这篇博文将以在VS2010下连接数据库并插入一个字段的方法编写单元测试为例,介绍如何使用TestDriven.NET弥补Nunit的这个致命的弱点。示例项目的工程架构如下:
http://pic002.cnblogs.com/images/2012/281227/2012070915425161.png
下面给出几个主要类的源码,Person类的代码如下:
<div class="cnblogs_code">using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace VS2010建立SQLServer数据库Test{ public class Person { private int id; private string userName; private string password; public int Id { get { return id; } set { id = value; } } public string UserName { get { return userName; } set { userName = value; } } public string Password { get { return password; } set { password = value; } } }}
页:
[1]