Installation and unit testing for Visual Studio

Source: Internet
Author: User

I. Installation of Visual Studio

Because the WIN10 system was re-installed last semester, the previously used vc++6.0 can not be used normally, so the installation of Visual Studio 2015, the installation of the direct follow the steps to install, is the installation time is longer.

Figure 1.1

Figure 1.2

Second, Unit test exercises

Software used: Visual Studio 2015

Title: Textbook 22~25 page Unit test exercise

1. First create a C # class

Figure 2.1

Figure 2.2

2. Writing code

Figure 2.3

3. Create a unit test

Mouse over the user class, right-click, click "Create Unit Test", 2.4

Figure 2.4

Click OK directly.

Figure 2.5

A new class appears in Explorer, as shown in 2.6.

Figure 2.6

4. Code fill, get unit test

 Public void usertest ()        {            stringnull; // todo:initialize to an appropriate                                      // value            New User (useremail);             // todo:implement code to verify target            Assert.Inconclusive ("todo:implement code to verify target");        }

Figure 2.7

5. Testing

Test Explorer, Window---windows, testing, 2.8.

Figure 2.8

Click Run All and the results are as shown in 2.9.

Figure 2.9

Since the test unit is also using assert.inconclusive, this is an unverified unit test.

6. Improved testing

The above example is further modified to set the data, use the function of the type being tested, compare the actual results and the expected results .

 Public class usertests    {        [TestMethod ()]        publicvoid  usertest ()        {            string " [email protected] " ;              New User (useremail);             NULL );        }    }

Figure 2.10

To test the modified example, the result 2.11

Figure 2.11

This test is just in accordance with the textbook examples of step-by-step implementation, and not too much innovation, because just contact, not too familiar with, I believe will slowly familiar with.

This error: At the beginning of the creation of the class, the system automatically created the DemoUser class, and this experiment is using the user class, initially did not notice, in the unit test error.

Installation and unit testing for Visual Studio

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.