Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Testing

mxcli includes a testing framework for a Mendix app’s own logic: each test calls into the running app — a microflow, a retrieve — and asserts on what came back or what was written. It is not a check that an MDL script parses; that is mxcli check.

Overview

The testing framework supports two test file formats:

FormatExtensionDescription
MDL test files.test.mdlTests as MDL blocks with annotations
Markdown test files.test.mdLiterate tests with prose and embedded mdl-test blocks

Prerequisites

Tests execute against a real Mendix runtime. Docker is one way to get one, not the only one — --local uses mxcli’s own runtime with no daemon, and is the faster path (see Running Tests for the mode comparison and the --watch / --attach loops). Either way the runner:

  1. Installs a temporary MxTest module holding one microflow per test
  2. Boots (or reuses) the app and invokes each test over a token-guarded endpoint
  3. Evaluates that test’s assertions and reports pass, fail or error
  4. Removes what it installed, leaving the project byte-identical

Quick Start

# Run all tests in a directory
mxcli test tests/ -p app.mpr

# Run a specific test file
mxcli test tests/sales.test.mdl -p app.mpr

Test Workflow

  1. Write test files using .test.mdl or .test.md format
  2. Name each test with @test and assert with @expect / @verify / @throws
  3. Run tests with mxcli test
  4. Review results

Example Test

-- tests/customer.test.mdl

/**
 * @test a new customer is active by default
 * @expect $customer/IsActive = true
 */
$customer = call microflow MyFirstModule.ACT_CreateCustomer(Name = 'Acme');
/

/**
 * @test the seed microflow writes five customers
 * @cleanup none
 * @expect count($customers) = 5
 * @verify select count(*) as n from MyFirstModule.Customer = 5
 */
call microflow MyFirstModule.ACT_Seed();
retrieve $customers from MyFirstModule.Customer;
/

An assertion the runner cannot evaluate is reported as an ERROR, never as a pass — see Test Annotations.

Playwright UI Testing

For browser-based testing that verifies widgets render correctly in the DOM, see Playwright Testing. mxcli test asserts on what the app’s logic returns and writes; Playwright testing asserts on what the app renders – that widgets are visible, forms accept input, and navigation works.

# MDL validation (this page)
mxcli test tests/ -p app.mpr

# Browser-based UI verification
mxcli playwright check /p/Customer_Overview -p app.mpr   # does it render? one call, text verdict
mxcli playwright verify tests/ -p app.mpr