- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Model-Based Testing Tutorial
Application testing is a critical activity for any apps. Various approaches for testing apps have been developed over the last decade to ensure that we are providing high-quality applications that meet all of the customer's needs.
Model-based testing (MBT) is a hot issue in the world of test automation that involves creating test cases from models of the applications being tested
Various approaches based on model-based testing are now available. We'll show you two approaches for model-based testing that use genetic algorithms. The use of genetic algorithms for model-based testing is a hot issue, and there are several papers and comparisons of existing techniques.
What is Model-Based Testing, and how does it work?
Model-based testing is a software testing approach in which the run-time behavior of the product under test is compared to model predictions. A model is a representation of how a system behaves. Input sequences, actions, conditions, output, and data flow from input to output can all be used to define behavior. It should be comprehensible and reusable; shareable must provide a detailed description of the system under test.
There are a variety of models available that describe various elements of system behavior.
The following are some examples of the model −
State transition machines
Model-Based Testing explains how a system responds to an activity (determined by a model). Provide the action and watch to see if the system replies as expected.
It is a simple formal approach for validating a system. This testing may be used for both hardware and software.
The basic MBT procedure consists of five key steps −
Modeling is the process of describing the system's needs. The test generator will be based on this description.
The predicted output of the tested system must also be included in the model. The Design Model and the Test Model are quite essential at this stage.
Some key criteria should be taken into account while choosing a model: In most situations, the model is converted into a state transition system or a finite state machine system. The finite state machine system is a representation of the system's potential configurations.
The system is searched for executable paths in order to find test cases. A plausible execution route will be used to generate the test case. If the model is deterministic or can be converted into a deterministic model, this approach can be utilized.
Test planning includes defining test selection criteria and metrics. This provides for the formal formulation of test case specifications, as well as directing the mapping of feasible test suites, among other things.
Test Design refers to the formalization of test cases using the preceding test selection criteria.
This entails creating as many tests as feasible.
Algorithms for searching
The format of tests is predetermined.
Algorithms for walking or light-seeking
Following the execution of the previous step and receipt of the output value, the next step is determined.
Algorithms must be quick.
Run the tests and look for discrepancies between the current and expected output.
Selection, reproduction, and mutation are all ideas used in evolutionary algorithms.
We'll go through three different sorts of evolutionary algorithms here −
Algorithms Based on Genetic Information (GA)
Evolutionary computation includes genetic algorithms. Artificial intelligence includes evolutionary computation.
Genetic algorithms are based on Darwin's theory of evolution. The answer to a problem solved by genetic algorithms can also be said to have evolved.
We use four key concepts from natural selection in our genetic algorithms: gene, chromosome (individual), population, and natural selection.
The natural selection consists of the following steps −
The population's fittest people will be chosen.
Individuals will have children who will inherit the qualities of their parents.
The offspring will be included in the upcoming generation.
Offspring of fitter parents will outperform their parents and have a higher chance of survival.
This is an iterative process that will result in a generation of the fittest individuals.
The easiest approach to describe Genetic algorithms is to imagine that we have a problem to solve and that we may examine a collection of solutions to that problem. We will have to use evolution theory and natural selection to discover the optimum answer to the situation.
The following terms are used in Genetic Algorithms −
Initial population − The problem begins with a collection of potential solutions (individuals) for the situation at hand. The population is made up of a certain number of people. Each person is a potential solution to the problem we're trying to address. A collection of parameters shapes an individual (variables). These characteristics are referred to as genes. A Chromosome (solution/individual) is formed by the joining of genes into a string. Binary values (a string of 1s and 0s) are commonly employed to encode genes in chromosomes.
Fitness function − Determines an individual's capacity to compete with other persons. Based on the fitness function, we will compute a fitness score for each person (chromosome/solution). The fitness score determines the likelihood that an individual will be picked for reproduction.
Selection − The fittest people will be chosen and their genes will be passed down to the next generation. How does it function? Based on their fitness scores, the algorithm will choose two pairs of individuals (parents). Individuals with high levels of fitness will be chosen for reproduction. There are many selection algorithms.
Crossover (Recombination) − This is the most important stage of a genetic algorithm. The crossover comes in a variety of forms. In general, a crossover point is chosen at random from within the genes for each pair of parents to be mated in order to produce new children and insert them into the population. As a result, the two parents will have two children.
Mutation − This is a genetic operator that is applied with a low random frequency to a portion of the new offspring produced. This means that the amount of bits in the bit string is frequently swapped.
Termination − If the population does not generate children that are considerably different from the previous generation, the algorithm will end. We can now state that the genetic algorithm has generated a set of solutions to our problem.
Model-Based Testing and Genetic Algorithm
Understanding how genetic algorithms may be applied to model-based testing is the most essential portion of this article. Let's look at two model-based testing uses of genetic algorithms.
We are now using all of the terminologies from genetic algorithms and demonstrating how they are utilized in various model-based testing applications of GA.
Using GA To Create Test Data From A UML State Diagram Model based testing may generate test cases and executable test scripts from a UML (Unified Modelling Language) model representation of the tested application. Using the Unified Modelling Language (UML) state chart diagram, genetic algorithms may be utilized to produce test data.
Keep the following terms in mind while using the UML state chart diagram −
State diagrams (state chart diagrams) are used to represent any complicated feature or to describe the dynamic behavior of a complete system, a subsystem, or even a single item inside a system.
Before coding, model-based testing is used to extract test cases from a UML state chart diagram. As a result, we can create a test suit for any program specification. Specifications are frequently presented in the form of UML diagrams or formal language specifications.
A trigger, similar to an event, starts a transition from one state to another.
A guard condition is a Boolean condition that must be met before a transition may take place.
The action (activity) that occurs when a transition occurs is referred to as an impact.
As previously stated, in order to use a genetic algorithm, we must first establish the original population of people (chromosome). This initial population will be a collection of solutions to our challenge.
Model-Based Testing Challenges −
Deploying MBT in any company obviously necessitates a significant amount of money and work.
The learning curve will be longer and the model will be more difficult to comprehend.
Benefits of Model Testing −
MBT has the following advantages −
Simple test case/suite upkeep
Cost savings improved test coverage
Can perform various tests on an n number of computers
Defect identification at an early stage
Increase in the number of defects
Savings in time
increased work satisfaction among testers
During testing, testers create mental models anyhow. These mental models can be translated to paper models. This aids readability and reusability for testers.
Model-based testing is a relatively recent method of software testing. The following diagram depicts the evolution of software testing −
- What is Cloud Testing? SaaS Testing Tutorial
- Mainframe Testing Tutorial for Beginners
- API Testing Tutorial for Beginners
- Penetration Testing Tutorial: What is PenTest?
- Load Testing Tutorial (Definition, how to, Example)
- Performance Testing Tutorial (Definition, Types, Metrics, Example)
- Backend Testing Tutorial (What is, Tools, Examples)
- Protocol Testing Tutorial – L2 & L3
- What is SOA Testing? Tutorial with Example
- Storage Testing Tutorial (What is, Type, Concepts)
- End-to-End Testing Tutorial: What is E2E Testing with Example
- Salesforce Testing Tutorial (What, Process, Tools, Best Practices)
- Penetration Testing Tutorial – What is Pen Test?
- Reliability Testing Tutorial (What is, Methods, Tools, Example)
- REST API Testing Tutorial - Sample Manual Test Case