A step by Step learning NUnit (1)

Source: Internet
Author: User
Tags visual studio

Basic knowledge of unit testing

A unit test is a small piece of code written by a developer to verify that a small, well-defined function of the measured code is correct. Typically, a unit test is used to determine the behavior of a particular function under a particular condition (or scene). For example, you might put a large value in an ordered list, and then confirm that the value appears at the end of the list. Alternatively, you might remove the character from the string that matches a pattern, and then confirm that the string does not contain the characters anymore.

The unit test is performed to prove that the behavior of a piece of code is exactly the same as what the developer expects.

When writing a project, if we assume that the underlying code is correct, the underlying code is first used in high-level code, and then the high-level code is used by higher-level code, and so forth. When basic underlying code is no longer reliable, the necessary changes cannot be confined to the bottom. Although you can fix the underlying problem, these changes to the underlying code will inevitably affect the high-level code. As a result, a correction to the underlying code could lead to a series of changes to almost any code, making the modifications more and more complex. So that the entire project also failed.

and the core of unit testing: the simple and effective technique is to make the code more perfect.

NUnit Introduction

NUnit is a free, open source (http://www.nunit.org) product that provides a set of test frameworks and a test run program (Beta runner).

Note: Test Tunner knows how to find the [test] method in classes and classes that have [Testfixture] properties.

How to install NUnit

In the official website http://www.nunit.org/index.php?p=download download NUnit, the current version is 2.4.8, I under IS nunit-2.4.8-net-2.0.zip.

NUnit First Demo

We create a new NUnit project with Visual Studio 2008

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.