Practice Unit Test (3)-using NUnit

Source: Internet
Author: User
Tags assert

NUnit is one of the most widely used test frameworks on the. NET platform, this article describes the use of NUnit by example, and provides several suggestions and tips for preparing unit tests for beginners ' reference.

Before continuing, let's take a look at a very simple test case (TestCase):

1 [Test]
2 public void Additiontest ()
3 {
4 int expectedresult = 2;

6 assert.areequal (exptectedresult, 1 + 1);
7}

You would say this testcase is too stupid! This is also a lot of nunit documents have been criticized, but my understanding is not so, Xunit is the simple framework for the development of UT, keep it simplicity and stupid, any use of complex testcase to introduce nunit usage is a misleading, UT's complexity lies in how it is applied and implemented in actual projects, rather than hovering over how to use NUnit.

Main content:

1, the basic use of NUnit

2. Organization of test Cases

3, NUnit assertion (Assert)

4. Introduction of common unit testing tools

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.