Output is Just Input with the Opposite Sign

It’s been a while since I last posted about my model-based testing tool, the MBT Workbench.  That is mostly because last time, we finished something really cool (a fully working chain resulting in web-services getting called), and the big bunch of very samey user-interface coding I had to do get further was a lot less interesting in comparison, so I’ve procrastinated a bit the past couple of weeks.

At last, I have something to report, though.  Now I can set up output mappings, and even use feedback from live services as input for assisting users in this task.  We’ll use my original example of an insurance company doling out insurances to everybody but sub-25 years old males.

We load in our web-service description, and set up out input mapping to discriminate based on gender and the age 25:

We connect the mapping to out test, and click the Procure output mapping:

Last time, this would just have invoked the service in the background, only logging a bit of diagnostics to the console.  It still does that, but now it also analyses the output, and uses that as input for setting up an output mapping:

We note that this screen is very similar to the screen used to set up input mappings. That’s on purpose and because the tasks are very similar.  The screen is a bit simpler, and instead of allowing both selecting both an operation and a mapping, we only select a mapping.  The mappings are similar to those for input mappings, but instead of trying to generate real data from simple values, they are geared towards producing simpler values based on real values.

In this example, the tool has picked the “Indicator” mapping.  This is done because it looked at the possible return values, and noticed that these particular elements were either present or not, and when present their value never differed.  The Indicator mapping just returns a boolean indicating whether the element is present or not.

There is currently 4 available mappings:

The Custom mapping allows users to write their own mappings using Groovy, the Identity mapping preserves the value, and the Ignore mapping just ignores the value.  The Indicator mapping we already talked about.

If we are happy with the proposed mapping, we can click on the Generate output mapping button, and we get a mapping customizer very similar to the one for input mappings:

The major difference is that we no longer get variables as input and produce XPath expressions, but instead to it the other way around.  For that reason, the mapping process is split into two parts: value extraction and value mapping.

At the top we see the extraction patterns: it is just XPath expressions for extracting values and names for the extracted values.  At the bottom we see the actual variables.  Here they correspond one-to-one with the extracted values, but it is possible to generate multiple output variables from a single extracted value or a single output variable for multiple extracted values.

Also here, the script has been generated by the tool but can be customized by the user.

And that pretty much concludes my current status.  Hopefully, I can now get to something more fun, actually performing the extraction, and then it is time for model generation.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.