Skip to main content

Writing Unit Tests

Unit Testing

Unit Testing is incredibly important for the longevity of your app. While its uses are more limited in Mendix, there are some use cases that are good to test. Note that you cannot test any data changes from pages with this, only microflows you call.

Go through the Unit Testing portion of this learning Path: https://academy.mendix.com/link/paths/57/Quality-Control-and-Testing

This will give you the basic understanding of how the Unit Testing Module functions. It is not included by default in the BYU starter app, so you will need to download it for and Mendix app.

Here are a few use cases for unit testing in Mendix:

  1. Verifying that external APIs we get no notifications for are healthy

    1. Normally for non-byu Apis
  2. Large scale data processing.

    1. When changes are made later, you want redundancy in verification.

Avoiding Live Data:

When you are testing in Mendix, you should avoid adding/manipulating the database for testing. The Unit Testing Module includes functionality. In each module, when testing for it begins, it will search for “Setup” and “Teardown” microflows, and run them. You should use these to create and then delete data for your testing.

To use the data, add a unique identifier to them, so you can easily retrieve them from the database when you are writing test microflow.