Nunit Usage Note

Source: Internet
Author: User

1. First download Nunit2.4.1 (http://xiazai.zol.com.cn/detail/27/264331.shtml#down)

2. Then download Resharper (http://kb.cnblogs.com/a/1441816/), is a Vs. NET plug-in, download, install, register. Used to execute self-written test classes.

3. Create a Test project and Test a method in the business logic class tbl_Account of the project.

/// <Summary>

/// Add a data entry

/// </Summary>

Public int Add (TPMS. Model. tbl_Account model)

{

Return dal. Add (model );

}

4. Compile the test class:

Namespace Test

{

[TestFixture]

Public class AccountAddTest

{

[Test]

Public void Add ()

{

BLL. tbl_Account bll = new BLL. tbl_Account ();

Model. tbl_Account account = new Model. tbl_Account ();

Account. PerName = "abc ";

Account. LoginName = "abc ";

Account. LoginPwd = "abc ";

Account. PerCode = 10;

Account. undefine4 = "0 ";

Account. undefine5 = "";

Int id = bll. Add (account );

 

Assert. AreEqual (12, id );

 

}

}

}

5. Execute Debug Unit Tests in VS. NET

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.