Model-based Testing

To automate executing a model-based test case, you need to define an implementation for every step in the model. Every model has one accompanying script file with the same name. For example, the model file is called example.mbtmodel, and the script file is, example.js,, example.rb or example.tcl, according to the scripting language you have chosen.

Every time a step is encountered in a model file, Squish will try to find a pattern matching the step text in the script file.

Defining Step Implementations Using Step

A step implementation is defined by calling a pre-defined Step function. A simple definition would look like this:

@mbt.step("Start the address book")
def step():
mbt.step("Start the address book", function() {
mbt::step("Start the address book", sub {
Mbt::step("Start the address book") do
mbt step "Start the address book" {} {
    startApplication "Addressbook"

In this example, a step matching the "Start the address book" pattern will cause Squish to execute the following code.

startApplication addressbook

Step Text

The step text must match the pattern exactly. The match is anchored to the start and end. There should be no text before or after it.


Defining a step with Step function in model-based testing is limited compared to defining a step in behavior-driven testing. It is not possible to use placeholders or regular expressions in step patterns.

Running a test case

You can use the mbt.runTestCase function to execute a model-based test case, as shown in the following example. To use this function, you need to provide the name of the test case file as an argument.

mbt runTestCase "test.mbttest"

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners.
The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.
Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.