Use of vs2013 and unit testing

Source: Internet
Author: User

My vs2013 is installed before, the installation process is not introduced, I usually write code is used vs2013, it is very convenient to use, and now we began to use vs2013 for unit testing

First we build a project, select the virtual C # class library in the project, click OK:


After building the project and entering the code in Class1.cs, the Class1.cs code changes as follows:

namespace demouser{public    class user    {public        User (string useremail)        {            m_email = useremail;        }        private string M_email;}    }

 

Next, right-click the user select Generate Unit Test and then generate the classlibrarytests, insert the code in UserTests.cs

[TestMethod ()]        public void Usertest ()        {            string useremail = "[email protected]";             User target = new user (useremail);             Assert.istrue (target! = null);        }

  

At the end of the test, click Run All in the Test Explorer Bar and the unit test is complete.

Summary: This is my first unit test, before the unit test ignorance, but also do not know the purpose and role, through my understanding of the information, unit testing The purpose is: first to ensure the quality of the code, and then ensure that the code is maintainable, and then this guarantee the code can be extended. Unit tests should verify the correctness of the program on the most basic functions and parameters, and unit testing is fast and independent--monocular test run/pass/fail is not dependent on other tests, it is possible to artificially construct the data to maintain the independence of the unit test. Life-long learning, for the study and use of vs2013 I have to work harder, vs there are a lot of features I need to understand.

Use of vs2013 and unit testing

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.