Visual Studio framework

Source: Internet
Author: User
  1. When you create a unit test, the name control of Microsoft. visualstudio. testtools. unittesting is added to the test project. The name control contains many useful classes:
    • Assertion class: Validation conditions in Unit Tests
    • Initialization and cleanup features: Used to run code before and after a unit test to ensure a specific start and end state
    • Expectedexception feature: used to verify whether a specific type of exception is thrown during unit test execution
    • Testcontext class: used to store information provided to unit tests and information required to run unit tests for ASP. NET web services. The system creates a variable named testcontextinstance for each test class.
    • Testclassattribute: When you create a unit test, testclassattribute is included in the test file to indicate that this particular class can contain methods marked with the [testmethod ()] feature.
    • Expectedexceptionattribute: Expected exception type
  2. Additional test features
    • [Classinitialize ()]: You can use classinitialize to run the code before the first test of the running class.
    • [Classcleanup ()]: You can use classcleanup to run the code after all tests in the class are run.
    • [Testinitialize ()]: You can use testinitialize to run code before running each test.
    • [Testcleanup ()]: Use testcleanup to run the code after each test is run.
  3. Roles of files in Test Solution
    • Local. testsettings: these settings control how to run a local test that does not collect diagnostic data.
    • Bank. vsmdi: This file contains information about the test list that exists in the solution and fills in the test List editor window.
    • Traceandtestimpact. testsettings: these settings control how to run a local test that collects specific diagnostic datasets.
  4. How to configure and view test coverage

Double-click Local. testsettings, follow the configuration, and then click started without debugging to run the test project. You cannot run it directly using F5.

Visual Studio framework

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.