Testing
mxcli includes a testing framework for validating Mendix projects using MDL test files. Tests verify that MDL scripts execute correctly and that the resulting project passes validation.
Overview
The testing framework supports two test file formats:
| Format | Extension | Description |
|---|---|---|
| MDL test files | .test.mdl | Pure MDL scripts with test annotations |
| Markdown test files | .test.md | Literate tests with prose and embedded MDL code blocks |
Prerequisites
Running tests requires Docker for Mendix runtime validation. The test runner:
- Creates a fresh Mendix project using
mx create-project - Executes the MDL test script against the project
- Validates the result with
mx check - Reports pass/fail results
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
- Write test files using
.test.mdlor.test.mdformat - Add
@testand@expectannotations for assertions - Run tests with
mxcli test - Review results
Example Test
-- tests/customer.test.mdl
-- @test Create customer entity
CREATE PERSISTENT ENTITY MyFirstModule.Customer (
Name: String(200) NOT NULL,
Email: String(200)
);
-- @expect 0 errors
-- @test Add association
CREATE ASSOCIATION MyFirstModule.Order_Customer
FROM MyFirstModule.Order
TO MyFirstModule.Customer
TYPE Reference;
-- @expect 0 errors
Playwright UI Testing
For browser-based testing that verifies widgets render correctly in the DOM, see Playwright Testing. While mxcli test validates that MDL scripts execute correctly and the project passes mx check, Playwright testing goes further by verifying the running application in a real browser – checking 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 verify tests/ -p app.mpr
Related Pages
- Test Formats –
.test.mdland.test.mdfile formats - Test Annotations –
@testand@expectannotations - Running Tests –
mxcli testcommand and Docker requirements - Playwright Testing – Browser-based UI testing with playwright-cli
- Diff – Comparing scripts against project state