Integrate EasyTest into XAF WinForms Applications
- 4 minutes to read
#Overview
This topic describes how to integrate EasyTest functional testing into your XAF WinForms application.
Tip
The Solution Wizard creates new applications that already have integrated Easy
Adds the
Easy
solution configuration.Test - Adds all necessary code to allow you to 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.Name. Module
If your application already has EasyTest integrated, go to the Next Steps section.
#Configuration
Typically, the EasyTest configuration file (config.xml) is stored in the FunctionalTests folder in a platform-agnostic module (MySolution.Module).
#For .NET Framework Projects
The following code snippet demonstrates a sample configuration file for .NET Framework projects. 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>
<!-- Win -->
<Application
Name="MySolutionWin"
FileName="[WinAppBin]\MySolution.Win.exe"
AdapterAssemblyName="[WinAdapterAssemblyName]"
CommunicationPort="4100"/>
</Applications>
<TestDatabases>
<Database xsi:type="TestMSSQLDatabase" Server="(localdb)\mssqllocaldb" DBName="MySolutionEasyTest"/>
</TestDatabases>
<Aliases>
<Alias Name="WinAdapterAssemblyName" Value="DevExpress.ExpressApp.EasyTest.WinAdapter.v24.2, Version=24.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
<Alias Name="WinAppBin" Value="[ConfigPath]\..\..\MySolution.Win\Bin\EasyTest" />
</Aliases>
</Options>
#For .NET Projects
Requirement: Install the DevExpress.ExpressApp.EasyTest.WinAdapter
NuGet package to your YourApplicationName.Win
project.
The following code snippet demonstrates a sample configuration file for .NET projects. 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>
<!-- Win -->
<Application
Name="MySolutionWin"
FileName="[WinAppBin]\MySolution.Win.exe"
AdapterFileName="[WinAdapterFileName]"
CommunicationPort="4100"/>
</Applications>
<TestDatabases>
<Database xsi:type="TestMSSQLDatabase" Server="(localdb)\mssqllocaldb" DBName="MySolutionEasyTest"/>
</TestDatabases>
<Aliases>
<Alias Name="WinAppBin" Value="[ConfigPath]\..\MySolutionWin.Win\Bin\EasyTest" />
<Alias Name="WinAdapterFileName" Value="[WinAppBin]\DevExpress.ExpressApp.EasyTest.WinAdapter.v24.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. |
File |
Specifies the fully qualified name of the application’s executable file. You can use the built-in [Config |
Arguments | Optional. Specifies the command-line arguments passed to the application when it is started. |
Adapter |
(For .NET 8+ projects) The path to the Win |
Adapter |
(For .NET Framework projects) Specifies the name of the Windows Forms Easy |
Communication |
Specifies the communication port number that will be used by Easy |
#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 Windows Forms application project, the following methods must be updated:
The DatabaseVersionMismatch method in the WinApplication.cs (WinApplication.vb) file.
The Main method in the Program.cs (Program.vb) file.
For .NET projects only. In the App.config file, add the following keys to <appSettings>:
<?xml version="1.0"?> <configuration> <!-- ... --> <appSettings> <!-- ... --> <add key="EasyTestTraceLevel" value="4"/> <add key="EasyTestLogFileName" value="TestExecutor.log" /> </appSettings> </configuration>
EasyTest listens to the default 4100 port. To use another port, specify the EasyTestCommunicationPort key value in the application configuration file (App.config). The custom port must match the port specified in the EasyTest Config.xml configuration file.
<appSettings> <!-- Specify a custom port --> <add key="EasyTestCommunicationPort" value="15923"/> <!-- ... --> </appSettings>
#Remove EasyTest
You can remove all EasyTest components from your application. In this case, delete the following:
- The FunctionalTests folder.
- The DevExpress.ExpressApp.EasyTest.WinAdapter assembly reference (or NuGet package) from the Windows Forms application project.
- The
EASYTEST
conditions from the Windows Forms application project’s Program.cs (Program.vb) and WinApplication.cs (WinApplication.vb) files.