Before moving forward to Model Based testing, let first understand what a model is -
What is 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 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
Model based testing is a testing technique where run time behavior of a software under test is checked against predictions made by a formal specification or model. In other means, it describes how 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 for both hardware and software testing.
The above model explains about simplified approach of writing poem in notepad and possible actions related to each step. For each and every action (like starting, Entering poem, Saving), Test Case can be generated and output can be verified.
Model based testing is a new approach to software testing. The evolution of Software Testing is shown below -
Types of MBT:
There are two types of Model based testing.
- Offline / a priori: Generation of Test Suites before executing it. Test suite is nothing but collection of test cases.
- 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 one by one:
Finite State Machines
This model helps testers to assess the result depending on the input selected. There can be various combinations of the inputs which results in a corresponding state of the system.
The system will have specific state and current state which is governed by set of inputs given from the testers.
Consider the example-
There is a system which allows employees to log- into the application. Now, current state of the employee is ''Out'' and it became ''In'' once he signs- into the system. Under the ''in'' state, employee can view, print, scan documents in the system.
It is an extension of Finite state machine and can be used for complex and real time systems. State charts are used to describe various behaviors of the system. It has 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 defect management tool with the status as New. Once it is fixed by developers, it has to be changed to status Fixed. If defect is not fixed change status to Re-open. State chart should be designed in such a way that it should call for an event for each state.
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 of that can describe very complicated behavior of the system.
UML has notations such as:
- Business Process
- Programming language
Challenges of Model Based Testing:
Deployment of MBT in every organization obviously requires high amount of investments and effort. Following are drawbacks of MBT:
- Necessary Skills required in testers
- Learning curve time will be more
- Difficult to understand the model itself
Benefits of Model Testing:
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
Testers construct mental models anyway during their testing. Those mental models can be transformed to models on paper. This helps testers to achieve readability and re-usability.