CN114817001A - Automatic testing tool and automatic testing method for Simulink model - Google Patents
Automatic testing tool and automatic testing method for Simulink model Download PDFInfo
- Publication number
- CN114817001A CN114817001A CN202210335094.2A CN202210335094A CN114817001A CN 114817001 A CN114817001 A CN 114817001A CN 202210335094 A CN202210335094 A CN 202210335094A CN 114817001 A CN114817001 A CN 114817001A
- Authority
- CN
- China
- Prior art keywords
- test
- test case
- module
- tested
- judging whether
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000012360 testing method Methods 0.000 title claims abstract description 206
- 238000004088 simulation Methods 0.000 claims abstract description 22
- 238000004364 calculation method Methods 0.000 claims abstract description 4
- 238000000034 method Methods 0.000 claims description 10
- 230000007704 transition Effects 0.000 claims description 4
- 230000006870 function Effects 0.000 description 11
- 238000005516 engineering process Methods 0.000 description 5
- 238000013522 software testing Methods 0.000 description 4
- 238000004422 calculation algorithm Methods 0.000 description 3
- 238000011161 development Methods 0.000 description 3
- 238000012545 processing Methods 0.000 description 3
- 238000004458 analytical method Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 2
- 238000013461 design Methods 0.000 description 2
- 238000010586 diagram Methods 0.000 description 2
- 230000002452 interceptive effect Effects 0.000 description 2
- 239000011159 matrix material Substances 0.000 description 2
- 230000000007 visual effect Effects 0.000 description 2
- 238000003491 array Methods 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 238000007405 data analysis Methods 0.000 description 1
- 238000013079 data visualisation Methods 0.000 description 1
- 238000001514 detection method Methods 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 230000007613 environmental effect Effects 0.000 description 1
- 230000010354 integration Effects 0.000 description 1
- 239000004973 liquid crystal related substance Substances 0.000 description 1
- 238000012423 maintenance Methods 0.000 description 1
- 239000002184 metal Substances 0.000 description 1
- 230000003252 repetitive effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3684—Test management for test design, e.g. generating new test cases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3664—Environments for testing or debugging software
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3692—Test management for test results analysis
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
The invention relates to an automatic testing tool and an automatic testing method for a Simulink model, wherein the tool comprises the following components: the first setting module is used for setting the comparison precision of the simulation step length and the test result; the third selection module is used for selecting an MIL or SIL simulation mode; the fourth selection module is used for selecting and executing a single test case or a plurality of test cases; the calculation module is used for calculating the coverage degree of the test; the second setting module is used for setting comparison only on expected time point data or comparison on each simulation step length; the automatic test module is used for executing automatic test on the Simulink model to be tested based on the test case; the generating module is used for generating a test result based on the current test case; the tool can be used for a tester to quickly load a model to be tested and a test case so as to finish one-key automatic test, and the tool is provided with personalized configuration, so that a user can select the required configuration on a front-end interface according to the requirement of the user so as to perform personalized test, and the tool is wide in application range.
Description
Technical Field
The invention belongs to the technical field of software testing, and particularly relates to an automatic testing tool and an automatic testing method for a Simulink model.
Background
Due to the rapid development of the new energy automobile battery management technology and the increasing complexity of software, the requirements change frequently and the workload of software testing is increased in the software development and software iteration processes. In automobile electronics and related projects developed based on Simulink models, after software is modified along with the change of requirements, software unit models need to be tested, traditional unit testing needs testers to manually test one by one according to models and detailed software design documents, testing efficiency is low, time consumption is long, repetitive operation is multiple, meanwhile, manual and non-standard operation exists in the testing process, and accuracy and correctness of testing results cannot be guaranteed.
Chinese patent publication No. CN106201891A discloses a technology entitled "an automatic testing method and apparatus for model", which is characterized in that a method described in the technology automatically calls an Excel document to be tested by a user through a main function, then calls an external interface, reads Excel data to be tested, then analyzes whether form data meets a basic format requirement, exits from a testing process if not, calls an input interface function and an output interface function in sequence if meeting, tests the tested model in real time, finally judges the tested data after the model operation is completed, and writes a judgment result into the Excel testing document; the technology can complete the whole control only by starting the main function during running, but has no pause or emergency stop in midway, and is not beneficial to modifying software bugs through testing conditions in time.
Disclosure of Invention
The invention aims to provide an automatic testing tool and an automatic testing method for a Simulink model, and solves the technical problems that: the existing testing technology facing the Simulink model can not realize the testing of different requirements or has narrow application range.
In order to solve the technical problems, the technical scheme adopted by the invention is as follows: an automated Simulink model-oriented test tool, comprising:
the loading module is used for loading a Simulink model to be tested;
the first selection module is used for selecting an output observation submodule of the Simulink model to be detected;
the second selection module is used for selecting the test case and distributing time for storing the test process and the test result under the corresponding path;
the assignment module is used for assigning the Simulink model to be tested through the initialization file;
the first setting module is used for setting the comparison precision of the simulation step length and the test result;
the third selection module is used for selecting an MIL or SIL simulation mode;
the fourth selection module is used for selecting and executing a single test case or a plurality of test cases;
the calculation module is used for calculating the coverage degree of the test;
the second setting module is used for setting comparison only on expected time point data or comparison on each simulation step length;
the automatic test module is used for executing automatic test on the Simulink model to be tested based on the test case;
the generating module is used for generating a test result based on the current test case;
and the comparison module is used for performing plotting comparison on the failed signals when the test cases fail so as to analyze the state transition of the signal to be tested along with the time flow.
The invention also provides an automatic testing method based on the automatic testing tool facing the Simulink model, which comprises the following steps:
s01: reading a test case and loading a Simulink model to be tested;
s02: acquiring the input of a test case as the input of a Simulink model to be tested;
s03: running a Simulink model to be tested;
s04: obtaining a test result;
s05: and comparing the test result with the expected output, judging whether the test result is consistent with the expected output, if so, passing the test case, and if not, failing to pass the test case.
Preferably, the first and second electrodes are formed of a metal,
in S01, the step of reading the test case includes loading the test case and reading test case data, and the step of loading the test case includes:
a01: judging whether a test case Excel file exists or not;
a02: emptying the list of Test panel and loading an Excel table;
a03: removing the Chinese worksheet in the form, acquiring configuration items, judging whether an initialization file exists or not, and acquiring an initial value;
a04: neglecting the sheet which is not the test case, loading each test case in sequence and converting the test case into a mat format;
a05: importing test case data into a working area;
the steps of reading the test case data are as follows:
b01: reading test case keyword information;
b02: reading the time sequence, judging whether the time data exists and the format is correct, and ensuring that the time sequence is monotonically increased;
b03: acquiring output information, judging whether output data exists or not, judging whether a format is correct or not, and judging whether a maximum value and a minimum value exist or not;
b04: and displaying the test case sequence number and the input variable name in the list.
Preferably, the first and second liquid crystal display panels are,
in S03, the step of executing the test case includes:
c01: reading the selected test case;
c02: judging whether Simulink model input exists in the test case data or not;
c03: judging whether a data dictionary file exists or not;
c04: recording the original values of variables needing to be modified in the data dictionary;
c05: modifying the value of the data dictionary according to the value in the test case;
c06: judging whether all the expected signals in the test case exist in the selected observation submodule;
c07: recording signal values in the observation submodule;
c08: modifying the configuration of the test model according to the simulation step length;
c09: and operating the model to be tested to obtain simulation output.
By adopting the technical scheme, the invention has the following beneficial technical effects: the invention utilizes MATLAB scripting language to compile a set of software testing tool based on the previous overall requirements, the visual interactive interface of the tool covers the overall requirements of software testing, and testers can quickly load a model to be tested and a test case to complete one-key automatic testing. The tool is provided with personalized configuration, tests with different requirements can be realized by configuring selectable items, the invention can realize the functions of MIL test or SIL test, strip-by-strip test or all tests, setting the comparison precision of test results, calculating test coverage and the like, the tool can flexibly control the test progress, can interrupt the test at any time and debug the Simulink model to be tested, the test results can be directly drawn and observed through the front end interface of the tool, Excel analysis is not needed, the test convenience and the efficiency of repairing the software BUG are improved, the application range is wide, and the subsequent customization, upgrading and maintenance can be performed according to the personalized requirements.
Drawings
FIG. 1 is a flow chart of the tool of the present invention as it performs a test task;
FIG. 2 is a front end interface view of the present tool;
FIG. 3 is a test case format template diagram;
FIG. 4 is a graph of the test results Excel;
FIG. 5 is a visual interface diagram of test results.
Detailed Description
The invention will be further explained with reference to the drawings.
As shown in fig. 2, the tool is an automated testing tool developed based on matlab, matlab is an abbreviated form of matrix laboratory, matlab is mainly used for processing whole matrixes and arrays, while other programming languages mostly process values one by one, a matrix refers to a two-dimensional array which is usually used for linear algebraic operations, matlab is a commercial mathematical software produced by mathworks corporation in the united states, and a high-level technical computing language and an interactive environment for algorithm development, data visualization, data analysis and numerical computation mainly include two major parts, namely matlab and Simulink. Matlabu has rich algorithm toolboxes, so the method is suitable for the fields of engineering calculation, control design, signal processing and communication, graphic processing, signal detection, financial modeling design and analysis and the like.
As shown in fig. 2, the main display interface of the test tool needs to set the size and position of the interface, the attributes of the menu bar, the option buttons, the cell text, and the like, and then writes and calls the Callback function according to the function of each option button, so as to implement the corresponding function. For example, pressing the "Browse" button can trigger a callback function selected by the model, open the Simulink model to be tested through the open _ system function, click the output observation subsystem of the model, and press the "select" button can obtain the path name of the current module through the gcb function.
As shown in fig. 2, the present invention provides an automated testing tool facing Simulink model, comprising:
and the loading module is used for loading the Simulink model to be tested.
The first selection module is used for selecting an output observation submodule of the Simulink model to be tested.
And the second selection module is used for selecting the test case and distributing time for storing the test process and the test result under the corresponding path.
And the assignment module is used for assigning the Simulink model to be tested through the initialization file.
And the first setting module is used for setting the comparison precision of the simulation step length and the test result.
And the third selection module is used for selecting an MIL or SIL simulation mode.
In particular, MIL testing, model-in-loop testing, is the testing of individual or integrated modules in a model-based development environment.
Specifically, the SIL test, i.e., the software-in-loop test, refers to testing embedded software, an algorithm or the entire control loop on a PC, and does not require ECU hardware regardless of the presence or absence of an environmental model, which is an integral part of the automobile software test during the SIL test.
And the fourth selection module is used for selecting and executing a single test case or a plurality of test cases.
And the calculating module is used for calculating the coverage degree of the test.
And the second setting module is used for setting comparison only on expected time point data or comparison on each simulation step length.
And the automatic test module is used for executing automatic test on the Simulink model to be tested based on the test case.
And the generating module is used for generating a test result based on the current test case.
And the comparison module is used for performing plotting comparison on the failed signals when the test cases fail so as to analyze the state transition of the signal to be tested along with the time flow.
From the perspective of a developed tool front-end interface, a user can perform corresponding operation according to own test requirements, and an observation subsystem of a Model to be tested is selected under a Model panel; selecting a test case form and an initialization file under a TestCase panel, and setting a simulation step length and simulation precision; setting a simulation mode in the Testpanel, testing MIL and SIL, selecting case by case, testing selected cases, selecting all cases: "MCDC" is used to calculate test coverage; "Compare mode" can choose to Compare only the desired point-in-time data or Compare for each simulation step; after the setting is finished, carrying out automatic test through a run running model and a test case; and finally, generating a test result based on the current test case through a report.
Specifically, after clicking "run", the tool begins executing the automated testing task.
Specifically, the tester configures a test environment of the unit model based on the developed tool, the input and output signal names of the model are completely consistent with the signal name of the test case, and the model of the environment to be tested is used as the model to be tested. And writing an initialization script file to give an initial value to the input signal, wherein the signal name is required to be consistent with the input signal name of the model, and the initialization file can be written independently or in an excel table of the test case file. As shown in fig. 3, the relevant keys in the table represent description information of the test case, requirement information corresponding to the test case, associated data dictionary files, data dictionary variable values to be modified (required during integration test), and test sequence information, and corresponding input and output are provided according to software requirements.
As shown in fig. 1, 4 and 5, the automated testing method based on the tool comprises the following steps:
the method comprises the following steps of firstly, reading a test case and loading a Simulink model to be tested, wherein the step of reading the test case comprises the steps of loading the test case and reading test case data, and the step of loading the test case comprises the following steps: judging whether a test case Excel file exists or not; emptying the list of Test panel and loading an Excel table; removing the Chinese worksheet in the form, acquiring configuration items, judging whether an initialization file exists or not, and acquiring an initial value; neglecting the sheet which is not the test case, loading each test case in sequence and converting the test case into a mat format; and importing the test case data into the working area.
The steps of reading the test case data are as follows: reading test case keyword information; reading the time sequence, judging whether the time data exists and the format is correct, and ensuring that the time sequence is monotonically increased; acquiring output information, judging whether output data exists or not, judging whether a format is correct or not, and judging whether a maximum value and a minimum value exist or not; and displaying the test case sequence number and the input variable name in the list.
And secondly, acquiring the input of the test case as the input of the Simulink model to be tested.
And thirdly, operating the Simulink model to be tested, wherein the Simulink model comprises a test case execution step, and the test case execution step comprises the following steps: reading the selected test case; judging whether Simulink model input exists in the test case data or not; judging whether a data dictionary file exists or not; recording the original values of variables needing to be modified in the array dictionary; modifying the value of the data dictionary according to the value in the test case; judging whether all the expected signals in the test case exist in the selected observation submodule; recording signal values in the observation submodule; modifying the configuration of the test model according to the simulation step length; and operating the model to be tested to obtain simulation output.
In the fourth step, test results are obtained, as shown in fig. 4.
And fifthly, comparing the test result with the expected output, judging whether the test result is consistent with the expected output, if so, passing the test case, and if not, failing to pass the test case. As shown in fig. 5, if the test case fails, the failed signal can be plotted and compared, and the state transition of the signal to be tested along with the time flow can be intuitively analyzed, so that the model to be tested is reversely analyzed, and software problems are solved.
Claims (4)
1. An automated testing tool oriented to the Simulink model, comprising:
the loading module is used for loading a Simulink model to be tested;
the first selection module is used for selecting an output observation submodule of the Simulink model to be detected;
the second selection module is used for selecting the test case and distributing time for storing the test process and the test result under the corresponding path;
the assignment module is used for assigning the Simulink model to be tested through the initialization file;
the first setting module is used for setting the comparison precision of the simulation step length and the test result;
the third selection module is used for selecting an MIL or SIL simulation mode;
the fourth selection module is used for selecting and executing a single test case or a plurality of test cases;
the calculation module is used for calculating the coverage degree of the test;
the second setting module is used for setting comparison only on expected time point data or comparison on each simulation step length;
the automatic test module is used for executing automatic test on the Simulink model to be tested based on the test case;
the generating module is used for generating a test result based on the current test case;
and the comparison module is used for performing plotting comparison on the failed signals when the test cases fail so as to analyze the state transition of the signal to be tested along with the time flow.
2. An automated testing method based on an automated testing tool facing a Simulink model is characterized by comprising the following steps:
s01: reading a test case and loading a Simulink model to be tested;
s02: acquiring the input of a test case as the input of a Simulink model to be tested;
s03: running a Simulink model to be tested;
s04: obtaining a test result;
s05: and comparing the test result with the expected output, judging whether the test result is consistent with the expected output, if so, passing the test case, and if not, failing to pass the test case.
3. The automated test tool of claim 2,
in S01, the step of reading the test case includes loading the test case and reading test case data, and the step of loading the test case includes:
a01: judging whether a test case Excel file exists or not;
a02: emptying the list of Test panel and loading an Excel table;
a03: removing the Chinese worksheet in the form, acquiring configuration items, judging whether an initialization file exists or not, and acquiring an initial value;
a04: neglecting the sheet which is not the test case, loading each test case in sequence and converting the test case into a mat format;
a05: importing test case data into a working area;
the steps of reading the test case data are as follows:
b01: reading test case keyword information;
b02: reading the time sequence, judging whether the time data exists and the format is correct, and ensuring that the time sequence is monotonically increased;
b03: acquiring output information, judging whether output data exists or not, judging whether a format is correct or not, and judging whether a maximum value and a minimum value exist or not;
b04: and displaying the test case sequence number and the input variable name in the list.
4. The automated test tool of claim 3,
in S03, the step of executing the test case includes:
c01: reading the selected test case;
c02: judging whether Simulink model input exists in the test case data or not;
c03: judging whether a data dictionary file exists or not;
c04: recording the original values of variables needing to be modified in the data dictionary;
c05: modifying the value of the data dictionary according to the value in the test case;
c06: judging whether all the expected signals in the test case exist in the selected observation submodule;
c07: recording signal values in the observation submodule;
c08: modifying the configuration of the test model according to the simulation step length;
c09: and operating the model to be tested to obtain simulation output.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210335094.2A CN114817001A (en) | 2022-03-31 | 2022-03-31 | Automatic testing tool and automatic testing method for Simulink model |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210335094.2A CN114817001A (en) | 2022-03-31 | 2022-03-31 | Automatic testing tool and automatic testing method for Simulink model |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114817001A true CN114817001A (en) | 2022-07-29 |
Family
ID=82532640
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210335094.2A Pending CN114817001A (en) | 2022-03-31 | 2022-03-31 | Automatic testing tool and automatic testing method for Simulink model |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114817001A (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20100175052A1 (en) * | 2009-01-05 | 2010-07-08 | Tata Consultancy Services Limited | System and method for automatic generation of test data to satisfy modified condition decision coverage |
CN106201891A (en) * | 2016-07-19 | 2016-12-07 | 意昂神州(北京)科技有限公司 | A kind of model automatization method of testing and device |
CN110987476A (en) * | 2019-12-26 | 2020-04-10 | 里卡多科技咨询(上海)有限公司 | Virtual calibration test method and system suitable for automobile power assembly calibration test |
CN111221326A (en) * | 2020-03-03 | 2020-06-02 | 上海中科深江电动车辆有限公司 | System and method for realizing hardware-in-loop test control based on Simulink real-time simulation system |
-
2022
- 2022-03-31 CN CN202210335094.2A patent/CN114817001A/en active Pending
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20100175052A1 (en) * | 2009-01-05 | 2010-07-08 | Tata Consultancy Services Limited | System and method for automatic generation of test data to satisfy modified condition decision coverage |
CN106201891A (en) * | 2016-07-19 | 2016-12-07 | 意昂神州(北京)科技有限公司 | A kind of model automatization method of testing and device |
CN110987476A (en) * | 2019-12-26 | 2020-04-10 | 里卡多科技咨询(上海)有限公司 | Virtual calibration test method and system suitable for automobile power assembly calibration test |
CN111221326A (en) * | 2020-03-03 | 2020-06-02 | 上海中科深江电动车辆有限公司 | System and method for realizing hardware-in-loop test control based on Simulink real-time simulation system |
Non-Patent Citations (1)
Title |
---|
汽车电控杂谈: ""Simulink中的SIL实现方式"", pages 2 - 5, Retrieved from the Internet <URL:《https://blog.csdn.net/jsszcsshaojie/article/details/105477630》> * |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US5991537A (en) | VXI test executive | |
CN101526919B (en) | Method for generating script files to test Web application software and device thereof | |
US7076713B1 (en) | Test generator for converting a model of computer component object behavior and stimulus values to test script | |
US8204711B2 (en) | System and apparatus for managing test procedures within a hardware-in-the-loop simulation system | |
US7761859B2 (en) | Application development environment with features for aiding a user in writing function calls | |
CN103064403A (en) | Method and system of electronic control unit (ECU) hardware-in-loop simulation automated testing | |
US20070061641A1 (en) | Apparatus and method for generating test driver | |
CN112270149A (en) | Verification platform automation integration method and system, electronic equipment and storage medium | |
US20030145252A1 (en) | Test executive system having XML object representation capabilities | |
US9495265B2 (en) | Test executive system with processing of results data in chunks | |
US8042095B2 (en) | Application development environment with features for increasing the ease and efficiency of viewing function help text | |
Tierno et al. | Open issues for the automotive software testing | |
US20030145280A1 (en) | Test executive system having XML reporting capabilities | |
US10169217B2 (en) | System and method for test generation from software specification models that contain nonlinear arithmetic constraints over real number ranges | |
CN110750462A (en) | FPGA white box test platform | |
US20100242024A1 (en) | User Interface System and Method for Controlling Conversion of a Source Job Control Language File into a Test Job Control Language File | |
CN116955170A (en) | Rocket test soft part automatic test system | |
CN111581101A (en) | Software model testing method, device, equipment and medium | |
CN114817001A (en) | Automatic testing tool and automatic testing method for Simulink model | |
CN115658617A (en) | Signal visualization analysis processing method and system based on MATLAB/App Designer development | |
Megawati et al. | The Black Box Testing of the" Hybrid Engine" Application Using Boundary Value Analysis Technique:- | |
JP3357567B2 (en) | Program evaluation system | |
CN111124815A (en) | Log checking method, device, equipment and storage medium | |
CN112417799B (en) | Multi-signal selection and response method | |
JPH09259006A (en) | Program evaluation system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |