the world of model driven development

Test Driven Modelling

If you come from a hard core development background one of the stranger concepts to experience is enterprise development (through modeling) with no unit test coverage strategy. I am not an advocate for smashing a unit test approach into a model driven development strategy but I do think that there are instances, when modeling more complex logic, where a test driven approach is both practical and needed. Additionally this approach works well when many modellers are working on common and re-used microflows where changes to a single microflow could effect a large portion of the application being developed.

To illustrate this point I have created a simple test module to house my test Microflows for some complex logic. The module contains a screen which outputs the testcase results.

There are 2 types of microflows being discussed below, the “test” microflows which handles the executable logic for the test itself. The “targeted” microflow which is the microflow containing business logic which is being tested.

The basics of creating a test driven approach can be summed up in 3 steps:

1. Create a Construct Microflow

This Microflow essentially removes all previous data out the database and populates the database with the entities needed to execute target microflows under certain conditions. Assert microflows will then ensure that the logic executed within the target microflow executes correctly given the controlled data set created in this step.

Microflow to construct test data

2. Test Microflow

A single test microflow called “test all” is created where other “assert” microflows are called from. Each “assert” microflow calls their respective targeted microflows. After calling the targeted microflow containing logic being tested the assert microflow then either retrieves the relevant entities that have changed from the microflow being tested or retrieves the returned object/variable the microflow being tested returns.

Given the controlled data created in step 1 the assert microflow then determines if the logic has executed correctly or not. The assert microflow then returns a true or false to the test microflow which then logs the result in a string variable called “result”.

Test All Microflow Calls Assert Microflows

3. Output to Screen

Lastly the result string is exported to the screen via the Microflow Label widget which executes our original “test all” microflow starting the testing process. Modellers can see the results on the screen using this method, instead of automation testing or navigating through the application, to execute complex logic in order to determine if all the logic scenarios are correctly covered.

Results to the Testing

In the example above I can see that my PO Changes and Order Place logic has failed and therefore needs attention. In a team environment I would expect modellers to execute these tests before merging code back into source in order to ensure that the source code is always accurate.

Comments on: "Test Driven Modelling" (4)

  1. […] Test Driven Modelling (mendixandbeyond.com) […]

  2. Derek Gardiner's avatar

    How to Start a Successful Online Testing Program is interesting however I don’t think fully applicable to the post at hand. This post is about a unit test type approach to modelling however I think your post seems to be more about a testing strategy for a testing resource. Still valuable information though – thank you for your contribution.

    • Kevin Dwinnell's avatar

      Derek: Upon second reading, it looks like you’re correct (looks like I’m failing my speed reading attempts). My thought was to complete the continuum of adopting, applying and evolving tests within businesses – and give an option for further reading.

      I still like the term “microflows.” It implies focus on single and small objects – a great way to get actionable information and early wins for testing. It’s so easy to get overwhelmed when you look at what all can and should be tested.

      • Derek Gardiner's avatar

        Thanks for your input Kevin – to be honest: linking a test approach you’re talking about with a model approach is a topic that really needs to be investigated in great detail. Testing is really the bedrock of agile development in any form since it provides stability upon which re-factoring can efficiently take place. With out the testing stability you’re talking about I think it would be very difficult to model high quality solutions at a rapid pace.

Leave a reply to Kevin Dwinnell Cancel reply

Design a site like this with WordPress.com
Get started