Author: Marinko Spasojevic

Automated UI tests with Selenium and ASP.NET Core MVC

Selenium is a library that helps us automate browser behavior. We can use it for different purposes, but its primary use is for automated testing of web applications. In this article, we are going to use Selenium to write automated UI tests and with that finish our testing series. Selenium has support for many different browsers and for this article, we are going to use the ChromeDriver. It also contains many different useful methods (Navigate, GoToUrl, FindElement, SendKees, Click…) which help us manipulate different HTML elements. These methods are going to be of great use in our examples. You...

Read More

How to Include AntiForgeryToken for MVC Integration Testing

In the previous article, we have learned how to write integration tests for different actions (Index and Create), but while we were testing the Create (POST) action, we faced a problem with AntiForgeryToken validation. We skipped that problem by commenting out that validation attribute and our test passed, but that was just a temporary solution. In this article, we are going to solve that problem. We will learn how to extract AntiForgeryToken from the HTML response and how to use it in our tests. After fixing our problem, we will be able to test our actions that are protected...

Read More

Integration Testing in ASP.NET Core MVC

We have covered a lot of different topics in the previous articles. We have learned how to use xUnit to write Unit tests for our Validation class and how to test our Controller class with its actions by using the Moq library to isolate dependencies. In this article, we are going to learn about Integration Testing in ASP.NET Core MVC. Additionally, we are going to prepare an in-memory database so we don’t have to use the real SQL server during integration tests. You can download the source code on our GitHub repository. For the complete navigation of this series, you can...

Read More

Testing MVC Controllers in ASP.NET Core

In the previous article, we have learned how to write Unit Tests by using the xUnit and different attributes that xUnit provides for us. We have seen how to test validation rules inside a single validation class. But what about controllers and all the actions inside? Can we write tests for them too? Sure we do. In this article, we are going to explain how to do that. You can download the source code on our GitHub repository. For the complete navigation of this series, you can visit ASP.NET Core MVC Testing. These are the topics we are going to cover:...

Read More

Unit Testing with xUnit in ASP.NET Core MVC

This is the first article from the series where we are going to present different topics related to unit testing with xUnit in ASP.NET Core MVC. We are going to start with a brief overview of the xUnit tool and our starting project. Later on, we are going to add a new class with validation logic and finally, learn how to test that new functionality with the xUnit project. You can download the source code for the starting project on our GitHub repository. We have also provided the source code for the finished project for this article. For the complete...

Read More

Widget1