How to add integration tests?

2025/12/11 4:49 PM

Has anyone been able to add some integration tests to their Xperience by Kentico projects? Specifically using the Microsoft.AspNetCore.Mvc.Testing package?

The package works when running through a regular console application, but when I use the same code inside an xunit test, it gets to app.InitKentico() then the test runner just stops unexpectedly without much of an error message.

Tried with the dancing goat sample from a while ago and getting the same thing.

Tags:
.NET ASP.NET Core C#

Answers

2025/12/11 5:14 PM

TLDR; Yes!

End-to-end tests have been part of the Kentico Community Portal project for a couple of years, including tests for membership journeys.

They can be run locally but are almost exclusively run in the GitHub workflow CI pipeline as part of PRs.

.NET 10 support for Xperience by Kentico, available in December's Refresh (releasing 2025/12/11) will enable a simpler orchestration of running these types of UI tests.

You should also be able to use the new Microsoft Test Platform for easier test running and configuration.

2025/12/12 9:27 AM

Thanks for the response.

The Kentico community portal project tests look like selenium tests where the tests are controlling a browser instance and telling it to go to certain pages and ensuring that the response contains certain HTML elements etc.

The tests I'm asking about are described here:

Integration tests in ASP.NET Core | Microsoft Learn

Allows testing of API endpoints within a project and verifying the contents of the HTTP responses.

2025/12/12 2:45 PM

You can also write integration tests, automating the test of a specific set of functionality with the database but without running the entire application.

There are also examples of this in the Kentico Community Portal.

However, in all my (13) years of working with Kentico I've found the most value in E2E tests, not unit or integration tests.

This is even more true now:

Just an additional note, the E2E tests I linked you to are not using Selenium, which is not the only technology that supports E2E tests.

Instead, they are using Playwright. It's a far more modern and easier to use E2E testing framework that is cross-platform, fast, and cross-browser. We use it to run E2E tests against Kentico itself.

2025/12/15 11:18 AM

Useful to know, thanks again.

It's a shame the Microsoft approach isn't supported - we have some API endpoints we would like to write tests for. They include calling external services and combining content & configuration stored in Kentico. I believe you can use Playwrite to call APIs and check responses but we would have preferred to be able to write integration tests using the same method we already have for the external services which are .net core services.

To response this discussion, you have to login first.