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