Testing & Undo of data in Mendix

0
Hello, I am new to Mendix and I am investigating possibilities to test Mendix apps in order to deliver a presentation about it to some of my colleauges. I was wondering how to undo the changes provoked by a Mendix test. I also saw that we could use the Unit Testing module yet I am unaware about a possiblity to revoke the changes after the execution. Does anyone have any idea about this?
asked
2 answers
0

Hello Andreia,

The unit testing module rolls back your changes by default! This is documented here ->

By default, all changes that are made when running a microflow test (committing new or changed objects) will be rolled back at the end of the test run. You can change this behavior for each test suite using the Rollback microflow tests after execution checkbox, which is visible after selecting a test suite. Note that the option only affects tests in the selected test suite.



answered
0

Short answer: Mendix doesn’t automatically undo changes after a test. If a microflow commits data, it stays in the database. :/


The Unit Testing module is mainly for checking logic, not for rolling back data. So you usually handle cleanup yourself. Common approaches are:


  • Run tests and demos in a separate test environment
  • Create and delete test data inside the same test microflow
  • Use non-persistable entities where possible
  • Tag test data (for example IsTestData = true) and clean it up with a reset microflow


For a presentation, the easiest option is a test environment plus a simple “reset demo data” microflow.


answered