How to do Asserts in Unit Testing Module and Find Coverage in mendix

0
HI Team,   i am trying to do unit testing in the mendix and i am using unitTesting module for it.  1.I am not able to use asserts, just like in java we can use multiple asserts statements. How i can do it in mendix? 2. how i can find the Coverage also for unit testing? 3. how i can write the test case for this scenario - i have a MF which saves the form data in DB after validate. How i can write UnitTest for this ?   I have already go through the UnitTesting module docs , but coluldnot get clearity . its very beneficial if someone explains in brief .   Thanks !  
asked
2 answers
0

Hi pratham,

 

Follow these steps to create /updata or validate your flow

1.Validate inputs (check if they meet your business logic)

2. Create/Update data in the database

3. Commit changes to the database

answered
0

Hi Pratham,

1. Have you see the Unit testing module Howto? That one briefly explains how to use the Assert and ReportStep actions from the Unit testing module in your unit testing microflow (see also the attached screenshot for the Assert & ReportStep actions you can use.

https://docs.mendix.com/refguide/testing-microflows-with-unit-testing-module/

 

2. The current version of the unit test module does not have a coverage report available.

3. Any microflow name starting with the prefix TEST_ or UT_ will be run as a unit test. So if you have a microflow called 'DoSomeCalculation', you could create a unit test microflow next to it called UT_DoSomeCalculation. This unit test microflow then could have some preparation activities to set up relevant data, and then call the 'DoSomeCalculation' microflow. The results from this call then can be used in the Assert activities to validate the outcomes against the expected outcome.

 

UnitTestModule.png

answered