Today's continuation of yesterday's topic-Unit testing, however, is a unit test in ASP. NET 5.
In the current visual Studio CTP6, MSTest is not supported for unit testing of ASP. NET 5 projects. Therefore, for unit testing (or integration testing) of ASP. NET 5, you need to introduce other test frameworks, such as xunit.net.
Introducing Xunit.net is simple, adding Xunit.net's NuGet package (add the following in the Package.json file):
"Xunit": "2.1.0.0-beta1-build2945",
"Xunit.runner.aspnet": "2.1.0.0-beta1-build60",
"Xunit.runner.visualstudio": "2.1.0.0-beta1-build1051"
To integrate LOCALDB in your tests, you typically divide it into 3 steps:
- Copy the SQL from the build database to a deployment item. This article provides a sample code for the Itemdeployment class to do this thing.
- Execute SQL to create the database. This article provides a sample code for the LocalDB class to complete this thing.
- The data in the database is accessed in the test code to verify correctness.
Because the code is more complex, I do not post here, interested readers jump to the article to see it.
Original address: http://blog.developers.ba/localdb-for-database-integration-testing-in-asp-net-5-project-and-xunit-net/
How to perform LOCALDB integration testing in ASP. NET 5 and Xunit.net