Test method and device of battery management software, electronic equipment and storage medium
By obtaining the test model of the battery management software and generating test cases, the problem of poor test results caused by the existing battery management software testing methods relying on human writing and observation, and efficient and accurate test results are achieved.
Patent Information
- Application Number
- CN202411481105.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-21
- Publication Date
- 2025-02-28
AI Technical Summary
The testing methods of existing battery management software rely on artificially writing test cases and observations, resulting in poor test results and large test errors caused by subjective factors.
By obtaining the test model of the battery management software to be tested, multiple test cases are generated based on the preset use case format, and these test cases are input into the test model, the test value is obtained, and finally the test results are generated based on the reference value and the test value.
There is no need to write test cases for humans, which greatly reduces labor costs, improves testing efficiency, reduces test errors caused by subjective factors, and ensures the accuracy of the test.
Smart Images

Figure CN119537209A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer technology, and in particular relates to a testing method, device, electronic equipment and storage medium for battery management software. Background Art
[0002] With the development of computer technology, in the fields of vehicles and the like, the status of the battery pack in the vehicle is often managed by a battery management system (BMS). Therefore, the operating status of the BMS system has a great impact on the vehicle battery, so it is necessary to test the software of the BMS system in a timely manner.
[0003] At present, BMS software testing is often done by testers who manually write test cases and obtain test results through manual observation. However, this method relies on the experience of testers and is relatively subjective, resulting in poor test results. Summary of the invention
[0004] The present invention provides a battery management software testing method, device, electronic equipment and storage medium to solve the problem of poor testing effect.
[0005] In order to solve the above-mentioned technical problems, the present invention is achieved as follows:
[0006] In a first aspect, the present invention provides a method for testing battery management software, the method comprising:
[0007] Based on the to-be-tested function of the to-be-tested battery management software, obtaining a test model of the to-be-tested battery management software;
[0008] Generate multiple test cases for the test model based on a preset test case format;
[0009] Inputting the multiple test cases into the test model, and obtaining multiple test values output by the test model based on the multiple test cases;
[0010] A test result is generated based on the reference value corresponding to each test case and the test value.
[0011] Optionally, generating a test result based on a reference value corresponding to each test case and the test value includes:
[0012] Compare the reference value corresponding to each test case with the test value to obtain a test result;
[0013] Determine whether each of the test results meets the preset test requirements and generate a test report;
[0014] In the case that there are test results that do not meet the preset test requirements, the test results that do not meet the preset test requirements are output to the display component for display.
[0015] Optionally, the method further comprises:
[0016] Based on the test results that do not meet the preset test requirements, determine the functions to be modified of the battery management software to be tested;
[0017] The software code corresponding to the function to be modified is modified to obtain updated battery management software to be tested.
[0018] Optionally, the method further comprises:
[0019] Acquire the updated test model of the battery management software to be tested as a new test model;
[0020] For the new test model, the operation of inputting the plurality of test cases into the test model is performed again.
[0021] Optionally, after generating a plurality of test cases for the test model based on a preset test case format, the method further includes:
[0022] Storing the multiple test cases in a preset data set;
[0023] The step of inputting the plurality of test cases into the test model comprises:
[0024] The preset data set is associated with the test model to obtain the multiple test cases from the preset data set and input them into the test model.
[0025] Optionally, generating a test report includes:
[0026] Acquire a tested function among the functions to be tested based on the test result;
[0027] Based on the number of the tested functions and the number of the functions to be tested, an execution coverage is generated and added to the test report.
[0028] Optionally, generating a test report includes:
[0029] Acquire the tested logic branches of each of the functions to be tested based on the test results;
[0030] Based on the tested logic branches and the to-be-tested logic branches of each of the to-be-tested functions, conditional coverage is generated and added to the test report.
[0031] Optionally, the function to be tested includes at least one of a charging and discharging function, a fault diagnosis, and a message interaction.
[0032] In a second aspect, the present invention provides a testing device for battery management software, which may include:
[0033] A first acquisition module, configured to acquire a test model of the battery management software to be tested based on a function to be tested of the battery management software to be tested;
[0034] A first generating module, configured to generate a plurality of test cases for the test model based on a preset test case format;
[0035] An input module, used for inputting the multiple test cases into the test model, and obtaining multiple test values output by the test model based on the multiple test cases;
[0036] The second generating module is used to generate a test result based on the reference value corresponding to each test case and the test value.
[0037] Optionally, the second generating module includes:
[0038] A comparison submodule, used to compare the reference value corresponding to each test case with the test value to obtain a test result;
[0039] A judgment submodule is used to judge whether each of the test results meets the preset test requirements and generate a test report;
[0040] The output submodule is used to output the test results that do not meet the preset test requirements to the display component for display when there are test results that do not meet the preset test requirements.
[0041] Optionally, the device further comprises:
[0042] A determination module, used to determine the function to be modified of the battery management software to be tested based on the test result that does not meet the preset test requirement;
[0043] The modification module is used to modify the software code corresponding to the function to be modified to obtain an updated battery management software to be tested.
[0044] Optionally, the device further comprises:
[0045] A second acquisition module, used to acquire the updated test model of the battery management software to be tested as a new test model;
[0046] An execution module is used to re-execute the operation of associating the preset data set with the test model for the new test model.
[0047] Optionally, the device further comprises:
[0048] A storage module, used for storing the plurality of test cases into a preset data set;
[0049] The input module is specifically used to associate the preset data set with the test model, so as to obtain the multiple test cases from the preset data set and input them into the test model.
[0050] Optionally, the second generating module includes:
[0051] A third acquisition submodule, configured to acquire a tested function among the functions to be tested based on the test result;
[0052] The fourth generating submodule is used to generate execution coverage based on the number of the tested functions and the number of the functions to be tested and add it to the test report.
[0053] Optionally, the second generating module includes:
[0054] A fourth acquisition submodule, used for acquiring tested logic branches of each of the functions to be tested based on the test results;
[0055] The fifth generating submodule is used to generate conditional coverage based on the tested logic branches and the to-be-tested logic branches of each of the to-be-tested functions and add it to the test report.
[0056] Optionally, the function to be tested includes at least one of a charging and discharging function, a fault diagnosis, and a message interaction.
[0057] In a third aspect, the present invention provides an electronic device comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method described in the first aspect when executing the program.
[0058] In a fourth aspect, the present invention provides a readable storage medium, which, when instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to execute the method described in the first aspect above.
[0059] The test method for battery management software provided in the embodiment of the present invention obtains the test model of the battery management software to be tested based on the test function of the battery management software to be tested; generates multiple test cases for the test model based on a preset use case format; inputs the multiple test cases into the test model, and obtains multiple test values output by the test model based on the multiple test cases; and generates test results based on the reference values corresponding to each test case and the test values. In this way, by obtaining the test model of the software and generating multiple test cases for the test model based on the preset use case format, there is no need to manually write test cases, which greatly reduces labor costs and improves test efficiency. At the same time, by using test cases to test the test model, test errors caused by subjective factors are reduced, and accurate test results can be obtained based on the test values and reference values output by the test model to ensure the accuracy of the test. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0061] Figure 1 is a flowchart of a method for testing battery management software provided by an embodiment of the present invention;
[0062] Figure 2 It is a schematic diagram of a testing process in the related art;
[0063] Figure 3 is a schematic diagram of another testing method provided by an embodiment of the present invention;
[0064] Figure 4 is a structural diagram of a battery management software testing device provided by an embodiment of the present invention;
[0065] Figure 5 It is a structural diagram of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0066] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0067] Figure 1FIG. 1 is a flow chart of the steps of a battery management software testing method provided by an embodiment of the present invention. Figure 1 As shown, the method may include the following steps:
[0068] Step 101: Based on the function to be tested of the battery management software to be tested, a test model of the battery management software to be tested is obtained.
[0069] Step 102: Generate multiple test cases for the test model based on a preset test case format.
[0070] Step 103: input the multiple test cases into the test model, and obtain multiple test values output by the test model based on the multiple test cases.
[0071] Step 104: Generate a test result based on the reference value corresponding to each test case and the test value.
[0072] With respect to the above steps 101 to 104, the embodiment of the present invention can be applied to any battery management system software that has a testing requirement, which can be a battery management software with a preliminary design or a battery management software with an operating abnormality. It can be used as a battery management software to be tested according to actual needs, and the embodiment of the present invention does not impose any restrictions on this.
[0073] The battery management software to be tested may be an application of the BMS system, which includes the operation logic of the BMS system and various functions that can be realized. Accordingly, the function to be tested refers to the software function that needs to be tested by the battery management software to be tested, which may be at least one of the charging and discharging function, the fault diagnosis function and the message interaction function.
[0074] The above test model refers to an abstract model of the software, which can simulate the system behavior of the battery management software to be tested, so that the model-in-the-loop and software-in-the-loop testing can be realized through the test model. Specifically, the above test model can be artificially built, can be pre-built by relevant testers based on the functions to be tested, or can be built by calling simulation tools, such as the unit testing framework (UnitTesting) in the matrix laboratory (matrix&laboratory, MATLAB), which can simulate the real test environment.
[0075] Among them, the above-mentioned preset use case format can be pre-set, and there can be multiple preset use case formats. For different functions to be tested, the corresponding preset use case formats may be different. For example, for the test of the interface data overflow function of 16-bit unsigned integer (UINT16), the preset use case format can be set to an integer, and then 0, -1, 65535, 100 and other values containing normal data, boundary data and abnormal data can be generated as test cases based on the preset use case format.
[0076] Specifically, the above operation of generating test cases can be implemented by a pre-written script, which can be an M script composed of MATLAB command lines. A preset case format can be set in the M script, and multiple random test cases can be generated based on the M script.
[0077] Among them, the above-mentioned reference value can be pre-generated based on each test case and / or the function to be tested, which refers to the expected output value. Further, the generated test case can be input into the test model to obtain the test value output by the test model based on each test case. It can be understood that when each function of the test model is normal, the output test value should be consistent with the expected output value, then the embodiment of the present invention can generate a test result based on the reference value and test value corresponding to each test case.
[0078] For example, taking the test function of the interface data overflow function of the above UINT16 as an example, its reference value is [0, 65535]. If the test value belongs to this interval, it is confirmed that the function test has passed. Correspondingly, if the test value does not belong to this interval, it is confirmed that the function test has failed.
[0079] Optionally, in some cases, the software also has some customized logical judgment functions, such as thermal runaway failures, etc. These judgment functions cannot generate test cases based on the preset use case format. The embodiment of the present invention can obtain logical judgment use cases set according to actual needs by receiving input information from relevant personnel.
[0080] Furthermore, the above logic judgment case can be combined with the test case generated in the above step 102 to obtain a target test case set, and the test model can be tested using the target test case set.
[0081] In summary, in an embodiment of the present invention, a test model of the battery management software to be tested is obtained based on the test function of the battery management software to be tested; multiple test cases are generated for the test model based on a preset use case format; the multiple test cases are input into the test model, and multiple test values output by the test model based on the multiple test cases are obtained; and test results are generated based on reference values corresponding to each test case and the test values. In this way, by obtaining the test model of the software and generating multiple test cases for the test model based on a preset use case format, there is no need to manually write test cases, which greatly reduces labor costs and improves test efficiency. At the same time, by using test cases to test the test model, test errors caused by subjective factors are reduced, and accurate test results can be obtained based on the test values and reference values output by the test model to ensure the accuracy of the test.
[0082] Optionally, the operation of generating a test result based on the reference value corresponding to each test case and the test value may specifically include:
[0083] S1041. Compare the reference value corresponding to each test case with the test value to obtain a test result.
[0084] S1042: Determine whether each of the test results meets the preset test requirements, and generate a test report.
[0085] S1043. When there is a test result that does not meet the preset test requirement, output the test result that does not meet the preset test requirement to a display component for display.
[0086] The above test requirements may be pre-set, and the test requirements for different functions to be tested may be different, which is not limited in the embodiment of the present invention. Specifically, in one case, the above test requirements may be that the test value is consistent with the reference value, or that the test value does not exceed the range of the reference value. Specifically, in the case of a test result that does not meet the test requirements, it indicates that there is a problem with the battery management software, and the problem needs to be solved in a timely manner.
[0087] The display component can be any screen with a display function, and can be a display of a terminal. The display component can be connected to the electronic device applied by the embodiment of the present invention by hardware or software, and the test results that do not meet the test requirements can be output to the display component for display. The relevant testers can promptly learn about the software functions with problems through the display component, and can solve the problems in a timely manner.
[0088] Optionally, the embodiment of the present invention may further include:
[0089] S1044: Based on the test result that does not meet the preset test requirement, determine the function to be modified of the battery management software to be tested.
[0090] S1045: Modify the software code corresponding to the function to be modified to obtain updated battery management software to be tested.
[0091] The above-mentioned function to be modified refers to a software function with problems, which can be determined based on the test results, and the software function with problems can be obtained based on the test results that do not meet the preset test requirements as the function to be modified. Further, the above-mentioned function to be modified can be determined by receiving input information from relevant testers after outputting the test results that do not meet the preset test requirements, or can also be directly determined based on the test results, which is not limited in the embodiment of the present invention.
[0092] The software code mentioned above refers to the code contained in the battery management software to be tested. Correspondingly, the software code corresponding to the function to be modified refers to the code used to implement the function to be modified in the BMS software to be tested. Specifically, the function to be modified refers to the software function with problems. At this time, the corresponding software code can be modified to optimize the software and obtain the updated BMS software.
[0093] For example, taking the problem of the battery thermal runaway fault function as an example, if the judgment statement code in the code is shielded and the judgment statement of the fault is not executed, it will cause the actual situation to meet the thermal runaway reporting conditions during BMS operation, but the BMS software does not perform fault judgment, resulting in the failure to implement the battery thermal runaway fault reporting function, which poses a certain safety risk. At this time, the embodiment of the present invention can modify the software code corresponding to the battery thermal runaway fault function, open the code shielding therein, prevent mis-shielding, and obtain the updated BMS software.
[0094] As another example, taking the problem of battery status judgment function as an example, when the BMS has charging current, it is misjudged as discharging state, which may cause overcharging or overdischarging of the battery, etc., affecting battery performance. Then, the embodiment of the present invention can modify the logic code of status judgment based on the test results to obtain an updated BMS software.
[0095] Specifically, the above code modification operation can be implemented by receiving input information from relevant testers. The software code corresponding to the function to be modified can be output to the display component for display, and the input code of the relevant testers can be received, and the original software code can be replaced by the input code.
[0096] In this way, problematic software functions can be modified in a timely manner to ensure the normal operation of the BMS software.
[0097] The test report may include statistical data such as the number, type, test coverage, and test performance of test results that do not meet the requirements. Optionally, the test report may also include information such as the test function, test date, execution time of each test case (including start time and end time), complexity, code coverage (Modified Condition / Decision Coverage, MCDC), execution coverage, model step length, etc. The table items required for the test report may be pre-set, and then the test report may be generated based on the pre-set table items.
[0098] In the embodiment of the present invention, the display component can provide real-time feedback on problematic test results, which is convenient for testers to find and solve problems in a timely manner, and can improve the overall efficiency of software development. At the same time, the test report generated by the test results can provide data support and decision-making basis for testers, which is helpful to evaluate the quality and performance of battery management software.
[0099] Optionally, after generating multiple test cases for the test model based on the preset test case format, the embodiment of the present invention may further include:
[0100] S21. Store the multiple test cases into a preset data set.
[0101] The operation of inputting the plurality of test cases into the test model may specifically include:
[0102] S22: Associating the preset data set with the test model to obtain the multiple test cases from the preset data set and input them into the test model.
[0103] Among them, the above-mentioned preset data set can be a pre-created folder, and the storage path of the preset data set can be pre-stored, and then the embodiment of the present invention can obtain the preset data set through the storage path, and store the generated test cases in the preset data set through the storage path.
[0104] Specifically, the above-mentioned association operation refers to enabling the test model to obtain the storage location of the test case. The association can be performed through the MATLAB tool, and the storage path of the preset data set can be set as the input path of the test model, so that the test cases stored in the preset data set can be input into the test model.
[0105] In the embodiment of the present invention, the plurality of test cases are stored in a preset data set; the preset data set is associated with the test model, so as to obtain the plurality of test cases from the preset data set and input them into the test model. In this way, the generated test cases can be obtained from the preset data set in real time and input into the test model, thus avoiding the problem of manual input during manual testing, and enabling the test model to complete the execution of multiple test cases in a short time, further reducing the manpower and time costs required, and improving the test efficiency.
[0106] Optionally, the embodiment of the present invention may further include:
[0107] S31, obtaining the updated test model of the battery management software to be tested as a new test model.
[0108] S32: for the new test model, the operation of associating the preset data set with the test model is performed again.
[0109] The update operation may be an optimization of the problematic function items in the test results, and may also include the iteration of the BMS software, which is not limited in the embodiment of the present invention. Specifically, since the software functions are often updated after the update operation, in order to ensure the timeliness of the test, the embodiment of the present invention may obtain the updated test model of the software to be tested as a new test model. At the same time, for the new test model, the operation of inputting multiple test cases into the test model is performed again.
[0110] Specifically, the embodiment of the present invention can use MATLAB to rebuild the corresponding test model as a new test model for the updated software to be tested, or can also add corresponding update items to the original test model based on the update items to obtain a new test model, which can be set according to the actual update operation, and the embodiment of the present invention does not limit this.
[0111] Furthermore, the embodiment of the present invention can store the above-mentioned test cases and test results, and then after obtaining a new test model, the stored test cases can be associated with the new test model to test the new test model, so that regression testing can be implemented to ensure whether the original functions of the updated software to be tested are running normally.
[0112] In the embodiment of the present invention, the battery management software to be tested is updated to obtain the updated software to be tested; the test model of the updated software to be tested is obtained as a new test model; and the operation of associating the preset data set with the test model is performed again for the new test model. In this way, it can be ensured that during the update and iteration process of the battery management software, regression testing can be conveniently performed on it to ensure that the new software does not destroy the original function, thereby improving the stability and reliability of the software.
[0113] Optionally, the operation of generating a test report in the embodiment of the present invention may specifically include:
[0114] S41. Acquire a tested function among the functions to be tested based on the test result.
[0115] S42: Generate execution coverage based on the number of the tested functions and the number of the functions to be tested and add it to the test report.
[0116] Among them, the above test results may include comparison results of the test values of each test case with the reference value, and the reference value is pre-set based on the function to be tested. Therefore, the embodiment of the present invention can determine the tested function as the tested function based on the reference value in the test results.
[0117] Furthermore, the above-mentioned execution coverage refers to the proportion of software functions that have been tested during the test period, so that the embodiment of the present invention can generate execution coverage and add it to the test report based on the number of tested functions and the number of functions to be tested.
[0118] In the embodiment of the present invention, the tested functions in the functions to be tested are obtained based on the test results; and the execution coverage is generated and added to the test report based on the number of the tested functions and the number of the functions to be tested. In this way, a more comprehensive and complete test report can be generated through the execution coverage.
[0119] Optionally, the operation of generating a test report in the embodiment of the present invention may specifically include:
[0120] S51 . Obtain a tested logic branch of each of the functions to be tested based on the test result.
[0121] S52: Generate conditional coverage based on the tested logic branches and the to-be-tested logic branches of each to-be-tested function and add it to a test report.
[0122] Among them, the above-mentioned logical branch refers to the logical transfer condition included in the function of logical judgment. For example, there are some functions which execute the first operation when the input data is true, and execute the second operation when the input data is false. In order to ensure the comprehensiveness of the test, it is often necessary to make the input data true at least once and the input data false at least once during the test process.
[0123] The condition coverage is used to characterize the coverage of the logic test. The embodiment of the present invention can obtain the logic transfer conditions of the functions of the logic judgment that have been tested from the test values and reference values in the test results as the tested logic branches. Specifically, since different logic branches correspond to different reference values, the embodiment of the present invention can determine the tested logic branches from the reference values in the test results.
[0124] Furthermore, the above-mentioned logic branch to be tested may be obtained in advance through the logic operator module of the function to be tested, or may be obtained by performing a logic analysis on the test model by MATLAB, which is not limited in the embodiment of the present invention.
[0125] Furthermore, conditional coverage can be generated by the ratio of the number of tested logic branches to the number of logic branches to be tested.
[0126] In the embodiment of the present invention, the tested logic branches of each function to be tested are obtained based on the test results; based on the tested logic branches and the tested logic branches of each function to be tested, conditional coverage is generated and added to the test report. In this way, a more comprehensive and complete test report can be generated through conditional coverage, thereby improving the evaluation index for the test results.
[0127] Figure 2 It is a schematic diagram of a test process in the related art, such as Figure 2As shown in the figure, general battery management system software usually relies on the experience and skills of testers, conducts demand analysis and specifies test plans, writes test cases according to the test plans, performs tests, analyzes test results, and completes test reports by hand. In battery management systems, there are often many application layer modules, and there are many strategies and requirements. It is difficult for software testing to record complete defect content, such as detection time, system environment, serious programs, program versions, functional modules, problem descriptions, detailed input and output interfaces, problem reproduction, etc. At the same time, software testers re-execute previous test cases after software updates to ensure that the newly introduced changes do not damage the original functions. The regression test step will take a lot of time and manpower, and the test results may be inaccurate test operations depending on the mental state of the tester. It is difficult to ensure the comprehensiveness and accuracy of the test. The preparation of test data is also a tedious and time-consuming task, especially for complex systems. In fact, the time spent on retesting is high because manual test cases have no memory.
[0128] The embodiment of the present invention provides an automatic testing method for battery management software. Figure 3 is a schematic diagram of another testing method provided by an embodiment of the present invention, such as Figure 3 As shown, the embodiment of the present invention can realize automated testing by constructing a test model, generating test cases, and using the test cases to test the test model. At the same time, a test report can be generated, and automated test analysis can be realized by analyzing the test report and performing iterations.
[0129] Optionally, the above test report may include execution coverage, decision coverage, and condition coverage, etc. Among them, for each project, execution coverage determines whether the project is executed during simulation. For each project, decision coverage is used to determine the percentage of the total number of simulation paths of the project traversed by simulation. Condition coverage analysis outputs modules whose inputs are logical combinations of logic operator modules and state transitions. When the test case causes each input of each instance of the logic module in the model and each condition of the transition to be true at least once during simulation and false at least once during simulation, the test case can achieve full coverage. Condition coverage analysis reports whether the test case fully covers each module in the model. For example: If a short-circuit logic module is specified, 100% condition coverage of the module may not be achieved by selecting to treat the logic module as a short circuit in the coverage pane of the configuration parameters. Modules that output logical combinations of their inputs and state transitions can be analyzed to determine the extent to which the test case tests the independence of the logic module inputs and transition conditions.
[0130] Exemplarily, the embodiment of the present invention can use the model-in-the-loop or software-in-the-loop test tool in the visualization tool (SIMULINK) model in MATLAB, which can simulate the real environment and realize more comprehensive testing. The embodiment of the present invention can pre-equip any electronic device with MATLAB and the version and settings of the required toolbox. Further, a SIMULINK model can be built for the application layer of the battery management team to be tested, and a test case can be generated based on the test of the baseline mode (Baseline), and the test case (Test Case) can be stored in the test data set (Test Suite), and then the test model can be tested by the test case in the test data set.
[0131] Optionally, the embodiment of the present invention may also pre-set a table item required in the test report, and then generate a test report containing the content of the table item based on the table item.
[0132] In summary, the battery management software testing method provided in the embodiment of the present invention can automatically generate test cases by constructing a system model, thereby reducing the test preparation time. The test model can cover all the functions to be tested and possible usage scenarios of the system to ensure the comprehensiveness of the test. Model-based testing can accurately evaluate the functions and performance of the system and provide reliable test results. The efficiency, comprehensiveness and accuracy of the test are ensured.
[0133] At the same time, automated testing can support the parallel execution of multiple test scripts, further improving test efficiency. This means that multiple test cases can be run in different test environments at the same time, significantly shortening the test cycle. Automated testing reduces test errors and omissions caused by human factors and improves the accuracy and reliability of testing. Test scripts are executed according to predetermined steps and conditions, avoiding errors caused by testers' fatigue, negligence or subjective judgment. Automated testing can be repeatedly executed under the same environment and conditions to ensure the consistency and repeatability of test results. This helps identify potential problems and defects in the software and improve the overall quality of the software.
[0134] Figure 4 is a structural diagram of a battery management software testing device provided by an embodiment of the present invention, such as Figure 4 As shown, the device 20 may include:
[0135] A first acquisition module 201 is used to acquire a test model of the battery management software to be tested based on the function to be tested of the battery management software to be tested;
[0136] A first generating module 202, configured to generate a plurality of test cases for the test model based on a preset test case format;
[0137] An input module 203, used for inputting the multiple test cases into the test model, and obtaining multiple test values output by the test model based on the multiple test cases;
[0138] The second generating module 204 is used to generate a test result based on the reference value corresponding to each test case and the test value.
[0139] Optionally, the second generating module includes:
[0140] A comparison submodule, used to compare the reference value corresponding to each test case with the test value to obtain a test result;
[0141] A judgment submodule is used to judge whether each of the test results meets the preset test requirements and generate a test report;
[0142] The output submodule is used to output the test results that do not meet the preset test requirements to the display component for display when there are test results that do not meet the preset test requirements.
[0143] Optionally, the device further comprises:
[0144] A determination module, used to determine the function to be modified of the battery management software to be tested based on the test result that does not meet the preset test requirement;
[0145] The modification module is used to modify the software code corresponding to the function to be modified to obtain an updated battery management software to be tested.
[0146] Optionally, the device further comprises:
[0147] A second acquisition module, used to acquire the updated test model of the battery management software to be tested as a new test model;
[0148] An execution module is used to re-execute the operation of associating the preset data set with the test model for the new test model.
[0149] Optionally, the device further comprises:
[0150] A storage module, used for storing the plurality of test cases into a preset data set;
[0151] The input module is specifically used to associate the preset data set with the test model, so as to obtain the multiple test cases from the preset data set and input them into the test model.
[0152] Optionally, the second generating module 204 includes:
[0153] A third acquisition submodule, configured to acquire a tested function among the functions to be tested based on the test result;
[0154] The fourth generating submodule is used to generate execution coverage based on the number of the tested functions and the number of the functions to be tested and add it to the test report.
[0155] Optionally, the second generating module 204 includes:
[0156] A fourth acquisition submodule, used for acquiring tested logic branches of each of the functions to be tested based on the test results;
[0157] The fifth generating submodule is used to generate conditional coverage based on the tested logic branches and the to-be-tested logic branches of each of the to-be-tested functions and add it to the test report.
[0158] Optionally, the function to be tested includes at least one of a charging and discharging function, a fault diagnosis, and a message interaction.
[0159] In summary, the test device for battery management software provided in the embodiment of the present invention obtains the test model of the battery management software to be tested based on the test function of the battery management software to be tested; generates multiple test cases for the test model based on a preset use case format; inputs the multiple test cases into the test model, and obtains multiple test values output by the test model based on the multiple test cases; and generates test results based on the reference values corresponding to each test case and the test values. In this way, by obtaining the test model of the software and generating multiple test cases for the test model based on the preset use case format, there is no need to manually write test cases, which greatly reduces labor costs and improves test efficiency. At the same time, by using test cases to test the test model, test errors caused by subjective factors are reduced, and accurate test results can be obtained based on the test values and reference values output by the test model to ensure the accuracy of the test.
[0160] The present invention also provides an electronic device, see Figure 5 , including: a processor 301, a memory 302, and a computer program 3021 stored in the memory and executable on the processor, wherein the processor implements the test method of the battery management software of the aforementioned embodiment when executing the program.
[0161] The present invention also provides a readable storage medium, when the instructions in the storage medium are executed by the processor of the electronic device, the electronic device can execute the test method of the battery management software of the aforementioned embodiment.
[0162] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0163] The algorithm and display provided herein are not inherently related to any particular computer, virtual system or other device. Various general purpose systems can also be used together with the teachings based on this. According to the above description, it is obvious that the structure required for constructing such systems. In addition, the present invention is not directed to any specific programming language either. It should be understood that various programming languages can be utilized to realize the content of the present invention described herein, and the description of the above specific languages is for disclosing the best mode of the present invention.
[0164] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.
[0165] Similarly, it should be understood that in order to streamline the present invention and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the present invention, the various features of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, this disclosed method should not be interpreted as reflecting the following intention: that the claimed invention requires more features than the features explicitly recited in each claim. More specifically, as reflected in the claims below, inventive aspects lie in less than all the features of the individual embodiments disclosed above. Therefore, the claims that follow the specific embodiment are hereby expressly incorporated into the specific embodiment, with each claim itself serving as a separate embodiment of the present invention.
[0166] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and in addition they may be divided into a plurality of submodules or subunits or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive, all features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this manner may be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.
[0167] The various component embodiments of the present invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that a microprocessor or digital signal processor (DSP) may be used in practice to implement some or all of the functions of some or all of the components in the sorting device according to the present invention. The present invention may also be implemented as a device or apparatus program for executing part or all of the methods described herein. Such a program for implementing the present invention may be stored on a computer-readable medium, or may be in the form of one or more signals. Such a signal may be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.
[0168] It should be noted that the above embodiments illustrate the present invention rather than limit it, and that those skilled in the art may devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets shall not be construed as a limitation on the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "one" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention may be implemented by means of hardware comprising a number of different elements and by means of a suitably programmed computer. In a unit claim enumerating a number of devices, several of these devices may be embodied by the same hardware item. The use of the words first, second, and third, etc., does not indicate any order. These words may be interpreted as names.
[0169] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0170] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
[0171] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A method for testing battery management software, characterized in that: The method comprises: Based on the to-be-tested function of the to-be-tested battery management software, obtaining a test model of the to-be-tested battery management software; Generate multiple test cases for the test model based on a preset test case format; Inputting the multiple test cases into the test model, and obtaining multiple test values output by the test model based on the multiple test cases; A test result is generated based on the reference value corresponding to each test case and the test value.
2. The method according to claim 1, characterized in that The generating of the test result based on the reference value corresponding to each test case and the test value includes: Compare the reference value corresponding to each test case with the test value to obtain a test result; Determine whether each of the test results meets the preset test requirements and generate a test report; In the case that there are test results that do not meet the preset test requirements, the test results that do not meet the preset test requirements are output to the display component for display.
3. The method according to claim 2, characterized in that The method further comprises: Based on the test results that do not meet the preset test requirements, determine the functions to be modified of the battery management software to be tested; The software code corresponding to the function to be modified is modified to obtain updated battery management software to be tested.
4. The method according to claim 3, characterized in that The method further comprises: Acquire the updated test model of the battery management software to be tested as a new test model; For the new test model, the operation of inputting the plurality of test cases into the test model is performed again.
5. The method according to claim 1, characterized in that After generating a plurality of test cases for the test model based on the preset test case format, the method further includes: Storing the multiple test cases in a preset data set; The step of inputting the plurality of test cases into the test model comprises: The preset data set is associated with the test model to obtain the multiple test cases from the preset data set and input them into the test model.
6. The method according to claim 2, characterized in that The generating of the test report includes: Acquire a tested function among the functions to be tested based on the test result; Based on the number of the tested functions and the number of the functions to be tested, an execution coverage is generated and added to the test report.
7. The method according to claim 2, characterized in that The generating of the test report includes: Acquire the tested logic branches of each of the functions to be tested based on the test results; Based on the tested logic branches and the to-be-tested logic branches of each of the to-be-tested functions, conditional coverage is generated and added to the test report.
8. The method according to any one of claims 1 to 7, characterized in that: The function to be tested includes at least one of a charging and discharging function, a fault diagnosis, and a message interaction.
9. A battery management software testing device, characterized in that: The device comprises: A first acquisition module, configured to acquire a test model of the battery management software to be tested based on a function to be tested of the battery management software to be tested; A first generating module, configured to generate a plurality of test cases for the test model based on a preset test case format; An input module, used for inputting the multiple test cases into the test model, and obtaining multiple test values output by the test model based on the multiple test cases; The second generating module is used to generate a test result based on the reference value corresponding to each test case and the test value.
10. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 8 when executing the program.
11. A readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method according to any one of claims 1 to 8.