Sergey Slepov
Sergey Slepov

Reputation: 2121

Integration testing Blazor apps

With Razor Pages, we had the TestServer class which we would use to write Integration tests in ASP.NET Core.

How would one go about testing a Blazor Server app? When I say integration testing, I mean testing the whole app: sending a request to the TestServer which runs the app, getting an HTML page back, and checking its contents.

Is this possible with Blazor Server? If not, what is the recommended approach for integration testing Blazor Server apps?

Upvotes: 1

Views: 2939

Answers (2)

Ray
Ray

Reputation: 3109

You can do that with IcuBlazor (https://icublazor.com/). Full Disclosure: I'm the author.

Upvotes: 1

Ogglas
Ogglas

Reputation: 70186

Microsoft has Selenium as an example for end-to-end testing with ASP.NET Core Blazor.

E2E testing: A test runner runs a Blazor app containing the Component Under Test (CUT) and automates a browser instance. The testing tool inspects and interacts with the CUT through the browser. Selenium is an example of an E2E testing framework that can be used with Blazor apps.

https://learn.microsoft.com/en-us/aspnet/core/blazor/test?view=aspnetcore-5.0

Example with ASP.NET Core MVC to start from:

https://code-maze.com/automatic-ui-testing-selenium-asp-net-core-mvc/

Upvotes: 2

Related Questions