Skip to main content
All docs
V24.2
.NET 8.0+

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

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 EasyTest components. The wizard does the following:

  • Adds the EasyTest solution configuration.

    EasyTest solution configuration

  • Adds all necessary code to allow you to 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.

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.
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 8+ projects) The path to the WinForms EasyTest adapter. To use the standard adapter, specify the following path: %ProgramW6432%\DevExpress 24.2\Components\Bin\NetCore\DevExpress.ExpressApp.EasyTest.WinAdapter.v24.2.dll
AdapterAssemblyName (For .NET Framework projects) Specifies the name of the Windows Forms 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.
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 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:

  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. 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>
    
  4. 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.

#Next Steps