Unit testing examples?

0
Hi All, Prasad here. I ahve started with Mendix a few days back and came across unit testing. I try to understand how it works with the unit testing module, but I don’t think I understand the examples very well. Do you have some examples that you used, or what to consider when writing unit tests for some microflows?  I use some of the free template apps but I get stuck when trying to write tests for some microflows there. thank you
asked
1 answers
0

Add the unittesting module’s snippet UnitTestOverview to your application, and the modules that it depends upon

Then for each microflow you want to create a unittest for, create a microflow having the prefix ‘Test_’ or ‘UT_’.

Here is an example unittest for microflow CRS_AddressInformation. The unittest I gave it the name UT_CRS_AddressInformation_KnownAddress:

  • “Create NL, 1213AM, 15” will set up some testdata that become the input parameter for your microflow
  • Execute your UUT (Unit Under Test), which ic in this case CRS_AddressInformation
  • Check if the result is as you expect
    • if correct return boolean true
    • if false report the failure, so it shows up in your UnitTestOverview and return boolean false

“'Failed. Expected result was 4.25123424 but actual result was '+$AddressResponse_2/Latitude”

That should do it.

answered