Skip to content

How to create a model

Kristian Karl edited this page Nov 2, 2020 · 15 revisions

Test design [modelling] and test idea

The purpose of the test design in MBT is to describe the expected behavior of the system under test. The result of the design looks like a model with a number of edges (aka arrows, arcs or transitions) and vertices (aka nodes or states) and how they interact with each other.
A model is reminiscent of the popular concept in testing of a state transition diagram, or a finite state diagram. An edge expresses an action with the SUT (system under test) and a vertex expresses a state of the SUT that should be tested.

Test idea

For a short example, our test idea is to write a regression test for the Spotify Desktop Client, more specifically the login feature. (Spotify is a music streaming business)

The feature is supposed to work like this:

  • In a freshly installed client when the client is running, the Login dialog is expected to be displayed.
  • The user can enter valid credentials and is logged in.
  • If the user quits or logs out, the Login dialog is displayed once again.
  • If the user checks the Remember Me checkbox and logs in (using valid credentials), the client runs, and the next time the user runs the client, it will not ask the user for credentials.

Designing a test for the first 2 steps, a model could look something like this:

Happy path

  1. The starting point is the green colored element e_Init, we remove all cache, and kill any previous client processes. Since the test might be restarted, stored credentials on disk might still exist, so we need to get rid of it. Also, restarted tests could have stopped in a state where the client is still running.

  2. v_ClientNotRunning will assert that there is no Spotify client process running.

  3. e_StartClient starts the client.

  4. v_LoginPrompted asserts that the login dialog is displayed and correctly rendered.

  5. e_ValidPremiumCredentials enters a valid username and password and clicks the Sign In button.

  6. v_ClientStarted asserts that the Browse view is correctly displayed.

The above is a simple test. In fact, it is just one possible path through the model. It could be called the basic flow in a use case. To make the test a better regression test, we extend the model.

  • Logout
  • Exit the client
  • Testing invalid credentials
  • Enabling and disabling stored credentials (Remember Me)
  • Closing/cancelling the login dialog

The complete model could look something like this:

Extended model

Verifying the correctness of the model

To verifying the model press the play button, and see if the traversing of th model is as expected. The model file can be downloaded from here.

Verifying extended model

Clone this wiki locally