0% found this document useful (0 votes)
194 views43 pages

Model Based Testing

testing

Uploaded by

sandeep yadav
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
194 views43 pages

Model Based Testing

testing

Uploaded by

sandeep yadav
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
  • Software Testing
  • Classification of Testing
  • Model Based Testing
  • Software In Loop (SIL)
  • Processor In Loop (PIL)
  • Hardware In Loop (HIL)
  • Testing Automation
  • Overview of Reactis

Model Based

Testing

Presenters
Ashish Mote
Amit Chigteri

© 2005 KPIT Cummins Infosystems Limited

We value our relationship


Prerequisites & Class Purpose

• For this session basic knowledge of Matlab-Simulink, Code


generation & S-function is required.

•To know about different types of testing used in software


industry, their objectives & when shall it performed??

• To learn different stages of testing & their use in model


based development(Simulink based development)

7-Mar-12 2 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
Agenda

• Testing, SDLC’s, Objectives of testing and testing artifacts

• Classification of Testing Strategies based on different factors

• Model Based Testing – MIL, Plant Modeling, SIL, PIL & HIL

• Testing Automation, automation for MBT

7-Mar-12 3 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
Software Testing

© 2005 KPIT Cummins Infosystems Limited

We value our relationship


What is testing?
• It is an activity aimed at evaluating an attribute or capability of a
program or system and determining that it meets its required results

• Software testing is an investigation conducted to provide


stakeholders with information about the quality of the product or
service under test.

• It is to be noted that testing can never completely identify all the


defects within software.

• When to perform testing?

7-Mar-12 5 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
Software Development Life Cycles
Waterfall model Modified Waterfall model

V model Agile Model

7-Mar-12 6 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
Testing Objective & Phases
• The objectives with which mostly testing is done software industries
are
1. Whether there are any bugs in implemented software.
2. Whether software/build is meeting requirement.
3. What is performance of system with this software.

• Traditionally testing was limited to debugging, but later when


separation was introduced, phases & goals in software testing
industry were classified as
• Until 1956 - Debugging oriented
• 1957–1978 - Demonstration oriented
• 1979–1982 - Destruction oriented
• 1983–1987 - Evaluation oriented
• 1988–2000 - Prevention oriented

7-Mar-12 7 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
Testing Artifacts
1. Test Plan :- A test specification is called a test plan.

2. Traceability Matrix :- A traceability matrix is a table that


correlates requirements or design documents to test documents.

3. Test Vector :- It is a systematic collection in form of array/matrix


of values for a particular input or output for model under test.

4. Test Case & Test Suite :- Test plan is overall brief plan of
complete testing. A test case more detailed version for a small
part of test plan for a specific requirement. Collection of test
cases is known as Test suite.

5. Test Data :- All the values of test inputs, expected outputs, actual
outputs along with test environment related data are collected
together in file. This data is called Test data.

7-Mar-12 8 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
Classification of testing

© 2005 KPIT Cummins Infosystems Limited

We value our relationship


Classification of testing

• Based on Scope
• Functional Testing
• Non-functional Testing(Performance, Scalability, Usability, Security
etc)

• Based on Method
• Static
• Dynamic

• Based On Knowledge tester has


• White Box Testing
• Black Box Testing
• Grey Box Testing

7-Mar-12 10 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
Classification of testing

• Based on Level of testing


• Unit Testing/ Component Testing
• Integration Testing
• System Testing
• System Integration Testing

• Based on way test is executed


• Manual Testing
• Automated Testing

•Based on who is tester


• Alpha Testing
• Beta Testing

7-Mar-12 11 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
Model Based Testing

© 2005 KPIT Cummins Infosystems Limited

We value our relationship


Model Based Testing

•The term ‘model-based testing’ is widely used today with


slightly different meanings. In the automotive industry it is
normally used to describe all testing activities in the context of
model-based development projects.

•One major benefit of model-based development is the


possibility to “do things as early as possible”. In terms of
testing this means to test the functionality in the model before
the software is implemented and integrated into the final ECU.

• Other advantages also include possibility of automation by use


of scripts, automatic test case generation, Specific
coding/modelling guideline checks using Model Advisor
7-Mar-12 13 Version 1.0
Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
Levels of Model based Testing

• Between the initial modelling and the integration into the


ECU there are intermediate integration levels of testing.

• These integration levels are


• Model-In-Loop i.e. MIL Testing
• Software-In-Loop i.e. SIL Testing
• Processer-In-Loop i.e. PIL Testing
• Hardware-In-Loop i.e. HIL Testing

7-Mar-12 14 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
Model In Loop(MIL)

7-Mar-12 15 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
MIL
• The first integration level is based on the model of the
system itself.
• Testing an embedded system on MIL level means that the
model and its environment are simulated (interpreted) in the
modelling framework without any physical hardware
components.
• Generally Objective of MIL level testing are
• Functionality/requirements testing
• Overflows/ Underflows detection
• Division by 0 and few other arithmetic errors

7-Mar-12 16 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
MIL Continued
• Model in Loop testing helps in finding bugs in implementation
in very early stage of software life cycle.
• For MIL/SIL in Matlab/Simulink Environment there are 2 ways
of testing
1. By using test vectors
2. By using Plant model(s)

MIL Using Test Vectors MIL Using Plant Modeling

7-Mar-12 17 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
MIL Continued
• For MIL/SIL testing wrapper model shall be created first from
design model.
• A design model is model which has all data defined & from
which code generated.
• Wrapper model is also knows as test model, Simulation model
or Feature/Component Simulation Model
• Design model is also known Code-gen Model, Controller Model
or Actual Model in very crude manner

7-Mar-12 18 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
Testing using test vectors
• Test vector is systematic collection in form of array/matrix of
values for a particular input or output for model under test.
• Collection of such vectors together which can test 1 or more
requirement or even a complete single feature is known as Test case.
• Collection of all test cases together that can completely test model
under test in a data file(.mat file in Matlab/Simulink) is knows as Test
Data for model based testing.

• These vectors can be handwritten by tester or can be automatically


generated using Matlab based testing tools
• Sometimes these test vectors can also come from actual vehicle test
data.
• These test vectors shall be created in such way that they are re-
usable for SIL as well PIL & HIL.

7-Mar-12 19 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
Testing Using Plant Model
• Plant Model is model made for simulating physical systems or
physical components

• Plant modelling shall be able to simulate physical


components that have sufficient fidelity to test the
various execution paths within the software.

• Testing becomes more effective when plant models with


right fidelity are used instead of simple test vectors.

• Plant models can be made to replicate behavior any


physical components such as sensors, actuators using
Simulink & Simscape which is also a tool by Mathworks

7-Mar-12 20 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
Plant Model Example
• Suppose a Proportional controller for “controlling heater for
maintaining room temperature within given range” is designed
using Simulink.
• This controller is suppose provide Duty cycle input to heater
relay or percentage duty cycle to device driver of the heater

• To test this controller a plant model of room can be made as


in snapshots on next slides which can test how efficient is it’s
proportional control.

7-Mar-12 21 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
Snapshot of top level of test model

7-Mar-12 22 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
Inside Plant Model

7-Mar-12 23 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
Software In Loop(SIL)

7-Mar-12 24 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
SIL
•Testing an embedded system on SIL level means that the
embedded software i.e. generated code is tested within
a simulated environment model but without any
hardware.
• Since the environments virtual, a real-time environment
is not necessary.

SIL Using Plant Modeling SIL Using Test Vectors


7-Mar-12 25 Version 1.0
Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
SIL Continued
• For SIL testing few objectives can be same as MIL, but
majorly following are objectives of SIL testing
• MIL v/s SIL behavior comparison to find differences if any
• Dead (or unreachable)Code finding
• Code Coverage testing to see how much part of code is really being
tested in test case you have designed.
• Out-of-bound array access
•If some legacy code has been mixed with Simulink-RTW
generated or Simulink-Targetlink code generation then Other
code errors that can show up, especially in a mix with hand-
generated code, include:
• Illegally de-referenced pointers
• Read-only access to non-initialized data
• Dangerous type conversions

• Usually SIL are performed on Windows/Linux based desktop.


7-Mar-12 26 Version 1.0
Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
SIL Continued

• For SIL testing in Matlab/Simulink Environment following


Steps shall be performed
• Define all data’s(Variables) correctly if not done at MIL stage
• From code generation model generate the code
• From this code make a separate S-function or for subsystem you
want to test directly make a S-function.
• In model used for MIL testing replace model with S-Function.
• Input/Import the test data to workspace & Run the model.
• Plot and analyze outputs. Compare with previously saved MIL
testing results if in scope of testing.

7-Mar-12 27 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
Processor In Loop(PIL)

7-Mar-12 28 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
PIL

7 March 2012 29 29 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
PIL Conti
•Embedded controllers are integrated in embedded devices with proprietary hardware (ECU).
•Testing on PiL level is similar to SiL tests, but the embedded software runs on a target board
with the target processor or on a target processor emulator.
•Tests on PiL level are important because they can reveal faults that are caused by the target
compiler or by the processor architecture.
•It is the last integration level which allows debugging during tests in a cheap and
manageable way.
•Therefore the effort spent by PiL testing is worthwhile in almost all cases.

7 March 2012 30 30 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
Hardware In Loop(HIL)

7-Mar-12 31 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
HIL
• When testing the embedded system on HIL level the
software runs on the final ECU.
• However the environment around the ECU is still a
simulated one. ECU and environment interact via the
digital and analog electrical connectors of the ECU.
•The objective of testing on HIL level is to reveal faults in
the low-level services of the ECU and in the I/O services.

7-Mar-12 32 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
Kind of bugs that can be found at each level

7 March 2012 33 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
Correct time in V model for each type of these testings

7 March 2012 34 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
Testing Automation

© 2005 KPIT Cummins Infosystems Limited

We value our relationship


Test Automation

• Test automation is the use of software to automate testing procedures.

•Test Automation can be used


• To setup test environment
• To control the execution of tests
• To compare actual outcomes to predicted outcomes
• To set up of test preconditions
• To setup other test control and test reporting functions

• Test Automation objectives are


• To reduce efforts and save time in repetitive type manual testing
• To reduce human errors that can get introduced in manual testing
• To find certain classes of defects which cannot be effectively found out or can
be missed by manual testing

7-Mar-12 36 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
Test Automation Approaches

• There are 2 general approaches to test automation are

1. Code driven testing


2. GUI driven testing

• Code driven testing(Scripting Based) :- The interfaces(ways of


inputting) to components, modules or libraries are tested with a
variety of input arguments to validate that the results that are
returned are correct.
• GUI driven testing :- A testing framework generates user interface
events such as keystrokes and mouse clicks, and observes the
changes that result in the user interface, to validate that the
observable behavior of the program is correct

7-Mar-12 37 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
Test Automation in Model Based Development/Testing

• What Can be automated?


1. Wrapper Model Creation
2. Test vector creation
3. Test result display, comparison and recording
4. Test result report creation
5. Run time bug finding and reporting
6. Coverage tracking

• Reactis is one stand alone application that reads .mdl files


created in Matlab-Simulink/Stateflow environment

7-Mar-12 38 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
Overview of Reactis

• A model-based design environment involving Reactis, Simulink and


Stateflow is depicted in Figure below

• Reactis contains three core components:


1. Tester:- Provides automated test generation from models.
2. Simulator:- Enables users to visualize model execution to debug
models and track coverage.
3. Validator:- Offers automated checks of Simulink models for
violations of user-specified requirements.
7-Mar-12 39 Version 1.0
Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
Overview of Reactis Conti…

• The generated test suites provide comprehensive coverage of


different test coverage metrics - including the Modified
Condition/Decision Coverage (MC/DC) test coverage measure
• The automated test data later can be used for different purposes
like
1. Implementation conformance
2. Model testing and debugging
3. Reverse engineering of models from source

7-Mar-12 40 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
Implementation conformance

7-Mar-12 41 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
Model testing and debugging

7-Mar-12 42 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote
Reverse engineering of models from source

7-Mar-12 43 Version 1.0


Complied By: Amit Chigteri, Ashish Mote Presenter: Amit Chigteri, Ashish Mote

Common questions

Powered by AI

Model-In-Loop (MIL) testing involves simulating an embedded system within the modeling framework without any physical hardware components, primarily focusing on functionality and requirements testing . In contrast, Software-In-Loop (SIL) testing evaluates the embedded software using a simulated environment model, testing the software itself but still without actual hardware, focusing on code behavior and coverage .

The key objectives of software testing mentioned in the document are to determine whether there are any bugs in the implemented software, to check if the software or build meets the requirements, and to evaluate the performance of the system with the software .

In the context of software testing, a test case is a detailed version of a test plan segment targeting specific requirements. It specifies the inputs, execution conditions, and expected results for a particular test scenario. A test suite, on the other hand, is a collection of test cases that collectively aim to test various aspects of a software program or system, ensuring comprehensive coverage of the test objectives .

The primary forms of testing based on the tester's knowledge of the system are White Box Testing, Black Box Testing, and Grey Box Testing. White Box Testing requires knowledge of the internal structure of the software, Black Box Testing involves testing the software without any knowledge of its internal workings, and Grey Box Testing is a combination of both, where the tester has partial knowledge of the internal structure .

Model-based testing (MBT) contributes to early detection of implementation bugs by allowing testing of the functionality in the model before the software is implemented and integrated into the final product. This early detection is possible because MBT enables testing at various stages such as Model-In-Loop (MIL), Software-In-Loop (SIL), and others, which can simulate and test the embedded systems even before physical hardware is available, thus identifying issues early in the development cycle .

Hardware-In-Loop (HIL) testing involves running the embedded software on the actual final ECU, but with simulated external environments interacting with the ECU through its electrical interfaces. Its goal is to reveal faults in low-level and I/O services. Processor-In-Loop (PIL) testing, meanwhile, involves running the software on a target board or emulator with the target processor but without actual hardware, mainly to detect faults introduced by the compiler or processor architecture .

Plant modeling is significant in Model-Based Testing (MBT) because it allows the creation of simulated physical systems or components, which can better replicate the behavior of actual physical entities. This enhances the testing process by enabling more realistic simulation of interactions, thereby making testing more effective compared to simple test vectors. Plant models offer the required fidelity to test various execution paths within the software, ensuring the software interfaces correctly with the hardware it will control .

A traceability matrix is a document that correlates requirements and design documents to test documents. It plays a crucial role in ensuring that all requirements are covered by test cases, facilitating impact analysis when requirements change, and providing a clear mapping for tracking project status and coverage. The matrix ensures that the testing process is comprehensive and aligned with the initial specifications, reducing the risk of missing critical requirements .

Test automation in Model-Based Development/Testing is aimed at reducing the time and effort involved in repetitive manual testing and minimizing human errors. It involves the automation of procedures such as wrapper model creation, test vector creation, results comparison, and reporting, as well as runtime bug identification and coverage tracking. This approach enhances efficiency by automating the testing of interfaces to components and modules, as well as enabling GUI-driven testing for validating observable behaviors. Overall, automation aids in achieving more accurate and faster testing processes .

The V-model of software development emphasizes parallel development and testing activities, where each development phase has a corresponding test phase. This structure ensures consistent validation and verification of every stage, from requirements analysis to system testing, facilitating early defect detection. In model-based testing contexts, this approach allows for structured testing at each integration level, aligning closely with different levels like MIL and SIL, thereby ensuring rigorous testing and quality of the end product .

Model Based 
Testing
Presenters
© 2005 KPIT Cummins Infosystems Limited
We value our relationship
Presenters
Ashish Mote
Amit
Prerequisites & Class Purpose
• For this session basic knowledge of Matlab-Simulink, Code 
generation & S-function is require
Agenda
• Testing, SDLC’s, Objectives of testing and testing artifacts
• Classification of Testing Strategies based on differe
Software Testing
© 2005 KPIT Cummins Infosystems Limited
We value our relationship
What is testing?
• It is an activity aimed at evaluating an attribute or capability of a 
program or system and determining t
Software Development Life Cycles
Modified Waterfall model
Waterfall model
V model
Agile Model
6
Version  1.0
Complied By: Ami
Testing Objective & Phases
• The objectives with which mostly testing is done software industries 
are
1.
Whether there are a
Testing Artifacts
1. Test Plan :- A test specification is called a test plan.
2. Traceability Matrix :- A traceability matrix
Classification of testing
© 2005 KPIT Cummins Infosystems Limited
We value our relationship
Classification of testing
• Based on Scope
• Functional Testing 
• Non-functional Testing(Performance, Scalability, Usability

You might also like