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