Third week job--vs 2013 Unit Test

Source: Internet
Author: User

VSTS can implement automated testing, in short, a program that writes a test program that automatically determines whether the output matches the expectations, gives code coverage, and so on, and provides a summary of how to take advantage of this feature.

1. Create a new project, creating a class. That is, a specific function to be completed, it provides a series of operations to complete the corresponding functions.

2. Click New Project to create a C # Unit test project.



3. Click OK to enter the code editing interface. Right-click the new item, tap Add, and select New item.

4. Create a class, define a class name, and click Add.

5. Write down the code in the book.

Namespace UnitTestProject2
{
public class User
{
Public User (String useremail)
{
M_email = UserEmail;
}
private string M_email;
}
}

[TestMethod ()]
public void TestMethod1 ()
{
String useremail = "[email protected]"; Initialize to the appropriate value
User target = new user (useremail); Create a use case for the object being tested
Assert.istrue (target! = null);//Compare actual results with expected results
}

6. Look in the menu bar: Test → Windows → Test Explorer.

7. Click Run the selected test.

8. The test results are as follows.

Third week job--vs 2013 Unit Test

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.