Integrate EasyTest into XAF Blazor UI Applications
- 4 minutes to read
#Overview
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:
- Google Chrome
- Microsoft Edge
This topic describes how to integrate EasyTest functional testing into your XAF Blazor application.
#Prerequisites
Configure your working machine as described below:
-
- For Google Chrome: download “chromedriver.exe” from https://chromedriver.chromium.org/downloads.
- For Microsoft Edge: download “msedgedriver.exe” from https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/?form=MA13LH.
Selenium requires a path to the downloaded driver. You can specify a path to the driver in any of the following ways:
- Add a folder with the driver to the system’s PATH variable.
Specify a path to the driver in EasyTest’s configuration file.
<Application ... WebDriverPath="C:\WebDriverPath" />
- Install the
DevExpress.ExpressApp.EasyTest.BlazorAdapter
package to yourYourApplicationName.Blazor.Server
project.
Tip
The Solution Wizard creates new applications that already have integrated Easy
Adds the
Easy
solution configuration.Test - Adds all the necessary code to allow you run tests in the
Easy
solution configuration.Test - Adds the Functional
Tests folder with a configuration file (config.xml ) and a sample test (sample.ets ) to the platform-independent YourApplication module. Installs theName. Module DevExpress.
package to yourExpress App. Easy Test. Blazor Adapter Your
project (only for theApplication Name. Blazor. Server Easy
solution configuration).Test
#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>
#Configuration 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. |
Physical |
A path to the folder that contains the application. You can use the built-in [Config |
Adapter |
Specifies a path to the Blazor Easy |
Ignore |
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. |
Web |
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). |
#Aliases
Alias | Description |
---|---|
Blazor |
A path to a Blazor application. |
Blazor |
A path to the Blazor EasyDevExpress. adapter and it becomes available in the project’s build results. In new applications created by the XAF Solution Wizard, the adapter is already referenced in the project and this option is set to a folder with the build results. |
#Run EasyTest in the Debug Configuration
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
}
#Run Tests
Use the TestExecutor Utility to run tests for .NET projects.
cd %ProgramFiles%\DevExpress 24.2\Components\Tools\eXpressAppFrameworkNetCore\EasyTest
TestExecutor.v24.2.exe C:\PathToTest\sample.ets
Note
Easy
#Remove EasyTest
You can remove all EasyTest components from your application. In this case, delete the following:
- The FunctionalTests folder.
- The DevExpress.ExpressApp.EasyTest.BlazorAdapter package from Blazor applications.
- The
EASYTEST
conditions from the Blazor application project’s BlazorApplication.cs file.