ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

New WINDEV 2024 feature!
Help / WINDEV Tutorial / Tutorial - Monitoring the evolution of an application
  • Automated tests
  • Overview
  • A practical example: creating an automated test
  • Creating an automated test
  • Testing changes in the application
  • Modifying the WLanguage code of an automated test
  • Further information

Tutorial - Monitoring the evolution of an application

Automated tests
We will cover the following topics:
  • How to create automated tests.
  • How to run automated tests.
  • How to edit automated tests.
Durée de la leçon 20 mn
Overview
In Full application with data, we developed a WINDEV application. Applications evolve over time: specific user requests, integration of new functionalities, etc. We need to make sure that these changes won't affect the existing elements.
WINDEV includes several tools to help you monitor the progress of your WINDEV projects and avoid regressions.
In this tutorial, we will focus on automated tests.
If you have followed the different WINDEV tutorials, you will have performed a number of tests throughout the development process: window tests or project tests.
Automated tests are a category of specific tests. Automated tests automatically perform a series of operations in your windows. These tests are recorded as WLanguage scenarios and can be easily edited in the code editor. Once recorded, automated tests can be re-run as many times as necessary, to test, for example, the impact of a change made to a window, procedure, etc.
Automated tests can be run on windows, procedures and classes.
A practical example: creating an automated test
To implement automated tests, we will use the "WD Full Application" project.
Opening the example project
  1. Go to the WINDEV home page (Ctrl + <).
  2. On the home page, click "Tutorial", then in "Tutorial - WINDEV Application: Manage data", double-click "Full application - Answers".
Let's create an automated test in the menu window of the "WD Full Application" project.

Creating an automated test

To create an automated test on a window, simply run a test:
  1. Open the "WIN_Menu" window in the editor.
  2. On the "Automated tests" tab, in the "Tests" group, expand "New" and select "Record a new scenario".
  3. In the window that appears, click "Start recording".
  4. The test of the window is run.
  5. Click the "Find orders" tab pane.
  6. Choose the "Credit card" payment mode.
  7. Click "Find".
  8. Close the window via "Menu .. Exit" and confirm the end of the application.
  9. The recording of the automated test has ended.
The test editor proposes to save a description for the automated test we just created.
  1. Enter the name of the automated test: "Test for finding orders".
  2. Validate.
The test editor displays the WLanguage code of the test that has just been recorded:
WLanguage code of an automated test
The WLanguage functions used to run automated tests are the EmulateXXX functions.
The test is currently available and has not been run (Available test next to the name of the test in the editor).
The test can be run at any time:
  1. Select the test name in the test editor.
  2. Right-click and select "Run" in the context menu.
  3. The test runs automatically.
  4. The test editor displays the result in the "Test results" pane (the test ran successfully in our case).
  5. Save the test if necessary (Save or Ctrl + S)
Testing changes in the application
Our test is up and running: when run again, no errors appear.
We will make a change in the window and run the test again.
The change is as follows: we will gray out the "Find" button.
  1. Open the "WIN_Menu" window if necessary.
  2. In the editor, click the "Find orders" tab pane and select the "Find" Button control.
  3. Open the control description (select "Description" in the context menu).
  4. In the "UI" tab, select "Grayed".
  5. Validate the control description window.
  6. Save the window.
The changes have been applied. Now, we can simply run the automated test to check for any regressions.
  1. Go back to the test editor (click the corresponding tab in the open document tabs).
  2. Run the test again.
  3. The test appears again in the test editor. The "Compilation errors" tab pane shows several test errors.
    As shown here, the error indicates that the BTN_Find button is not visible.
Since we made these changes just as an example, we can undo them so that the test runs successfully again:
  1. Open again the "WIN_Menu" window in the editor.
  2. Open the description of the "Find" Button control (select "Description" in the context menu).
  3. In the "UI" tab, select "Enabled".
  4. Validate the control description window.
  5. Go back to the test editor (click the corresponding tab in the open document tabs).
  6. Run the test again. The test is now completed successfully.
Modifying the WLanguage code of an automated test
Since automated tests correspond to WLanguage code, you can modify or add WLanguage code directly to test scenarios.
To quickly test this feature, we will add a few lines of code to check that the Table control contains at least one record.
  1. Open the test editor if necessary (for example, double-click "TEST_Menu" in the "Tests" folder of the "Project explorer" pane).
  2. Add the following code before the "EmulateMenu("_Menu","OPT_Exit")" line:
    // If the Table control contains no record
    IF WIN_Menu.TABLE_QRY_FindOrders.Count = 0 THEN
    // An error must be signaled 
    TestWriteResult(twrError, ...
    "The Table control is empty after the search")
    END
    Modifying the WLanguage code of an automated test
  3. Save the test (Save or Ctrl + S)
  4. Click Test an element. The test is completed successfully. The Table control contains at least one record.
We have now covered all the basics of automated tests. Close the automated test editor.
Further information
The test editor contains many features that we won't be able to cover in this tutorial:
  • the use of a set of test values.
  • the input and output parameters of the test.
  • the possibility to create a test library to test an executable on a computer other than the development computer for example.
For more details on automated tests, see Overview of automated tests.
Table of contents
Minimum version required
  • Version 2024
Comments
Click [Add] to post a comment

Last update: 12/04/2023

Send a report | Local help