Back to Devexpress

Screenshot Tests (Visual Testing)

expressappframework-403972-debugging-testing-and-error-handling-functional-tests-easy-test-write-tests-csharp-vb-screenshot-tests.md

latest1.7 KB
Original Source

Screenshot Tests (Visual Testing)

  • Feb 02, 2026
  • 3 minutes to read

EasyTest supports screenshot testing for XAF ASP.NET Core Blazor and Windows Forms. This topic explains how to run screenshot tests.

Add a Visual Test

The steps below show how to add a visual test for the login form.

  1. In your test project, create a Screenshots folder, and add an expected image ({BlazorAppName}_Login.png) and a mask image ({BlazorAppName}_Login_Mask.png). In the properties window, set the Build Action property for these images to Embedded resource.

  2. Add the following code to get an image from the embedded resources:

  3. The following method saves an image to a file:

  4. Add test code:

Image Types

Expected image

The screenshot test compares an actual screenshot with an expected image. The expected image captures the application’s visual state you need to achieve during the test.

Mask image

Use a mask image to ignore a particular area on the screenshot (for example, a text input with a blinking cursor). Mask images are of the same size as their corresponding expected images. A mask image has a white background; ignored areas are painted in black.

Diff image

A diff image shows the difference between expected and actual images. The different areas are painted red.

Actual image (Screenshot) An application screenshot captured during testing. If the actual image is the same as the expected image, the test passed.