Unit Test Mocking

0
I haven't found much information about mocking data when running some unit tests. Locally I understand that the unit test relies on database to run, but moving those unit testing for a CI/CD pipeline makes not ideal to use database calls.    Is there any way to mock database access or any other guidance in how to do that?  Thank you. 
asked
2 answers
0

I think it's just too much overhead in trying to achieve this. Make your unit tests simple and easy. Create manually as much mock data as you need. Use the Unit Testing module from Mendix. 

 

https://marketplace.mendix.com/link/component/390?_gl=1*ehiz2x*_gcl_au*MjAxODg2MDUyNi4xNzQ0MjgyOTQw

answered
0

The Mendix Unit Testing module executes its unit tests within a transaction that is always rolled back upon completion.

 

When I have tests that need data, I create new entities at the start of the unit test microflow. This allows the microflow being tested to find the data it needs. The new entities are automatically cleaned up once the test has completed. 

 

If there is common data you always need for testing, you can use the Setup and Teardown microflows to set this up for every test in a module.

 

You can find more information on the Unit Testing module in the documentation.

https://docs.mendix.com/appstore/modules/unit-testing/

 

I hope this helps. Good luck!

answered