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