Functional Tests (EasyTest)
- 3 minutes to read
The eXpressApp Framework includes its own functional testing engine - EasyTest.
EasyTest features a laconic syntax and a simple set of commands. Using a custom script language has strong advantages - you write tests in XAF terms and your tests work for WinForms, ASP.NET Core Blazor and ASP.NET Web Forms applications.
This topic describes the basics of using EasyTest, and the components it comprises. For step-by-step instructions on how to test your XAF applications, refer to the Test an Action topic.
Add EasyTest to Your Project
The Solution Wizard creates new applications that already have integrated EasyTest components.
Refer to the following articles for information on how to integrate EasyTest to your XAF projects:
- Integrate EasyTest to XAF WinForms Applications
- Integrate EasyTest to XAF Blazor UI Applications
- Integrate EasyTest to XAF ASP.NET Web Forms Applications
- EasyTest Configuration
Create a Test
You can create test scripts in two ways.
Manually
Add a new text file to your project, change the file extension to
*.ets
, and enter a test script in it. Refer to the following topic for a list of available script commands: EasyTest Script Reference.The code sample below demonstrates a sample test added to newly created XAF applications.
;#DropDB MySolutionEasyTest #Application MySolutionWin ;#Application MySolutionWeb *FillForm User Name = Admin *Action Log In #IfDef MySolutionWin *Action About... *Action OK #EndIf #IfDef MySolutionWeb *Action Navigation(My Details) #EndIf
Use the EasyTest script recorder
For the .NET Framework applications, you can use the EasyTest Script Recorder. It can record the actions you perform on a UI and save them to an EasyTest script file.
Run a Test
With EasyTest, you can test your applications from Visual Studio or integrate functional testing in your CI/CD environment.
For information on how to run tests refer to the following topic: Run Tests.
EasyTest Components
When you create a new XAF solution, the FunctionalTests folder is added to the module project.
This folder contains the EasyTest configuration file and the Sample.ets sample test script file. You can use the sample test script to get a general idea of the script syntax.
EasyTest requires that the Config.xml configuration file is present in the folder containing a test script to be able to perform the test script. This file serves as a central storage for the configuration information required by test scripts. The configuration file created by default contains application definitions for the solution’s application project. You can create test scripts in any folder. However, since the FunctionalTests folder contains the automatically generated configuration file, it is recommended that you store test scripts here. For more information about the configuration file, refer to the EasyTest Configuration topic.
New solutions are created with a separate EasyTest connection string defined in application projects’ configuration files. This connection string is named EasyTestConnectionString. While testing, the applications use the database specified by this connection string.
EasyTest Limitations
- Administrative privileges may be required to run EasyTest scripts. If a script fails to run, try to start Visual Studio as an administrator.
- To run EasyTest for an ASP.NET Web Forms application, disable the Browser Link feature. Otherwise, your tests may fail to execute with the “WaitCallback - operation is not finished, pending ‘setTimeout’ handlers“ exception.