Knowledge Point 4-2: unit test Introduction

Source: Internet
Author: User

In this section, we will briefly test the test controller. In all different types of automated tests, we only care about one type at the moment: unit testing ).

Unit testing is a small script-based test, which is usually written in the same language as the product code. They establish and practice the functions of a single component in the form of isolation from the rest of the system to verify that it works correctly. As applications grow, the number of unit tests increases. Applications with thousands of tests are common and can be executed at any time to verify bugs not introduced in the code library.

To ensure that unit tests run quickly, it is important not to allow them to call external processes. When conducting unit tests on the Controller code, various dependencies should be simulated so that the only running product code is the controller itself. To make it possible, it is important to design a controller in this way: any external dependency can be easily exchanged externally (such as database or web service calls ).

To effectively test the guestbookcontroller, we need to make some modifications that consider testability. But before doing this, let's take a look at the default unit test project, which is part of ASP. net mvc.

1. Use provided test items

By default, when creating a new ASP. net mvc project, vs provides an option to create a unit test project.

 

Knowledge Point 4-2: unit test Introduction

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.