Go to ASP. 5: Unit Test

Source: Internet
Author: User
Tags xunit

1. Preface

Before I try to deploy the ASP.NET5 Unit test environment, I'm confused about using the test framework before we talk about "playing with the ASP. NET 5: Data manipulation Package (ii)"(draft already proofing, still at the discretion) . Although I am not accustomed to, not good at unit test thinking programming method, but recently in groping it. No, I need to find a asp.net5. Test framework. Also see the famous Xunit framework to support VS2015 CTP5 situation.

This article also on the reference http://xunit.github.io/docs/getting-started-aspnet.html experience, counted as a personal anti-copy notes it!

2. Create a project

In the testsolution solution, create a Testdemo class Library project, such as:

3. Install the test framework

Open Project.json File:

But could not find the RC version , we go to www.nuget.org to search, you can find:

Also find runners version:

After installing our package Manager Console :

Note: It is not consistent with the name of the official tutorial to find out carefully:

First, whether it's this version or not. Plus commands:

4. Test Cases

In Class1.cs , modify to:

usingXunit;namespacetestdemo{ Public classClass1 {[Fact] Public voidpassingtest () {//throughAssert.equal (4, Add (2,2)); } [Fact] Public voidfailingtest () {//failedAssert.equal (5, Add (2,2)); }        //addition Operation        intADD (intXinty) {returnX +y; }    }}

5. Implementation

Commands defined, you can see this:

After this execution, and did not see what results!!! Brother Faint, just try to xunit.runners the name (the assembly does not change) to the following:

To run again, it appears:

And the exception prompt appears:

On the go, it's closed, and there's nothing in the Test Explorer window. What kind of test is this, egg?

6.DOS under test

Go to the project root directory and execute K xtest:

This is a hint of the test is very detailed. But you have to spit it out, integrated in the VS2015, still needs to be improved!

7. Summary

This article also has no technical content, sorry! If you have tried other VS2015 CTP under the test framework can, good, trouble you tell me! Thank you!

Go to ASP. 5: Unit Test

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.