What is Model Based Testing?

What is Model Based Testing?

Model-based testing is a software testing technique where the run time behavior of the software under test is checked against predictions made by a model. A model is a description of a system’s behavior. Behavior can be described in terms of input sequences, actions, conditions, output, and flow of data from input to output. It should be practically understandable and can be reusable; shareable must have a precise description of the system under test.

There are numerous models available, and it describes different aspects of the system behavior. Examples of the model are:

  • Data Flow
  • Control Flow
  • Dependency Graphs
  • Decision Tables
  • State transition machines

Model-Based Testing describes how a system behaves in response to an action (determined by a model). Supply action, and see if the system responds as per the expectation.

It is a lightweight formal method to validate a system. This testing can be applied to both hardware and software testing.

Model Based Testing Example

Model Based Testing – Stuff You Must Know!

The above model explains the simplified approach of writing poetry in notepad and possible actions related to each step. For each and every action (like starting, Entering a poem, Saving), Test Case can be generated, and the output can be verified.

Types of MBT

There are two types of Model based testing frameworks-

  1. Offline / a priori: Generation of Test Suites before executing it. A test suite is nothing but a collection of test cases.
  2. Online / on-the-fly: Generation of Test Suites during test execution

Different Models in Testing

In order to understand the MBT, it is necessary to understand some of the models explained below. Let’s go through them one by one:

Finite State Machines

This model helps testers to assess the result depending on the input selected. Various combinations of the inputs can result in a corresponding state of the system.

The system will have a specific state and current state, which is governed by a set of inputs given by the testers.

Consider the example-

There is a system that allows employees to log- into the application. Now, the current state of the employee is ”Out,” and it became ”In” once he signs- into the system. Under the ”in” state, an employee can view, print, and scan documents in the system.

Model Based Testing – Stuff You Must Know!

State Charts

It is an extension of the Finite state machine and can be used for complex and real time systems. Statecharts are used to describe various behaviors of the system. It has a definite number of states. The behavior of the system is analyzed and represented in the form of events for each state.

For example –

Defects are raised in the defect management tool with the status as New. Once it is fixed by developers, it has to be changed to status Fixed. If a defect is not fixed, change status to Re-open. State charts should be designed in such a way that it should call for an event for each state.

Model Based Testing – Stuff You Must Know!

Unified Modeling Language (UML)

Unified Modeling Language (UML) is a standardized general-purpose modeling language. UML includes a set of graphic notation techniques to create visual models that can describe the very complicated behavior of the system.

UML has notations such as:

  • Activities
  • Actors
  • Business Process
  • Components
  • Programming language

Model Based Testing – Stuff You Must Know!

Challenges of Model Based Testing

Deployment of MBT in every organization obviously requires a high amount of investment and effort. Following are drawbacks of MBT in Software Engineering.

  • Necessary Skills required in testers
  • Learning curve time will be more
  • Difficult to understand the model itself

Advantages of Model Testing

The following are benefits of MBT:

  • Easy test case/suite maintenance
  • Reduction in Cost
  • Improved Test Coverage
  • Can run different tests on n number of machines
  • Early defect detection
  • Increase in defect count
  • Time savings
  • Improved tester job satisfaction

Conclusion

Testers construct mental models anyway during their testing. Those mental models can be transformed into models on paper. This helps testers to achieve readability and re-usability.

Model based testing is a new approach to software testing. The evolution of Software Testing is shown below –

Model Based Testing – Stuff You Must Know!