Skip to content

mxcli test leaves an orphaned, empty MxTest module in the project after every run #804

Description

@fabric-ian

Summary

Every mxcli test run injects a generated MxTest.TestRunner microflow, executes it, and then cleans up. The cleanup step (cleanup() in cmd/mxcli/testrunner/runner.go) drops the generated microflow but never drops the containing MxTest module, so an empty MxTest module permanently accumulates in the project — even when all tests pass.

Steps to reproduce

Using a fresh blank project (mxcli new, so no pre-existing project state is involved):

mxcli new MxTestRepro --version 11.12.0 --skip-init
cd MxTestRepro

cat > smoke.test.mdl << 'EOF'
/**
 * @test Basic arithmetic sanity check
 * @expect $result = 4
 */
DECLARE $result Integer = 2 + 2;
/
EOF

./mxcli test smoke.test.mdl -p MxTestRepro.mpr

Result: "All tests passed." Then:

./mxcli -c "SHOW MODULES" -p MxTestRepro.mpr

Shows an MxTest module with 0 entities/microflows/pages/etc. — left behind permanently.

Root cause

cmd/mxcli/testrunner/runner.go, in cleanup():

// Drop the test runner microflow
execMxcliCmd(projectPath, "DROP MICROFLOW MxTest.TestRunner")

This only removes the microflow, not the module that wraps it.

Suggested fix

DROP MODULE is already fully supported by the MDL grammar and model SDK (sdk/mpr/writer_modules.go's DeleteModuleWithCleanup). Replacing the line above with:

execMxcliCmd(projectPath, "DROP MODULE MxTest")

is sufficient — confirmed locally that DROP MODULE MxTest correctly removes the module (including the microflow) in one step.

Environment

  • mxcli: built from main @ ead892672f82fdc5f54ed8a944e98026845700a2 (2026-07-28)
  • Mendix version: 11.12.0
  • Reproduced on a throwaway blank project, not a production project

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions