expressappframework-403393-debugging-testing-and-error-handling-functional-tests-easy-test-write-tests-human-readable-test-blazor-apps.md
XAF can run functional tests for Blazor UI applications based on the Selenium driver to interact with a browser.
EasyTest for Blazor supports the following browsers:
This topic describes how to integrate EasyTest functional testing into your XAF Blazor application.
Configure your working machine as described below:
Install the DevExpress.ExpressApp.EasyTest.BlazorAdapter package to your YourApplicationName.Blazor.Server project.
Tip
The Template Kit creates new applications that already have integrated EasyTest components. The wizard does the following:
Adds the EasyTest solution configuration.
Adds all the necessary code to allow you run tests in the EasyTest solution configuration.
Adds the FunctionalTests folder with a configuration file (config.xml) and a sample test (sample.ets) to the platform-independent YourApplicationName.Module module. Installs the DevExpress.ExpressApp.EasyTest.BlazorAdapter package to your YourApplicationName.Blazor.Server project (only for the EasyTest solution configuration).
The code below demonstrates a sample configuration file. You can edit it according to your project environment.
<?xml version="1.0" encoding="utf-8" ?>
<Options xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Applications>
<!-- Blazor -->
<Application
Name="DXApplication1Blazor"
Url="http://localhost:4030"
PhysicalPath="[BlazorAppPath]"
AdapterFileName="[BlazorAdapterAssemblyPath]"
Configuration="EasyTest"
IgnoreCase="true"/>
</Applications>
<TestDatabases>
<Database xsi:type="TestMSSQLDatabase" Server="(localdb)\mssqllocaldb" DBName="DXApplication1EasyTest"/>
</TestDatabases>
<Aliases>
<Alias Name="BlazorAppPath" Value="[ConfigPath]\..\..\DXApplication1.Blazor.Server" />
<Alias Name="BlazorAdapterAssemblyPath" Value="[BlazorAppPath]\bin\EasyTest\net8.0\DevExpress.ExpressApp.EasyTest.BlazorAdapter.v21.2.dll" />
</Aliases>
</Options>
| Attribute | Description |
|---|---|
| Name | Specifies the name of the Application element. This name is used to differentiate between different applications. The Application command takes this name as the parameter. |
| Url | The application’s web address. |
| PhysicalPath | A path to the folder that contains the application. You can use the built-in [ConfigPath] alias to specify a path to the Config.xml file. |
| AdapterFileName | Specifies a path to the Blazor EasyTest adapter. This is an EasyTest assembly that contains platform-specific functionality. The attribute contains the adapter’s assembly filename, assembly version, culture, and public key. |
| IgnoreCase | Specifies whether the test ignores a letter case when referring to UI element names, captions, or tags. |
| Configuration | Specifies the configuration to use when running tests. |
| WebDriverPath | Specifies a path to a folder that stores a web driver executable. |
| Browser | Specifies a web browser to use for running tests. Available values: Chrome, Edge (the default value). |
| Alias | Description |
|---|---|
| BlazorAppPath | A path to a Blazor application. |
| BlazorAdapterAssemblyPath | A path to the Blazor EasyTest adapter. This path typically points to a project’s build results. Reference the DevExpress.ExpressApp.EasyTest.BlazorAdapter adapter and it becomes available in the project’s build results. In new applications created by the Template Kit, the adapter is already referenced in the project and this option is set to a folder with the build results. |
The following steps describe the modifications required to support EasyTest in the Debug solution configuration.
Note that after updating the solution in this way, EasyTest will use the database connection strings specified in the application projects’ configuration files. As such, you may want to back up the databases used by the applications before running any tests.
In a Blazor application project, update the DatabaseVersionMismatch method in BlazorApplication.cs:
private void MyBlazorApplication_DatabaseVersionMismatch(object sender, DevExpress.ExpressApp.DatabaseVersionMismatchEventArgs e) {
#if DEBUG
e.Updater.Update();
e.Handled = true;
#else
if (System.Diagnostics.Debugger.IsAttached) {
//...
}
else {
//...
}
#endif
}
Use the TestExecutor Utility to run tests.
cd %ProgramFiles%\DevExpress 25.2\Components\Tools\eXpressAppFrameworkNetCore\EasyTest
TestExecutor.v25.2.exe C:\PathToTest\sample.ets
You can remove all EasyTest components from your application. In this case, delete the following:
EASYTEST conditions from the Blazor application project’s BlazorApplication.cs file.