XUnit Entry 1: xUnit entry

Source: Internet
Author: User
Tags xunit

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.

 

Related Article

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.