Contents tagged with Unit Testing
Functional Testing plays an important role in delivering software products with great quality and reliability. Even though the ability to write in-memory functional tests in ASP. NET Core MVC application is present in ASP.NET Core 2.0, it had some pitfalls
- Manual copying of the .deps files from application project into the bin folder of the test project
- Needed to manually set the content root of the application project so that static files and views can be found
Bootstrapping theapp on the Test Server.
In ASP.NET Core 2.1, Microsoft has released a new package Microsoft.AspNetCore.Mvc.Testing which solves all the above mentioned problems and helps you to write and execute in-memory functional tests more efficiently. To check how it can be done, let's create two projects - one for the web application and another for our test project.
Create an ASP.NET Core MVC project without any authentication. The following command will create one in the folder specified by the -o switch
dotnet new mvc -au none -o SampleWeb/src/WebApp
Let's add a test project based on Xunit test framework using the below command. As in Step 1, the project will be created in the specified folder
dotnet new xunit -o SampleWeb/test/WebApp.Tests
Now we will create a solution file and add these two projects into it.
dotnet new sln
dotnet sln add src/WebApp/WebApp.csproj
dotnet sln add .\test\WebApp.Tests\WebApp.Tests.csproj
Breaking Changes in coming your way for ASP.NET Core 3.0
Resilient Connections in Entity Framework Core