NashTech Insights

Model based testing – An approach generating test cases from models automatically

Thuy Pham
Thuy Pham
Table of Contents

According to the Capgemini 2019 Continuous Testing Report, 40% of the participants indicated that their present method for requirements gathering and analysis lacks automation. Consequently, in the majority of instances, testing is not integrated into the initial phase of defining the requirements. During this stage, a considerable amount of time and effort, approximately 40-70% as reported by respondents, is devoted to clarifying specifications.

In an Agile and DevOps environment, where requirements undergo frequent changes, ensuring adequate requirements coverage during high-speed testing becomes crucial. This represents a challenging area for most organizations, as evidenced by the survey results below.

What is Model Based Testing (MBT)?

Model-Based Testing (MBT) is an advanced test approach using models for testing. It provides for the automatic generation of test artifacts including test cases and test automation scripts, as well as the flexibility to adapt to changing requirements using automated requirements change processes.

MBT can be employed alongside well-known testing tools and automation frameworks, aiding the team in crafting both manual and automated scripts, thereby enhancing test coverage.

MBT helps requirements engineering in the following ways:

  • Enhance requirement and user story clarity and quality by sharing complete or partial MBT models with business representatives and developers. This process produces a common understanding of expected software behavior.
  • Facilitate communication among Business Analysts, Developers, and Testers by offering graphical MBT depicting the anticipated software behavior for the upcoming development.
  • Support early validation of requirements, even during stages where they are still subject to change.

But how does MBT work?

Model Based Testing Steps

MBT refers to the processes and techniques for the automatic beginning of abstract test cases from abstract formal models, the generation of existing tests from abstract tests, and the manual or automated execution of the resulting existing test cases. Therefore, the key points of MBT are the modelling principles for test generation, the test generation strategies and techniques, and the concretization of conceptual tests into existing, executable tests.

Model Based Testing Workflow

The diagram below illustrates activities related to MBT in connection with the ISTQB test process.

Next section, I will demonstrate the incorporation of MBT into the software life cycle. Which specific test levels and testing types will be employed for MBT.

Integrating MBT Into the Software Life Cycle
Model Based Testing Model

Within this segment, we will explore the various types of models and their respective test objectives.

Language for MBT Models

Modeling Languages for MBT:

  • Modeling concepts
  • Formalism
  • Presentation formats

Categories of Modeling Languages:

  • Languages for structural models: Languages support the specification of structural elements of software such as interfaces, components, and hierarchies. Example: UML component diagram.
  • Languages for data models: Languages support the specification of the data types and values. Example: The UML class diagrams and value specifications.
  • Languages for behavioral models: Languages support the specification of events, actions, reactions and/or interactions of software. Example: UML activity or interaction diagrams, state machines or Business Process Modeling Notation (BPMN).
  • Integrated languages: Modeling language is not limited to one of the aspects, but rather provides concepts for a number of aspects. Example: UML itself, in which the different diagrams can be used in combination to denote the different aspects of software.
Model Based Testing Tools

Here are some of the top tools for MBT categorized into open-source and commercial options:

Open-source Tools:

1. GraphWalker: Provide an editor called Studio, primarily used for creating and editing models. However, Studio’s capabilities extend beyond mere editing. Within the tool, we can execute test path generations to verify the accuracy of the models. This feature enables users to validate the correctness of the models by running test paths.

2. fMBT: A set of tools for fully automatic test generation and execution and a collection of utilities and libraries that support the high level of test automation. This includes Python libraries for multiplatform GUI testing, a tool for editing, debugging, running and recording GUI test scripts, and a tool for editing and visually analyzing test models and generated tests.

Commercial Tools:

1. Tricentis Tosca: A complex automation framework that can generate test data using various criteria such as risks and pairwise combinations. It’s capable of automatically extracting the structure of test data objects from the implementation.

2. MBTsuite: MBTsuite generates test cases from UML models using diverse coverage criteria (like path or edge coverage) or randomness. It seamlessly imports models from multiple editors and is integrated with various test management and execution tools.

Given that MBT is often not as widespread as traditional testing methods, the assessment and implementation of tools must be both robust and not underestimated. A pivotal facet of this evaluation pertains to seamlessly integrating the MBT tool with configuration management, requirements management, test management, and test automation tools.

A typical test tool chain embedding MBT is depicted in the diagram below.

Benefits of Model Based Testing
  • Optimize the testing time and costs significantly.
  • Help generate test cases automatically from models.
  • Minimal number of test cases to validate functionality and flow ensuring full coverage.
  • Enable test coverage improvement.
  • Requirements Evolution. With manual test design, if requirements change, a large amount of effort is often required to update the test suite to reflect the new requirements. With MBT it suffices to update the model and then re -generate the tests.
Challenges of Model Based Testing
  • Require a team of skilled testers. Tester needs to be well-known with the model, which means knowledge of dissimilar forms of state machines, formal languages, and automata theory.
  • The model is quite complex and sometimes it becomes difficult to understand.
  • It is usually used only for Functional Testing.
Conclusion

According to Capgemini, the forthcoming years will witness MBT and behavior-driven development emerging as prominent testing trends. These trends will foster enhanced collaboration between business analyst teams, development, and QA departments, thereby enhancing responsiveness to evolving requirements and facilitating seamless continuous delivery.

With the incorporation of AI testing and Machine Learning, MBT will bring tremendous time and money savings to businesses by enabling extensive test automation. Ultimately, MBT represents a logical progression in the realm of test automation.

Reference
Thuy Pham

Thuy Pham

With 19 years of experience in software testing, I hold the position of a Senior Test Team Manager. Throughout my career, I have adeptly managed testing projects across diverse domains, consistently achieving successful outcomes. My expertise extends to ETL Testing and SAP Testing, where I have gained valuable hands-on experience. Furthermore, I have honed my skills in mentoring and training junior testers through various programs, including Fresher programs and Direct Entry programs.

Leave a Comment

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

Suggested Article

%d bloggers like this: