Skip to main content
All docs
V23.2
.NET 6.0+

Integrate EasyTest to XAF WinForms Applications

  • 4 minutes to read

Overview

This topic describes how to integrate EasyTest functional testing to your XAF WinForms application.

Tip

The Solution Wizard creates new applications that already have integrated EasyTest components. The wizard does the following:

  • Adds the EasyTest solution configuration.

    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) into the platform-independent YourApplicationName.Module module.

If your application already has EasyTest integrated, go to the Next Steps.

Configuration

Typically, the EasyTest configuration file (config.xml) is stored in the FunctionalTests folder in a platform-agnostic module.

For .NET Framework Projects

The code below demonstrates a sample configuration file for the .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.v23.2, Version=23.2.5.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
        <Alias Name="WinAppBin" Value="[ConfigPath]\..\..\MySolution.Win\Bin\EasyTest" />
    </Aliases>
</Options>

For .NET 6+ Projects

Requirement: install the DevExpress.ExpressApp.EasyTest.WinAdapter NuGet package to your YourApplicationName.Win project.

The code below demonstrates a sample configuration file for .NET 6+ 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.v23.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.
FileName Specifies the fully qualified name of the application’s executable file. You can use the built-in [ConfigPath] alias to specify a path relative to the Config.xml file location.
Arguments Optional. Specifies the command-line arguments passed to the application when it is started.
AdapterFileName (For .NET 6 projects) The path to the WinForms EasyTest adapter. To use the standard adapter, specify the following path: %ProgramW6432%\DevExpress 23.2\Components\Bin\NetCore\DevExpress.ExpressApp.EasyTest.WinAdapter.v23.2.dll
AdapterAssemblyName (For the .NET Framework projects) Specifies the name of the Windows Forms EasyTest adapter. This is an EasyTest assembly that contains a platform-specific functionality. The attribute contains the adapter’s assembly filename, assembly version, culture and public key.
CommunicationPort Specifies the communication port number that will be used by EasyTest when testing the application.

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 database connection strings specified in the application projects’ configuration files. So you may want to backup the databases used by the applications before running any actual tests.

In a Windows Forms application project, the following methods must be updated.

  1. The DatabaseVersionMismatch method in the WinApplication.cs (WinApplication.vb) file.

    private void MySolutionWindowsFormsApplication_DatabaseVersionMismatch(
        object sender, DevExpress.ExpressApp.DatabaseVersionMismatchEventArgs e) {
    #if DEBUG
        e.Updater.Update();
        e.Handled = true;
    #else
        if (System.Diagnostics.Debugger.IsAttached) {
            //...
        }
        else {
            //...
        }
    #endif
    }
    
  2. The Main method in the Program.cs (Program.vb) file.

    static void Main() {
    #if DEBUG
        DevExpress.ExpressApp.Win.EasyTest.EasyTestRemotingRegistration.Register();
    #endif
    //....
    }
    
  3. Only for .NET 6+ projects. 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>
    
  4. EasyTest listens the 4100 port by default. 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.

Next Steps