MVC Unit Testing Study Notes

Source: Internet
Author: User

MVC Unit Testing

 

Reference:

1. http://www.asp.net/mvc/overview/testing

2. http://www.asp.net/mvc/tutorials/older-versions/nerddinner/enable-automated-unit-testing

 

1 Protocol Throuth: Using TDD with ASP. NET MVC

Reference: gg416511 (VS.98). aspx

1.1 Use VS Unit Testing framework

Reference: dd127597 (v = vs.98). aspx

2 TDD testing principles

  • Each test method corresponds to a specific requirement
  • Databases or other components should not be verified
  • The name of the test method should be descriptive.

3 encoding

3.1 Assert usage

Reference: microsoft. visualstudio. testtools. unittesting. assert. aspx

4 references

4.1 Using Mocks And Tests To Design Role-Based Objects

Reference: dd882516.aspx

4.2 Building Testable ASP. net mvc Applications

Reference: dd942838.aspx

4.3 Enable Automated Unit Testing

Reference: enable-automated-unit-testing

5 tools

For more information, see Mock Framework.

5.1 Nunit

  • : Http://www.nunit.org/

5.2 Ninject

6 concepts

6.1 TDD

  • Test-Driven Development
  • It is a core practice and technology in Agile development and a design methodology. The principle of TDD is to write unit test case code before developing function code, and test code to determine the product code to be written.

6.2 IoC

  • For more information, see DI.
  • Inversion of Control (IoC) is an important Object-Oriented Programming Law to reduce the coupling problem of computer programs. Another name is Dependency Injection ). DI for short.

6.3 DI

  • Dependency Injection

6.4 Mock Framework.

  • Reference document: 1947414.html describes various Mock

6.4.1 Rhino Mocks

6.4.2 Moq

  • Is a Mocking library designed and developed for. NET using, for example, the Linq Expression Tree and Lambda expressions.

6.4.3 Typemock

6.4.4 Moles

6.5 NuGet

  • NuGet is a free and open-source package management and development tool.

7. FAQs

7.1 1. Load config

Reference: arwutang

8 Learning Goals

8.1 2. How to Use

8.1.1 2.1 test view

A. Check whether the view exists.

Reference: making-sure-a-view-exists

B. Unit test MVC views using Razor Generator

Reference: unit-test-your-mvc-views-using-razor.html

C. View Unit Testing

Reference: 1396718.html (Lao Zhao's article)

Reference: testing-routes-in-asp.net-mvc.aspx

8.1.3 Controller

Unit test controller that uses Forms Authentication

Reference: how-can-I-unit-test-my-asp-net-mvc-controller-that-uses-formsauthentication

8.1.4 Test Action Filter

Reference: how-to-test-action-filters-in-asp-net-mvc

8.1.5 Controller Context

Reference: mocking-asp-net-mvc-controller-context

8.1.6 custom Authorize filters

Reference: aspnet-mvc-testing-a-custom-authorize-filters

8.2 basic development process

A. Create a test class [TestClass]

B. Method of initialization [TestInitialize]

C. Test method [TestMethod]

D. Use Assert class in the test method

8.3 3. Notes

For more information, see TDD testing principles.

 

Mind Map Source File Download: Mvc Unit Testing (open with MindManager)

 

 

 

Related Article

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.