Automatic test method and device for model software
Through the automated testing method, the test case description table is used to generate the test case table, and simulation and result comparison are performed in the model software, which solves the problem of low MIL testing efficiency of the model software and improves the testing efficiency.
Patent Information
- Application Number
- CN202410665429.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-27
- Publication Date
- 2024-09-03
AI Technical Summary
The MIL testing efficiency of model software in the existing technology is low, and Excel test cases need to be manually written for testing, resulting in low efficiency.
Provide an automated testing method for model software. By obtaining the test case description table, generate a test case table, and assign the value of the input signal to the model software for simulation at each test time, automatically obtain the actual value of the output signal, and automatically compare Actual and expected values, labeled test results.
It realizes automated testing of model software, improves MIL testing efficiency, and reduces manual steps and time.
Smart Images

Figure CN118585437A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software automated testing, and in particular to an automated testing method and device for model software. Background Art
[0002] Most of the application software in the vehicle controller uses Simulink in Matlab to build a model, which is automatically generated into code and then applied to the real vehicle, such as CCM (Chassis Control Module) application layer software. After the model software is developed, it is usually tested by MIL (Model in loop) to ensure the correctness of the model software function. At present, when performing MIL testing on the model software, it is necessary to write Excel test cases and manually test according to the Excel test cases, which has the problem of low testing efficiency. Summary of the invention
[0003] The present invention solves the technical problem of how to improve the MIL testing efficiency of model software by providing an automated testing method and device for model software.
[0004] On the one hand, the present invention provides the following technical solutions:
[0005] An automated testing method for model software, comprising:
[0006] Obtain a test case description table of the model software; the test case description table records the input value of each input signal and the expected value of each output signal in each test phase;
[0007] Generate a test case table according to the test case description table; the test case table records the input value of each input signal at each test time and the expected value of each output signal at each test time, and the test time corresponds to the test stage one by one;
[0008] At each test time, assigning the input value of each input signal in the test case table at the test time to the input signal of the model software for simulation;
[0009] Obtaining the actual value of each of the output signals output by the model software at each of the test times;
[0010] If the actual value of at least one of the output signals output at the test time is different from the expected value of the output signal at the test time in the test case table, then the test result of the test time is marked as failed in the test case table;
[0011] If the actual value of each of the output signals output at the test time is the same as the expected value of the output signal at the test time in the test case table, the test result of the test time is marked as passed in the test case table.
[0012] Optionally, before generating the test case table according to the test case description table, the method further includes: obtaining the names of all the input signals and the names of all the output signals of the model software; writing the name of each input signal and the name of each output signal into the test case table;
[0013] The step of generating a test case table according to the test case description table comprises:
[0014] Write the input value corresponding to the name of each input signal of each test phase in the test case description table into the position corresponding to the test phase and the name of the input signal in the test case table;
[0015] Write the expected value corresponding to the name of each output signal of each test phase in the test case description table into the position corresponding to the test phase and the name of the output signal in the test case table;
[0016] The test time corresponding to each test phase is written in the position corresponding to the test phase in the test case table.
[0017] Optionally, writing the name of each input signal and the name of each output signal into the test case table comprises: writing the name of each input signal and the name of each output signal into the same row of the test case table in a form in which the name of each input variable and the name of each output signal each occupy a column;
[0018] The step of writing the input value corresponding to the name of each input signal of each test phase in the test case description table into the position corresponding to the test phase and the name of the input signal in the test case table comprises: writing the input value corresponding to the name of each input signal of each test phase in the test case description table into the row corresponding to the test phase and the column where the name of the input signal is located in the test case table;
[0019] The step of writing the expected value corresponding to the name of each output signal of each test phase in the test case description table into the position corresponding to the test phase and the name of the output signal in the test case table comprises: writing the expected value corresponding to the name of each output signal of each test phase in the test case description table into the row corresponding to the test phase and the column where the name of the output signal is located in the test case table;
[0020] Writing the test time corresponding to each test phase in the position corresponding to the test phase in the test case table includes: writing a first character string representing the test time in a blank column of the same row of the test case table; writing the test time corresponding to the test phase in the row corresponding to each test phase in the test case table and in the column where the first character string is located.
[0021] Optionally, the automated testing method further comprises: writing a second character string representing a test result in a blank column of the same row of the test case table;
[0022] The step of marking the test result of the test time as a failure in the test case table includes: writing a character string representing a test failure in the row where the test time is located and in the column where the second character string is located in the test case table;
[0023] The step of marking the test result of the test time as passed in the test case table includes: writing a character string representing a successful test in the row where the test time is located and the column where the second character string is located in the test case table.
[0024] Optionally, the obtaining the names of all input signals and all output signals of the model software includes:
[0025] Call the find_system function to obtain the handle information of the FromWorkspace module and the handle information of the ToWorkspace module of the model software;
[0026] Call the get function to obtain the names of all the input signals in the handle information of the FromWorkspace module and the names of all the output signals in the handle information of the ToWorkspace module.
[0027] Optionally, assigning the input value of each input signal in the test case table at the test time to the input signal of the model software for simulation at each test time includes:
[0028] Call the xlsread function to read each of the test times in the test case table and the input value of each of the input signals at the test time;
[0029] The assignin function of the simulation software is called to write each of the test times and the input value of each of the input signals at the test time into the working area of the simulation software.
[0030] Optionally, assigning the input value of each input signal in the test case table at the test time to the input signal of the model software for simulation at each test time includes:
[0031] At each test time, assigning the input value of each input signal in the test case table at the test time to the input signal of the model software;
[0032] Call the set_param function to set the running time of the model software to the maximum value of the test time;
[0033] The sim function is called to simulate the model software.
[0034] On the other hand, the present invention also provides the following technical solutions:
[0035] An automated testing device for model software, comprising:
[0036] An acquisition module is used to acquire a test case description table of the model software; the test case description table records the input value of each input signal and the expected value of each output signal in each test phase;
[0037] A generating module, used to generate a test case table according to the test case description table; the test case table records the input value of each input signal at each test time and the expected value of each output signal at each test time, and the test time corresponds to the test stage one by one;
[0038] A simulation module, used for assigning the input value of each input signal in the test case table at the test time to the input signal of the model software for simulation at each test time;
[0039] The acquisition module is further used to acquire the actual value of each of the output signals output by the model software at each of the test times;
[0040] A writing module, used for marking the test result of the test time as failure in the test case table if the actual value of at least one of the output signals output at the test time is different from the expected value of the output signal at the test time in the test case table;
[0041] If the actual value of each of the output signals output at the test time is the same as the expected value of the output signal at the test time in the test case table, the test result of the test time is marked as passed in the test case table.
[0042] On the other hand, the present invention also provides the following technical solutions:
[0043] A computer device comprises a memory, a processor and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of an automated testing method for any model software.
[0044] On the other hand, the present invention also provides the following technical solutions:
[0045] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of an automated testing method for any model software.
[0046] One or more technical solutions provided by the present invention have at least the following technical effects or advantages:
[0047] The present invention can automatically generate a test case table according to a test case description table, automatically assign the input value of each input signal in the test case table at the test time to the input signal of the model software for simulation, automatically obtain the actual value of each output signal output by the model software at each test time, automatically compare the actual value of each output signal output by the model software at each test time with the expected value of the output signal at the test time, and automatically mark the test result of each test stage according to the comparison result, thereby realizing the automated testing of the model software and improving the MIL testing efficiency of the model software. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings in the following description are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.
[0049] Figure 1 It is a flow chart of the automated testing method of the model software in the embodiment of the present invention;
[0050] Figure 2 Schematic diagram of an automated testing device for model software in an embodiment of the present invention. DETAILED DESCRIPTION
[0051] The embodiment of the present invention solves the technical problem of how to improve the MIL testing efficiency of model software by providing an automated testing method and device for model software.
[0052] In order to better understand the technical solution of the present invention, the technical solution of the present invention will be described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0053] like Figure 1 As shown, the automated testing method of the model software of the embodiment of the present invention includes:
[0054] Step S1, obtaining a test case description table of the model software; the test case description table records the input value of each input signal and the expected value of each output signal in each test phase;
[0055] Step S2, generating a test case table according to the test case description table; the test case table records the input value of each input signal at each test time and the expected value of each output signal at each test time, and the test time corresponds to the test stage one by one;
[0056] Step S3, at each test time, assigning the input value of each input signal in the test case table at the test time to the input signal of the model software for simulation;
[0057] Step S4, obtaining the actual value of each output signal output by the model software at each test time;
[0058] Step S5, if the actual value of at least one output signal output at the test time is different from the expected value of the output signal at the test time in the test case table, then mark the test result of the test time as failed in the test case table;
[0059] Step S6: If the actual value of each output signal output at the test time is the same as the expected value of the output signal at the test time in the test case table, then the test result of the test time is marked as passed in the test case table.
[0060] The embodiment of the present invention is described by taking the model software as part of the application layer software in the CCM controller as an example. The modules used in the outermost layer of the model software are the FromWorkspace module and the ToWorkspace module. The FromWorkspace module can assign the input value of the input signal in the simulation software MATLAB workspace to the FromWorkspace module, and the ToWorkspace module can output the actual value of the output signal to the MATLAB workspace, including the actual value of the output signal at each moment.
[0061] The application layer software is mainly used to control the seat ventilation function. The input / output interface definition is shown in Table 1:
[0062] Table 1
[0063]
[0064]
[0065] When the power gear is ON (g_inIGNSw=2), CCM will issue a seat ventilation opening command to turn on the seat ventilation function after SWINve_u8_Mp5DriverSeatVentReq sends a seat ventilation request. SWINve_u8_Mp5DriverSeatVentReq sends seat ventilation requests of different gears, and CCM will issue the corresponding seat ventilation opening command. When the power gear is OFF / ACC (g_inIGNSw=0 / 1), CCM will output a seat ventilation closing request (DriverSeatVent_Close_CmdTrig=1) to turn off the seat ventilation function.
[0066] Before step S2, the automated testing method for the model software of the embodiment of the present invention further includes: obtaining the names of all input signals and all output signals of the model software; and writing the name of each input signal and the name of each output signal into the test case table.
[0067] Wherein, obtaining the names of all input signals and all output signals of the model software may include: calling find_system function to obtain the handle information of the FromWorkspace module and the handle information of the ToWorkspace module of the model software; calling get function to obtain the names of all input signals in the handle information of the FromWorkspace module and the names of all output signals in the handle information of the ToWorkspace module. In this way, an array IN composed of all input signal names and an array Out composed of all output signal names can be obtained, IN = (g_inIGNSw, SWINve_u8_Mp5DriverSeatV entReq), Out = (DriverSeatVent_OpenLevel1_CmdTrig, DriverSeatVent_Open Level2_CmdTrig, DriverSeatVent_OpenLevel3_CmdTrig, DriverSeatVent_Close_CmdTrig), the length of IN is 2, and the length of Out is 4.
[0068] Wherein, writing the name of each input signal and the name of each output signal into the test case table may include: writing the name of each input signal and the name of each output signal into the same row of the test case table in the form of each input variable name and each output signal name occupying one column. Here, the names of the two input signals and the names of the four output signals may be written into the first row of the test case table, and then sequentially written into columns 2-7 of the test case table, to obtain the test case table of Table 2.
[0069] Table 2
[0070]
[0071] Let i be the row number of the test case table, j be the column number of the test case table, and a be the sequence number of the input signal name in the array IN.
[0072] When writing the input signal name, assign IN(a) to Write_Excel(i, j), and Write_Excel(i, j) means writing the data Write_Excel(i, j) as the i-th row and j-th column of the test case table. First, let a=1, i=1, j=2, and write the first input signal name g_inIGNSw in IN to the first row and second column of the test case table; let a=a+1, j=j+1, now a=2, j=3, determine whether a is greater than the length of IN, that is, determine whether all output signal names have been written into the test case table, a is not greater than the length 2 of IN, assign IN(2) to Write_Excel(1,3), and write the second input signal name SWINve_u8_Mp5DriverSeatVentReq in IN to the first row and third column of the test case table; let a=a+1, j=j+1, now a=3, j=4, a is greater than the length 2 of IN, and all input signal names have been written into the test case table.
[0073] The process of writing output signal names is similar to the process of writing input signal names, so it will not be repeated here.
[0074] The test case description table in step S1 is shown in Table 3.
[0075] Table 3
[0076]
[0077]
[0078] Each row of 2-4 in the table represents a test case, which contains the input value of the input signal and the expected value of the output signal of each test stage, that is, the test case description table records the names of all input signals, all output signals, the input value corresponding to the name of each input signal, and the expected value corresponding to the name of each output signal in each test stage. The test stages in Table 3 include the initialization stage, the stage of opening the seat ventilation function, and the stage of closing the seat ventilation function. It can be seen that the input signals of the three stages are g_inIGNSw and SWINve_u8_Mp5DriverSeatVentReq; there is no output signal in the initialization stage, the output signal of the stage of opening the seat ventilation function is DriverSeatVent_OpenLevel1_CmdTrig, and the output signals of the stage of closing the seat ventilation function are DriverSeatVent_OpenLevel1_CmdTrig and DriverSeatVent_Close_CmdTrig.
[0079] Step S2 of the embodiment of the present invention may include: writing the input value corresponding to the name of each input signal of each test phase in the test case description table into the position corresponding to the test phase and the name of the input signal in the test case table; writing the expected value corresponding to the name of each output signal of each test phase in the test case description table into the position corresponding to the test phase and the name of the output signal in the test case table; writing the test time corresponding to the test phase in the position corresponding to each test phase in the test case table. Further, writing the input value corresponding to the name of each input signal of each test phase in the test case description table into the position corresponding to the test phase and the name of the input signal in the test case table includes: writing the input value corresponding to the name of each input signal of each test phase in the test case description table into the row corresponding to the test phase and the column where the name of the input signal is located in the test case table. Writing the expected value corresponding to the name of each output signal of each test phase in the test case description table into the position corresponding to the test phase and the name of the output signal in the test case table includes: writing the expected value corresponding to the name of each output signal of each test phase in the test case description table into the row corresponding to the test phase and the column where the name of the output signal is located in the test case table. The test time corresponding to each test phase is written in the position corresponding to the test phase in the test case table, including: writing a first character string representing the test time in a blank column of the same row of the test case table; and writing the test time corresponding to each test phase in the row corresponding to the test phase and in the column where the first character string is located in the test case table.
[0080] In the embodiment of the present invention, the position corresponding to the initialization stage can be the second row of the test case table, the position corresponding to the stage of opening the seat ventilation function can be the third row of the test case table, the position corresponding to the stage of closing the seat ventilation function can be the fourth row of the test case table, the positions corresponding to the names of the two input signals can be the second column and the third column of the test case table, respectively, and the positions corresponding to the names of the four output signals can be the fourth to seventh columns of the test case table, respectively. The first character string can be "Time", and "Time" can be written into the first row and the first column of the test case table, the test time corresponding to the initialization stage can be written into the second row and the first column of the test case table, the test time corresponding to the stage of opening the seat ventilation function can be written into the third row and the first column of the test case table, and the test time corresponding to the stage of closing the seat ventilation function can be written into the third row and the first column of the test case table, to obtain the test case table of Table 4.
[0081] Table 4
[0082]
[0083] Let p be the row number of the test case description table and q be the column number of the test case description table.
[0084] When writing the input value of the input signal, the data in the test case description table is read through Read_Excel(p,q), and Read_Excel(p,q) represents the data in the pth row and qth column of the test case description table. First, let p=2, q=2, a=1, i=2, j=2, and determine whether Read_Excel(2,2) contains IN(1), that is, determine whether the second row and the second column of the test case description table contain the first input signal name "g_inIGNSw" in IN, and Read_Excel(2,2) contains IN(1). Extract the value "0" between "g_inIGNSw=" and ";" in Read_Excel(2,2) and assign it to Write_Excel(2,2), and write "0" into the second row and the second column of the test case table.
[0085] Next, let p=p+1=3 to determine whether p is greater than the number of rows in the test case description table, that is, to determine whether the first input signal has been processed; p=3 is not greater than the number of rows in the test case description table, which is 4, indicating that the first input signal has not been processed, then let i=i+1=3 to continue to determine whether Read_Excel(3,2) contains IN(1). Read_Excel(3,2) contains IN(1), extract the value "2" between "g_inIGNSw=" and ";" in Read_Excel(3,2) and assign it to Write_Excel(3,2), and write "2" into the 3rd row and 2nd column of the test case table.
[0086] Next, let p=p+1=4 to determine whether p is greater than the number of rows in the test case description table. If p=4 is not greater than the number of rows in the test case description table, which is 4, then let i=i+1=4 to continue determining whether Read_Excel(4,2) contains IN(1). Read_Excel(4,2) contains "g_inIGNSw". Extract the value "0" between "g_inIGNSw=" and ";" in Read_Excel(4,2) and assign it to Write_Excel(4,2). Write "0" to the 4th row and 2nd column of the test case table.
[0087] Next, let p=p+1=5, and determine whether p is greater than the number of rows in the test case description table. p=5 is greater than the number of rows in the test case description table, which is 4, indicating that the first input signal has been processed. Then let a=a+1=2, and determine whether a is greater than the length of IN, that is, determine whether all input signals have been processed. If a=2 is not greater than the length of IN, which is 2, then let p=2 and i=2, and repeat the above process starting from the 2nd row and 2nd column of the test case description table to process the second input signal, until a=3 is greater than the length of IN, which is 2, and all input signals have been processed.
[0088] The process of writing the expected value of the output signal is similar to the process of writing the input signal name, which will not be repeated here. The difference is that if a row or column in the test case description table does not contain the name of an output signal, it means that the test case has no expected value for the output variable, so the default value (such as FF) is written to the corresponding position in the test case table.
[0089] When writing the test time, let T be the test time and the time difference of each test stage be 0.5. Let T=0.5, i=2, j=1, and write 0.5 in the 2nd row and 1st column of the test case table; then let i=i+1=3 to determine whether i is greater than the number of rows in the test case table. i=3 is not greater than the number of rows in the test case table, which is 4. Then let T=0.5+(i-2)*0.5=1, and write 1 in the 3rd row and 1st column of the test case table; then let i=i+1=4 to determine whether i is greater than the number of rows in the test case table. i=4 is not greater than the number of rows in the test case table, which is 4. Then let T=0.5+(i-2)*0.5=1.5, and write 1.5 in the 4th row and 1st column of the test case table; then let i=i+1=5 to determine whether i is greater than the number of rows in the test case table. i=5 is greater than the number of rows in the test case table, which is 4. The test time has been written for all test stages.
[0090] Step S3 of the embodiment of the present invention may include: assigning the input value of each input signal in the test case table at the test time to the input signal of the model software at each test time; calling the set_param function to set the running time of the model software to the maximum value of the test time; calling the sim function to simulate the model software. Wherein, assigning the input value of each input signal in the test case table at the test time to the input signal of the model software at each test time may include: calling the xlsread function to read each test time in the test case table and the input value of each input signal at the test time; calling the assignin function of the simulation software Matlab to write each test time and the input value of each input signal at the test time into the work area of the simulation software Matlab.
[0091] When simulating the Matlab model, the FromWorkspace module will automatically read the Matlab workspace containing the test time and the input value of each input signal at the test time. The ToWorkspace module will output the actual value of each output signal at each moment in the simulation process to the Matlab workspace. The running time of the model software can be set to 1.5s. If the simulation cycle of the model software is 0.1s, the actual value of each output signal output at 0.1s, 0.2s, ..., 1.4s, and 1.5s can be obtained.
[0092] Step S4 may include: obtaining the number of runs of the model software; determining the run time corresponding to the number of runs; if the run time is consistent with a certain test time, obtaining the actual value of each output signal output by the model software at the run time. That is, the actual value of each output signal output by the model software at the test time is obtained. The number of runs of the model software ranges from 1 to 15, and the corresponding run times are 0.1s, 0.2s, ..., 1.4s, and 1.5s, respectively. The run time 0.5 is consistent with the test time 0.5, the run time 1 is consistent with the test time 1, and the run time 1.5 is consistent with the test time 1.5.
[0093] Assume that t is the running time of the model software, b is the serial number of the output signal, and Output_Vale(t, b) is the actual value of the bth output signal output by the model software at time t.
[0094] When comparing the actual value of the output signal with the expected value, first set t = 0.1, i = 2, j = 1, and determine whether t is equal to Write_Excel (2, 1). t = 0.1 is not equal to Write_Excel (2, 1) = 0.5, then set i = i + 1 = 3 to determine whether i is greater than the number of rows in the test case table. i = 3 is less than the number of rows in the test case table, 4. Determine whether t is equal to Write_Excel (3, 1). t = 0.1 is not equal to Write_Excel (3, 1)=1 are not equal, then let i=i+1=4, and determine whether i is greater than the number of rows in the test case table. i=4 is not greater than the number of rows in the test case table, 4. Determine whether t is equal to Write_Excel(4,1). t=0.1 is not equal to Write_Excel(3,1)=1.5, then let i=i+1=5, and determine whether i is greater than the number of rows in the test case table. i=5 is greater than the number of rows in the test case table, 4. The running time 0.1 has been compared with all the test times in the test case table.
[0095] Then let t=0.2, 0.3, 0.4, and repeat the above process. When t=0.5, t=0.5 is equal to Write_Excel(2,1)=0.5, then let b=1, i=2, j=4, and judge whether Output_Vale(0.5,1) is equal to Write_Excel(2,4) or whether Write_Excel(2,4) is the default value FF, that is, judge whether the actual value of the first output signal output by the model software at time 0.5 is equal to the value FF of the second row and fourth column of the test case table or whether the value of the second row and fourth column of the test case table is the default value FF. If Output_Vale(0.5,1) is not equal to Write_Excel(2,4) and Write_Excel(2,4) is not the default value FF, it means the test failed, and the test result of test time 0.5 is marked as failed in the test case table; if Output_Vale(0.5,1) is equal to Write_Excel(2,4), then Write_Excel(2,4) is equal to Write_Excel(2,4). _Excel(2,4) is equal or Write_Excel(2,4) is the default value FF, which means the first output signal test passed; then let b=b+1=2, j=j+1=5, and judge whether j is greater than the column number of the last column of output signals, that is, judge whether all output signals have been compared. j=5 is less than the column number 7 of the last column of output signals, and all output signals have not been compared. Then judge whether Output_Vale(0.5,2) is equal to Write_Excel(2,5) or whether Write_Excel(2,4) is the default value FF, and the comparison of the second output signal is completed; and so on, the comparison of the third and fourth output signals is completed respectively; if the actual value of each output signal output at 0.5s is the same as the expected value of the output signal at the test time in the test case table, then the test result of the test time 0.5 is marked as passed in the test case table. The comparison process of the output signal at t=1 and 1.5 is similar to the above process, which will not be repeated here.
[0096] For marking the test results, the automated testing method of the embodiment of the present invention further includes: writing a second string representing the test result in a blank column in the same row of the test case table. Marking the test result of the test time as failed in the test case table may include: writing a string representing a test failure in the row where the test time is located and the column where the second string is located in the test case table. Marking the test result of the test time as passed in the test case table may include: writing a string representing a successful test in the row where the test time is located and the column where the second string is located in the test case table. The second string "test result" representing the test result can be written in the 8th column of the 1st row of the test case table. The string representing a test failure can be "Fail", and the string representing a successful test can be "Pass". The test case table of Table 5 is obtained to complete the automated testing of the model software.
[0097] Table 5
[0098]
[0099] As can be seen from the above, the automated testing method for the model software of the embodiment of the present invention can automatically generate a test case table based on the test case description table, automatically assign the input value of each input signal in the test case table at the test time to the input signal of the model software for simulation, automatically obtain the actual value of each output signal output by the model software at each test time, automatically compare the actual value of each output signal output by the model software at each test time with the expected value of the output signal at the test time, and automatically mark the test results of each test stage according to the comparison results, thereby realizing automated testing of the model software and improving the MIL testing efficiency of the model software.
[0100] like Figure 2 As shown, the embodiment of the present invention also provides an automated testing device for model software, including:
[0101] An acquisition module is used to acquire a test case description table of the model software; the test case description table records the input value of each input signal and the expected value of each output signal in each test phase;
[0102] A generation module is used to generate a test case table according to the test case description table; the test case table records the input value of each input signal at each test time and the expected value of each output signal at each test time, and the test time corresponds to the test stage one by one;
[0103] A simulation module, used for assigning the input value of each input signal in the test case table at the test time to the input signal of the model software for simulation at each test time;
[0104] The acquisition module is also used to obtain the actual value of each output signal output by the model software at each test time;
[0105] A writing module is used to mark the test result of the test time as failed in the test case table if the actual value of at least one output signal output at the test time is different from the expected value of the output signal at the test time in the test case table; if the actual value of each output signal output at the test time is the same as the expected value of the output signal at the test time in the test case table, then the test result of the test time is marked as passed in the test case table.
[0106] Furthermore, the acquisition module can also be used to obtain the names of all input signals and all output signals of the model software; the generation module can also be used to write the name of each input signal and the name of each output signal into the test case table. The generation module can also be used to: write the input value corresponding to the name of each input signal of each test phase in the test case description table into the position corresponding to the test phase and the name of the input signal in the test case table; write the expected value corresponding to the name of each output signal of each test phase in the test case description table into the position corresponding to the test phase and the name of the output signal in the test case table; write the test time corresponding to each test phase in the position corresponding to the test phase in the test case table.
[0107] Furthermore, the acquisition module can also be used to: call the find_system function to obtain the handle information of the FromWorkspace module and the handle information of the ToWorkspace module of the model software; call the get function to obtain the names of all input signals in the handle information of the FromWorkspace module and the names of all output signals in the handle information of the ToWorkspace module.
[0108] Furthermore, the generation module can also be used to write the name of each input signal and the name of each output signal into the same row of the test case table in the form of the name of each input variable and the name of each output signal each occupying one column; write the input value corresponding to the name of each input signal in each test phase in the test case description table into the row corresponding to the test phase and the column where the name of the input signal is located in the test case table; write the expected value corresponding to the name of each output signal in each test phase in the test case description table into the row corresponding to the test phase and the column where the name of the output signal is located in the test case table; write the first character string representing the test time in the blank column of the same row of the test case table; write the test time corresponding to each test phase in the row corresponding to the test phase and the column where the first character string is located in the test case table.
[0109] Furthermore, the simulation module can also be used to: call the xlsread function to read each test time in the test case table and the input value of each input signal at the test time; call the assignin function of the simulation software to write each test time and the input value of each input signal at the test time into the workspace of the simulation software.
[0110] Furthermore, the simulation module can also be used to: assign the input value of each input signal in the test case table at each test time to the input signal of the model software; call the set_param function to set the running time of the model software to the maximum value of the test time; call the sim function to simulate the model software.
[0111] Furthermore, the writing module can also be used to: write a second string representing the test result in a blank column in the same row of the test case table; write a string representing a test failure in the row where the test time is located and the column where the second string is located in the test case table; write a string representing a test success in the row where the test time is located and the column where the second string is located in the test case table.
[0112] Based on the same inventive concept as the automated testing method for model software described above, an embodiment of the present invention also provides a computer device comprising a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of any of the automated testing methods for model software described above.
[0113] Among them, the bus architecture (represented by the bus), the bus can include any number of interconnected buses and bridges, and the bus links various circuits including one or more processors represented by the processor and memory represented by the memory. The bus can also link various other circuits such as peripherals, voltage regulators, and power management circuits together, which are all well known in the art and are therefore not further described herein. The bus interface provides an interface between the bus and the receiver and transmitter. The receiver and transmitter can be the same element, namely a transceiver, which provides a unit for communicating with various other devices on a transmission medium. The processor is responsible for managing the bus and general processing, while the memory can be used to store data used by the processor when performing operations.
[0114] Since the computer device introduced in the embodiment of the present invention is a computer device used to implement the automated testing method of the model software in the embodiment of the present invention, based on the automated testing method of the model software introduced in the embodiment of the present invention, a person skilled in the art can understand the specific implementation of the computer device in the embodiment of the present invention and its various variations, so how the computer device implements the method in the embodiment of the present invention is not described in detail here. As long as a person skilled in the art implements the computer device used in the automated testing method of the model software in the embodiment of the present invention, it belongs to the scope of protection of the present invention.
[0115] Based on the same inventive concept as the above-mentioned automated testing method for model software, the present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the above-mentioned automated testing methods for model software.
[0116] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0117] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0118] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0119] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0120] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.
Claims
1. An automated testing method for model software, characterized in that: include: Obtain the test case description table of the model software; The test case description table records the input value of each input signal and the expected value of each output signal in each test phase; Generate a test case table according to the test case description table; the test case table records the input value of each input signal at each test time and the expected value of each output signal at each test time, and the test time corresponds to the test stage one by one; At each test time, assigning the input value of each input signal in the test case table at the test time to the input signal of the model software for simulation; Obtaining the actual value of each of the output signals output by the model software at each of the test times; If the actual value of at least one of the output signals output at the test time is different from the expected value of the output signal at the test time in the test case table, then the test result of the test time is marked as failed in the test case table; If the actual value of each of the output signals output at the test time is the same as the expected value of the output signal at the test time in the test case table, the test result of the test time is marked as passed in the test case table.
2. The automated testing method for model software according to claim 1, characterized in that: Before generating the test case table according to the test case description table, the method further includes: obtaining the names of all the input signals and the names of all the output signals of the model software; writing the name of each input signal and the name of each output signal into the test case table; The step of generating a test case table according to the test case description table comprises: Write the input value corresponding to the name of each input signal of each test phase in the test case description table into the position corresponding to the test phase and the name of the input signal in the test case table; Write the expected value corresponding to the name of each output signal of each test phase in the test case description table into the position corresponding to the test phase and the name of the output signal in the test case table; The test time corresponding to each test phase is written in the position corresponding to the test phase in the test case table.
3. The automated testing method for model software according to claim 2, characterized in that: Writing the name of each input signal and the name of each output signal into the test case table comprises: writing the name of each input signal and the name of each output signal into the same row of the test case table in a form in which the name of each input variable and the name of each output signal each occupy a column; The step of writing the input value corresponding to the name of each input signal of each test phase in the test case description table into the position corresponding to the test phase and the name of the input signal in the test case table comprises: writing the input value corresponding to the name of each input signal of each test phase in the test case description table into the row corresponding to the test phase and the column where the name of the input signal is located in the test case table; The step of writing the expected value corresponding to the name of each output signal of each test phase in the test case description table into the position corresponding to the test phase and the name of the output signal in the test case table comprises: writing the expected value corresponding to the name of each output signal of each test phase in the test case description table into the row corresponding to the test phase and the column where the name of the output signal is located in the test case table; Writing the test time corresponding to each test phase in the position corresponding to the test phase in the test case table includes: writing a first character string representing the test time in a blank column of the same row of the test case table; writing the test time corresponding to the test phase in the row corresponding to each test phase in the test case table and the column where the first character string is located.
4. The automated testing method for model software according to claim 3, characterized in that: Also includes: Write a second character string representing a test result in a blank column of the same row of the test case table; The step of marking the test result of the test time as a failure in the test case table includes: writing a character string representing a test failure in the row where the test time is located and in the column where the second character string is located in the test case table; The step of marking the test result of the test time as passed in the test case table includes: writing a character string representing a successful test in the row where the test time is located and the column where the second character string is located in the test case table.
5. The automated testing method for model software according to claim 2, characterized in that: The obtaining of the names of all input signals and all output signals of the model software includes: Call the find_system function to obtain the handle information of the FromWorkspace module and the handle information of the ToWorkspace module of the model software; Call the get function to obtain the names of all the input signals in the handle information of the FromWorkspace module and the names of all the output signals in the handle information of the ToWorkspace module.
6. The automated testing method for model software according to claim 1, characterized in that: The step of assigning the input value of each input signal in the test case table at the test time to the input signal of the model software for simulation at each test time includes: Call the xlsread function to read each of the test times in the test case table and the input value of each of the input signals at the test time; The assignin function of the simulation software is called to write each of the test times and the input value of each of the input signals at the test time into the working area of the simulation software.
7. The automated testing method for model software according to claim 1, characterized in that: The step of assigning the input value of each input signal in the test case table at the test time to the input signal of the model software for simulation at each test time includes: At each test time, assigning the input value of each input signal in the test case table at the test time to the input signal of the model software; Call the set_param function to set the running time of the model software to the maximum value of the test time; The sim function is called to simulate the model software.
8. An automated testing device for model software, characterized in that: include: An acquisition module is used to obtain a test case description table of the model software; The test case description table records the input value of each input signal and the expected value of each output signal in each test phase; A generating module, used to generate a test case table according to the test case description table; the test case table records the input value of each input signal at each test time and the expected value of each output signal at each test time, and the test time corresponds to the test stage one by one; A simulation module, used for assigning the input value of each input signal in the test case table at the test time to the input signal of the model software for simulation at each test time; The acquisition module is further used to acquire the actual value of each of the output signals output by the model software at each of the test times; A writing module, used for marking the test result of the test time as failure in the test case table if the actual value of at least one of the output signals output at the test time is different from the expected value of the output signal at the test time in the test case table; If the actual value of each of the output signals output at the test time is the same as the expected value of the output signal at the test time in the test case table, the test result of the test time is marked as passed in the test case table.
9. A computer device, characterized in that: The invention comprises a memory, a processor and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
