XUnit Entry 1: xUnit entry
After reading the introduction Demo of nhib.pdf, I feel that testing-driven development will be more efficient. Of course, do you think you need additional programming unit testing code? How can development be more efficient?
In one sentence, the server won't cut the firewood by mistake.
Now let's get started ~.~
The author uses vs2013 + Resharper 8.2.
1. It is convenient to use Resharper. Therefore, first, Resharper-> Extension Manager..., download and install xUnit.net Test Support;
:
2. Create a project and install xUnit
Incorrect operation: Create a project. First, I think I should establish a test-> unit test project (the project template that comes with ).
The result shows that even if xUnit is correctly installed, neither the Resharper or the Test Runer provided by vs can detect the unit Test method I have compiled. Well, I don't have to worry about it. See the official documentation:
Http://xunit.github.io/docs/getting-started-desktop.html
Correct operation:
1.0 create a class library project;
2.0 Nuget console-> install-package xunit
In this way, an xUnit unit test project has been established. In fact, what I want to say is that a unit test project is essentially a class library project.
3 encoding Test
The code is relatively simple. It is recommended that you manually press it. I will directly:
Click the small icon in front of the 14 rows and select Run.
As you can see, the test is successful. The icon in front of the 14 Rows hasGreen check markBecause I only run a unit test for a method, the leftmost icon of the 20-line test method does not have a green check mark.
There are too many test methods. You can right-click the current test project and choose Run Unit Tests.
As you can see, the test fails in 20 rows, and the red icon appears on the left. At the same time, the red icon appears in 11 rows. That is to say, this class has not passed the test.
The following figure shows the management unit test panel:
It's over.