To add xUnit test to the solution add a Class Library (Package) project.
Edit the default project.json shown below.
Add dependency to the ASP.Net 5 web project, and to xUnit and xUnit.Runner.Final project.json should be similar to below.
{ "version": "1.0.0-*", "description": "BookMyEvents.UnitTests Class Library", "authors": [ "Chaminda" ], "tags": [ "" ], "projectUrl": "", "licenseUrl": "", "dependencies": { "BookMyEvents": "1.0.0-*", "xunit": "2.1.0", "xunit.runner.dnx": "2.1.0-rc1-build204" }, "commands": { "test": "xunit.runner.dnx" }, "frameworks": { "dnx451": { }, "dnxcore50": {} } }
Let’s write a test for a very simple controller method.
Test method as a Fact (There are two types of Unit Tests in xUnit. Fact and Theory. More information here).
Go to test explorer in VS to view the test.
If you cannot see test as above build your solution. Test will be then available in the explorer. Execute and you can see the results.
Next post let’s learn how to run the unit tests (xUnit), with VS Team Service build and publish test results.
1 comment:
Hello,
The Article on Unit Test for ASP.Net 5 with xUnit is very informative. It give detail information about it .Thanks for Sharing the information on Unit testing for ASP.net.
Software Testing Services
Post a Comment