Unit Test Module: TearDown microflow and option Rollback microflow tests after execution

0
Hi all, I'm using the Unit Testing module for testing locally a REST API. As some test cases include creating objects in the database, I wanted to drop them after tests completed, so I decided to use a TearDown microflow to search for and then delete the persisted objects, which have been created during the tests. But this clean up did not work. Debugging the TearDown microflow revealed no errors. Then I had the idea to deactivate the option 'Rollback microflow tests after execution', and this helped, so the clean up finally worked. Is this an intended behaviour? For me, it makes little sense to roll back the clean up. My TearDown microflow simply consists of 'Retrive list' and subsequent 'Delete objects' activities. Thanks in advance for any ideas on this, Martin 
asked
1 answers
1

Hi Martin, this is actually intended behavior of the Unit Testing module in Mendix. When the “Rollback microflow tests after execution” option is enabled, all changes made in the test microflow, including the TearDown are rolled back at the end of the test. This ensures the database stays unchanged after each test.

 

So, even though your TearDown deletes objects, the rollback undoes those deletes, making it seem like they never happened.

 

Solution:

You already did the correct thing, disableRollback microflow tests after execution this allows TearDown to truly persist and clean up data.

 

Recommendation:

Use Rollback = ON during normal test runs (to keep the DB clean) and disable it only when testing persistent side effects or cleanup logic like in your case.

 

Thanks for this topic!

answered