This topic is important to me because I want to be able to have a series of test that I can run to ensure my application runs.
Swashbuckle.AspNetCore NuGet package.Startup.cs file, add services for Swagger in the ConfigureServices method.services.AddSwaggerGen method to configure Swagger options and document generation settings.Startup.cs file, add middleware for Swagger in the Configure method.app.UseSwagger and app.UseSwaggerUI methods to configure the Swagger UI endpoint and UI settings./swagger.We want to write unit test for our controllers in our web applications.
You can test the view returned by a controller action, how to test the View Data returned by a controller action, and how to test whether or not one controller action redirects you to a second controller action.
Write Unit Tests
In your test class, you’ll need to set up the following: A reference to the controller being tested. Mocked instances of services or dependencies that your controller depends on.
Define Test Cases
Define individual test methods within your test class. Each test method should focus on testing a specific scenario or functionality of your controller action.
Unit Test involve testing a part of an app in isolation from its infrastructure and dependencies.
Write test methods to test your controller actions.
Use the test client to send HTTP requests and receive responses.
Assert the responses, status codes, view results, or data returned by the actions.
Unit testing ASP.NET Core MVC controllers helps ensure the correctness of your application's behavior.
xUnit and Moq are powerful tools for creating effective and reliable controller tests.
I want to learn when I’ll use unit testing in a work place setting.
I want to learn the different libraries that I can use to build things cool, like with Swagger for example.