Test script generation method, bms product testing method, and electronic device

By automating the generation of BMS test scripts, the problems of low efficiency and insufficient reliability in BMS test case entry in existing technologies are solved, achieving efficient and reliable BMS testing and reducing the dependence on the experience of test engineers.

CN122173409APending Publication Date: 2026-06-09LIGOO (SHAN DONG) NEW ENERGY TECHNOLOGY CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
LIGOO (SHAN DONG) NEW ENERGY TECHNOLOGY CO LTD
Filing Date
2026-05-11
Publication Date
2026-06-09

AI Technical Summary

Technical Problem

In existing BMS product testing, test case entry is inefficient and relies on human experience, resulting in insufficient reliability of test conclusions. Furthermore, automated testing depends on the professional experience of test engineers, which is also inefficient.

Method used

An automated test script generation method is used to generate script generation information based on the product information of the BMS product under test. This includes extracting signal, operation, and instruction sets from the DBC file, combining interface mapping relationships and reference test cases, generating and verifying the initial test script until it meets the requirements.

Benefits of technology

It has achieved automation and reliability improvement in BMS testing, reduced reliance on the experience of test engineers, improved testing efficiency and reliability, and ensured the accuracy and adaptability of test scripts.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122173409A_ABST
    Figure CN122173409A_ABST
Patent Text Reader

Abstract

This invention discloses a test script generation method, a BMS product testing method, and an electronic device, relating to the field of BMS technology. The method includes: generating script generation information for pre-configured test cases based on product information of the BMS product under test; generating an initial test script based on the script generation information and validating the initial test script; if the initial test script fails validation, generating new script generation information based on the initial test script and returning to the step of generating the initial test script based on the script generation information; if the initial test script passes validation, using the initial test script as the test script for the BMS product under test. This improves the efficiency and reliability of BMS testing and reduces the reliance on experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of BMS (Battery Management System) technology, and in particular to a test script generation method, a BMS product testing method, and electronic equipment. Background Technology

[0002] As a critical control unit in new energy battery systems, the quality testing of the Battery Management System (BMS) directly impacts the operational safety and reliability of the entire system. However, in related technologies, BMS product testing requires test cases to be entered into the BMS test bench's host computer parameter configuration interface. Currently, this is primarily achieved through manual input or partial extraction. However, handling a large number of BMS test cases (typically thousands) is labor-intensive, inefficient, and prone to omissions, leading to unreliable test results. Furthermore, automated BMS test bench testing involves processing various information, such as machine instructions, DBC signals, test procedures, and BMS interface parameters. Test cases need to be instantiated using this information, a process highly dependent on the professional experience of test engineers. Therefore, BMS product testing in related technologies relies heavily on manual experience, resulting in low efficiency and reliability. Summary of the Invention

[0003] This invention aims to at least partially address one of the technical problems in related technologies. Therefore, the first objective of this invention is to propose a test script generation method to achieve automated test script generation, improve the efficiency and reliability of BMS testing, and reduce the reliance on experience.

[0004] The second objective of this invention is to provide a BMS product testing method.

[0005] The third objective of this invention is to provide an electronic device.

[0006] To achieve the above objectives, a first aspect of the present invention provides a test script generation method, characterized in that the method includes: generating script generation information for pre-configured test cases based on product information of the BMS product under test; generating an initial test script based on the script generation information and verifying the initial test script; when the initial test script fails verification, generating new script generation information based on the initial test script and returning to the step of generating the initial test script based on the script generation information; when the initial test script passes verification, using the initial test script as the test script for the BMS product under test.

[0007] In addition, the test script generation method according to embodiments of the present invention may also have the following additional technical features: According to one embodiment of the present invention, the step of generating script generation information for pre-configured test cases based on product information of the BMS product under test includes: extracting configuration fields from the test cases; extracting configuration field information from the product information based on the configuration fields; and generating script generation information corresponding to the test cases based on the configuration field information.

[0008] According to one embodiment of the present invention, the product information includes the DBC (DatabaseCAN, Controller Area Network Database) file of the BMS product under test, and the step of generating script generation information corresponding to the test cases based on the configuration field information includes: obtaining the test case information of the test cases based on the DBC file; and generating the script generation information based on the test case information and the configuration field information.

[0009] According to an embodiment of the present invention, obtaining the test case information of the test case based on the DBC file includes: filtering a first signal set from the DBC file, wherein the first signal set includes a first message name, a first signal name, and first parameter information corresponding to the test case; and using the first signal set as the test case information.

[0010] According to an embodiment of the present invention, obtaining the test case information of the test case based on the DBC file includes: filtering a second signal set from the DBC file, wherein the second signal set includes a second message name, a second signal name, and second parameter information corresponding to the test case; filtering a first operation set corresponding to the test case and the second signal set from a pre-configured operation set; and using the second signal set and the first operation set as the test case information.

[0011] According to an embodiment of the present invention, obtaining the test case information of the test case based on the DBC file includes: filtering a third signal set from the DBC file, wherein the third signal set includes a third message name, a third signal name, and third parameter information corresponding to the test case; filtering a second operation set corresponding to the test case and the third signal set from a pre-configured operation set; filtering an instruction set corresponding to the test case and the second operation set from a pre-configured instruction set; and using the third signal set, the second operation set, and the instruction set as the test case information.

[0012] According to an embodiment of the present invention, generating the script generation information based on the use case information and the configuration field information includes: obtaining a target reference test case corresponding to the test case based on a pre-configured set of reference test cases; obtaining template input information based on the test case, the configuration field information, the use case information, the target reference test case, and the interface mapping relationship, wherein the interface mapping relationship is the mapping relationship between the interface of the BMS product under test and the interface of the test bench, and the test bench is the test bench used to test the BMS product under test; and filling the template input information into a pre-configured script generation information template to obtain the script generation information.

[0013] According to an embodiment of the present invention, the verification of the initial test script includes: parsing the initial test script to obtain script information of the initial test script; verifying the script information according to the DBC file and the instruction set; and determining that the initial test script has failed verification in response to the script information failing verification.

[0014] According to an embodiment of the present invention, the step of verifying the initial test script further includes: in response to the script information passing the verification, matching the test steps in the initial test script with the test cases to obtain a matching result of the test steps and the test cases; when the matching result is a mismatch, determining that the initial test script has failed the verification; when the matching result is a match, determining that the initial test script has passed the verification.

[0015] According to an embodiment of the present invention, the step of generating new script generation information based on the initial test script includes: obtaining the reason for verification failure; generating new script generation information based on the reason for verification failure, the initial test script, the configuration field information, the test case information, the target reference test case, and the interface mapping relationship, wherein the target reference test case is a test case corresponding to the test case obtained from a pre-configured set of reference test cases, the interface mapping relationship is the mapping relationship between the interface of the BMS product under test and the interface of the test bench, and the test bench is a test bench for testing the BMS product under test.

[0016] To achieve the above objectives, a second aspect of the present invention provides a BMS product testing method, the method comprising: generating a BMS test script for the BMS product to be tested, wherein the BMS test script is a test script generated according to the test script generation method of the above embodiment; and testing the BMS product to be tested according to the BMS test script.

[0017] To achieve the above objectives, a third aspect of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and running on the processor. When the computer program is executed by the processor, it implements the test script generation method of the above embodiments, or implements the BMS product testing method of the above embodiments.

[0018] According to embodiments of the present invention, a test script generation method, a BMS product testing method, and an electronic device generate script generation information for pre-configured test cases based on product information of the BMS product under test; generate an initial test script based on the script generation information and verify the initial test script; if the initial test script fails verification, generate new script generation information based on the initial test script and return to the step of generating the initial test script based on the script generation information; if the initial test script passes verification, use the initial test script as the test script for the BMS product under test. Thus, automatic test script generation can be achieved, improving the efficiency and reliability of BMS testing and reducing the reliance on experience.

[0019] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description

[0020] Figure 1 This is a flowchart of the test script generation method according to an embodiment of the present invention; Figure 2 This is a flowchart of a BMS product testing method according to an embodiment of the present invention; Figure 3 This is a flowchart of a BMS product testing method according to an embodiment of the present invention; Figure 4 This is a structural block diagram of an electronic device according to an embodiment of the present invention. Detailed Implementation

[0021] The test script generation method, BMS product testing method, and electronic device of the present invention are described below with reference to the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described with reference to the accompanying drawings are exemplary and should not be construed as limiting the present invention.

[0022] Figure 1 This is a flowchart of a test script generation method according to an embodiment of the present invention.

[0023] like Figure 1 As shown, the test script generation method includes: S11, Generate scripts for pre-configured test cases based on the product information of the BMS product under test.

[0024] The above-mentioned script generation information for pre-configured test cases based on the product information of the BMS product under test includes: extracting configuration fields from the test cases; extracting configuration field information from the product information based on the configuration fields; and generating script generation information corresponding to the test cases based on the configuration field information.

[0025] The aforementioned product information includes the DBC file of the BMS product under test. Based on the configuration field information, script generation information corresponding to the test cases is generated, including: obtaining the test case information from the DBC file; and generating script generation information based on the test case information and configuration field information.

[0026] The test case information is obtained from the DBC file, including: filtering the first signal set from the DBC file, wherein the first signal set includes the first message name, the first signal name and the first parameter information corresponding to the test case; and the first signal set is used as the test case information.

[0027] Alternatively, test case information can be obtained from the DBC file, including: filtering a second signal set from the DBC file, wherein the second signal set includes a second message name, a second signal name, and second parameter information corresponding to the test case; filtering a first operation set corresponding to the test case and the second signal set from a pre-configured operation set; and using the second signal set and the first operation set as test case information.

[0028] Alternatively, test case information can be obtained from the DBC file, including: filtering a third signal set from the DBC file, wherein the third signal set includes a third message name, a third signal name, and third parameter information corresponding to the test case; filtering a second operation set corresponding to the test case and the third signal set from a pre-configured operation set; filtering an instruction set corresponding to the test case and the second operation set from a pre-configured instruction set; and using the third signal set, the second operation set, and the instruction set as test case information.

[0029] The script generation information is generated based on the test case information and configuration field information, including: obtaining the target reference test case corresponding to the test case based on the pre-configured reference test case set; obtaining template input information based on the test case, configuration field information, test case information, target reference test case, and interface mapping relationship, wherein the interface mapping relationship is the mapping relationship between the interface of the BMS product under test and the interface of the test bench, and the test bench is the test bench for testing the BMS product under test; and filling the template input information into the pre-configured script generation information template to obtain the script generation information.

[0030] The aforementioned third signal set, second signal set, and first signal set can be identical; the aforementioned second operation set and first operation set can be identical; the aforementioned third signal set, second signal set, and first signal set can be generated using the same method; and the aforementioned second operation set and first operation set can be generated using the same method.

[0031] The number of pre-configured test cases is at least one, so script generation information can be generated for each test case.

[0032] Furthermore, when generating script generation information, a pre-configured set of reference test cases can be used.

[0033] The following description uses examples of use case information including a third signal set, a second operation set, and an instruction set.

[0034] Based on the product information of the BMS product under test, at least one pre-configured test case, and a pre-configured set of reference test cases, at least one script generation information corresponding to at least one test case is generated. This includes: extracting configuration fields from the test cases and extracting configuration field information from the BMS product information based on the configuration fields; for each test case, obtaining the third signal set, second operation set, and instruction set corresponding to the test case based on the DBC file, and obtaining the target reference test case corresponding to the test case based on the set of reference test cases; and generating script generation information corresponding to the test cases based on the test cases, configuration field information, third signal set, second operation set, instruction set, target reference test case, and interface mapping relationship. Here, the interface mapping relationship is the mapping relationship between the interface of the BMS product under test and the interface of the test bench, and the test bench is the test bench used to test the BMS product under test.

[0035] Specifically, the product information mentioned above includes textual knowledge, which includes documents on the system principles, interface definitions, and related strategies (equalization, thermal runaway, current acquisition, BCU control, SOC correction, etc.) of the BMS product under test.

[0036] To obtain configuration field information, test cases are first input, and configuration fields are extracted from them using a combination of rules and a large model. Rules are common BMS configuration fields, such as battery pack rated voltage, battery pack rated current, individual cell voltage, and number of individual cells, matched using keywords and synonyms. The large model extracts configuration fields that depend on the specific test case and cannot be determined by rules. For example, for a test case testing "main and negative relay adhesion fault," "main and negative relay interface" needs to be extracted as a configuration field. This is achieved by writing configuration field extraction prompts and calling the large model, thus obtaining the fields that the test case needs to configure.

[0037] The final extracted configuration field names, for example, can be preset extracted fields such as single cell voltage value, number of battery strings, rated voltage value, rated power value, relay interface name, temperature sensor interface name, shunt interface name, etc.

[0038] By extracting configuration fields from test cases, we can determine which information needs to be extracted from the aforementioned text knowledge. Then, based on the configuration fields, we can extract information from the text knowledge to obtain the configuration field information.

[0039] Moreover, since the text data is large, directly using a large model for extraction is inefficient. Therefore, the text knowledge can be divided into paragraphs first, and then, based on each configuration field, keyword search methods can be used to sort the text in descending order of score to obtain the top 50 paragraphs of text for the large model. The large model can then extract the corresponding field values ​​to obtain the configuration field information.

[0040] For example, the final results may include a battery pack voltage of 416V, a single cell voltage of 3.3V, and a number of 126 batteries. The extraction results are stored in a dictionary structure.

[0041] The process involves obtaining the third signal set, the second operation set, and the instruction set corresponding to the test cases from the DBC file, including: filtering the message name, signal name, and parameter information corresponding to the test cases from the DBC file, and obtaining the third signal set based on the message name, signal name, and parameter information; filtering the pre-configured operation set to obtain the second operation set corresponding to the test cases and the third signal set; and filtering the pre-configured instruction set to obtain the instruction set corresponding to the test cases and the second operation set.

[0042] Specifically, firstly, all information in the DBC file is read, and combined with the content of the test cases, the test cases and the information in the DBC file are concatenated into the input of the pre-trained fourth language model through preset prompt words. The fourth language model outputs the message name, signal name and parameter information required for each test case, so that the message name, signal name and parameter information required for the above test cases can be used as the third signal set.

[0043] The above parameter information may include the message corresponding to the message name, the value range of each parameter in the signal corresponding to the signal name, and the specific meaning of each parameter value.

[0044] The aforementioned preset prompts can be pre-written templates. The test cases and information from the DBC file are filled into the templates, and the results are then input into the fourth language model to obtain the message name, signal name, and parameter information required for each test case.

[0045] The following example illustrates how the message names, signal names, and parameter information required by the above test cases constitute the third signal set.

[0046] As an example, assuming the message name is "VCU (Vehicle Control Unit) sends discharge request signal" and its corresponding parameter information is in the range of 0-255, then one signal in the third signal set can be obtained: "VCU sends discharge request signal, value range 0-255"; assuming the signal name is "BMS error level" and its corresponding parameter information is in the range of 0-255, then one signal in the third signal set can be obtained: "BMS error level, value range 0-255"; assuming the message name is "Discharge power limited due to fault" and its corresponding parameter information is in the range of 0-1, then one signal in the third signal set can be obtained: "Discharge power limited due to fault, value range 0-1".

[0047] It is also necessary to pre-compile operation sets, which can be done by professionals based on the operational information that the test benches testing the BMS product can understand. Moreover, only test statements that require the execution of multiple instructions need to be compiled; if a test statement in a test case can be directly converted into a single instruction, it does not need to be included in the operation set.

[0048] After obtaining the third signal set, since the statements in the test cases do not strictly correspond one-to-one with the test bench instructions, some test case statements need to be executed by combining multiple instructions. Furthermore, when writing test cases, continuous or repetitive instruction steps are often encapsulated into concise operation statements to improve the readability and efficiency of test case writing. Therefore, it is necessary to convert both the aforementioned test cases and the third signal set obtained from the test cases into operations within the pre-summarized operation set. This step can be implemented using a pre-trained fifth language model.

[0049] Specifically, for each test case, it can be associated with the aforementioned set of operations using the first prompt word template, input into the fifth model, and through semantic analysis, accurately map from the operation set to output the set of operation numbers required for the corresponding test case. The corresponding operation statements are obtained by parsing the operation numbers, forming the second set of operations for that test case. The aforementioned first prompt word template can be a pre-written template based on experience.

[0050] For the processing of the third signal set mentioned above, please refer to the test cases above.

[0051] It is also necessary to pre-organize the instruction set, that is, to obtain all the instructions supported by the test bench used and organize them into a structured table. The table should include the following fields: instruction name, function description, number of parameters, and type, default value, minimum value, and maximum value of each parameter.

[0052] After obtaining the second set of operations, for each test case and the second set of operations, it can be associated with a preset second prompt word template and input into a pre-trained sixth language model. Based on semantic understanding, this model identifies and outputs a set of instruction numbers applicable to the current test case and the second set of operations from the instruction set. By parsing the numbers, the complete information of the corresponding instructions is obtained, forming the instruction set required for that test case and the second set of operations. The aforementioned second prompt word template can be a template written in advance based on experience.

[0053] The instruction set must include complete attributes such as instruction name, number of parameters, parameter type, default value, value range, and function description.

[0054] It should be noted that, due to the complexity of BMS test cases (for example, some faults are triggered before high voltage is applied and others are triggered after high voltage is applied), and the correlation between test items (this correlation will not be reflected in the test cases, for example, when testing the total voltage, attention should be paid to adjusting the individual unit voltage to avoid causing additional differential voltage faults), it is difficult to generate scripts using a unified prompt word. Therefore, it is also possible to set up target reference test cases corresponding to the test cases based on the reference test case set.

[0055] The above-mentioned process of obtaining target reference test cases corresponding to test cases based on the reference test case set includes: parsing each test case to obtain the test case category and function; and selecting target reference test cases from the reference test case set based on the test case category and function.

[0056] Among them, the aforementioned reference test cases can be historical test cases. For example, test cases used by the test bench in the past can be obtained, or test cases used by the BMS product under test in previous tests can be obtained.

[0057] After obtaining reference test cases in advance and completing the reference test case set, the reference test cases are categorized according to functional dimensions. Here, functional dimension refers to test cases that have the same operation script instructions. For example, for power-on operations, all cases that are "set slave temperature, fast charging temperature, inlet and outlet water temperature → set individual unit → set high voltage interlock, collision duty cycle → set high voltage source" are considered to have the same functional dimension.

[0058] Secondly, based on category dimensions, such as fault type (Level 1) – single-unit overvoltage fault (Level 2), reference test cases belonging to the same functional dimension are further classified, and then placed under their corresponding categories in the form of test case – test script. This allows for the construction of a BMS historical test case – test script library.

[0059] When generating test scripts for the aforementioned BMS product under test, each test case can be parsed to obtain its category and function. Then, based on the reference test cases categorized by category and function, a target reference test case can be found that corresponds to the test case. For example, the three most similar reference test cases for each test case can be identified based on similarity, and the most similar reference test case can be automatically matched using a large model. This reference test case can then be used as the target reference test case.

[0060] Therefore, it is possible to obtain target reference test cases, which can then be used as a one-shot learning method for subsequent large language models, thereby improving the accuracy of test script generation. In other words, by obtaining target reference test cases, it is possible to use semantic matching templates for test cases, thus serving as a one-shot learning mechanism.

[0061] The above product information also includes the first interface information of the BMS product under test.

[0062] The method for obtaining the above interface mapping relationship includes: inputting the first interface information and the second interface information of the test bench into the first large language model to obtain the interface mapping relationship between the interface of the BMS product under test and the interface of the test bench.

[0063] Specifically, based on the first and second interface information mentioned above, interface compatibility is analyzed through a large language model, and the interface mapping relationship between the BMS product under test and the test bench is automatically allocated to ensure interface conflict detection and optimized allocation.

[0064] The interface mapping setting serves a dual purpose. First, it sets default interface options; for example, when the BMS under test supports a shunt or Hall current sensor, the shunt can be set as the default current sensor type. Second, it pre-assigns the functional interfaces of the BMS under test to the corresponding interfaces on the test bench; for example, the precharge relay interface is mapped to the SetHV2 interface (an interface number on the test bench), and the heating relay interface is mapped to the SetHV3 interface (another interface number on the test bench).

[0065] This step is primarily accomplished through the large language model. The aforementioned first interface information can be the information in the configuration fields mentioned above. Common connection information, first interface information, interface allocation logic, and other information are provided to the large language model.

[0066] Common connection information includes "The main positive relay is connected to the SetHV2 interface on the bench".

[0067] The first interface information, such as "heating relay cannot close fault", requires the configuration of two interfaces: "main positive relay" and "heating relay".

[0068] The interface allocation logic includes: ① Prioritizing the allocation of frequently used interfaces; ② When there are multiple interfaces for the same test case, they cannot be connected to the same interface; ③ When there is only one interface in a test case, they are allocated sequentially; ④ Based on the above three principles, all test case interfaces are considered in a comprehensive manner to achieve one-time connection of interfaces and eliminate the need to reconnect to the interface when switching test cases.

[0069] The subsequently generated test scripts will assign and retrieve values ​​to the test bench interfaces based on this mapping relationship. It is crucial to ensure that functional interfaces being tested simultaneously are not mapped to the same test bench interface. After setup, the final actual tests must strictly adhere to the preset interface connection relationships.

[0070] The aforementioned second interface information can be known information obtained in advance.

[0071] The mapping relationship between the interface of the BMS product under test and the interface of the test bench refers to the connection relationship between the interface of the BMS product under test and the interface of the test bench during testing.

[0072] After obtaining the configuration field information, the third signal set, the second operation set, the instruction set, the interface mapping relationship, and the target reference test cases, these elements can be converted into script generation information by constructing prompt words. The prompt words can be pre-written script information generation templates based on experience. Based on these templates, it becomes clear what information needs to be written into the template. Then, the necessary template input information is obtained from the configuration field information, the third signal set, the second operation set, the instruction set, the interface mapping relationship, and the target reference test cases. This template input information is then written into the script information generation template to obtain the aforementioned script generation information. An example of such a script information generation template is shown below: # Task Definition - Task Description xxxx - Task requirements xxxx - Output requirements xxxx # Test Cases # Target Reference Test Cases # Preset information (including the above configuration fields and interface mapping relationships) # Signal Set # Operation Set # Command Set Furthermore, in order to improve the interpretability of the generated test scripts, the second largest language model is required to generate the corresponding instruction interpretation before each generated instruction, and then the test script is generated.

[0073] The second major language model mentioned above can be a pre-trained model.

[0074] S12, Generate an initial test script based on the script generation information, and verify the initial test script.

[0075] After obtaining the initial test script, it can be parsed to extract the initial test script that conforms to the preset format. If parsing fails, a retry mechanism is initiated, retrying at most once, and the second major language model mentioned above is called again to generate the initial test script.

[0076] Furthermore, each initial test script needs to be validated.

[0077] For each initial test script, the initial test script is validated, including: parsing the initial test script to obtain the script information of the initial test script; validating the script information according to the DBC file and instruction set; and determining that the initial test script has failed validation in response to the script information failing validation.

[0078] The verification of the initial test script also includes: in response to the script information passing the verification, matching the test steps and test cases in the initial test script to obtain the matching results of the test steps and test cases; when the matching result is a mismatch, it is determined that the initial test script has failed the verification; when the matching result is a match, it is determined that the initial test script has passed the verification.

[0079] The script information mentioned above includes the set of signal names, signal parameters, instruction names, instruction parameters, number of first instruction parameters, and instruction type set in the initial test script.

[0080] Specifically, after obtaining the script information, the first verification result of the initial test script is obtained based on the signal name set, signal parameter set, instruction name set, instruction parameter set, number of first instruction parameters, instruction type set, DBC file, instruction set corresponding to the initial test script, second operation set, and test cases.

[0081] The first verification result of the initial test script obtained above, based on the signal name set, signal parameter set, instruction name set, instruction parameter set, number of first instruction parameters, instruction type set, DBC file, and instruction set, second operation set, and test cases corresponding to the initial test script, includes: obtaining the second verification result based on the signal name set, signal parameter set, and DBC file; and obtaining the third verification result based on the instruction name set, instruction parameter set, number of first instruction parameters, instruction type set, and instruction set.

[0082] By obtaining the second and third verification results, it can be determined whether the script information has passed the verification.

[0083] If at least one of the second and third verification results fails the verification, the script information fails the verification. If both the second and third verification results pass the verification, the script information passes the verification.

[0084] If at least one of the second and third verification results is failed, the first verification result is determined to be a failed verification.

[0085] The second verification result obtained above based on the signal name set, signal parameter set, and DBC file includes: obtaining a list of signal names and a range of signal parameters corresponding to each signal parameter in the signal reference set based on the DBC file.

[0086] If all signal names in the signal name set exist in the signal name list, and all signal parameters in the signal parameter set are within their corresponding signal parameter range, then the second verification result is a successful verification.

[0087] If any signal name in the signal name set does not exist in the signal name list, the second verification result is that the verification failed.

[0088] If any signal parameter in the signal parameter set is not within its corresponding signal parameter range, the second verification result is that the verification failed. In other words, each signal parameter in the signal parameter set is compared with its corresponding signal parameter range; if any signal parameter is not within its corresponding signal parameter range, the second verification result is determined to be that the verification failed.

[0089] The third verification result is obtained based on the instruction name set, instruction parameter set, number of first instruction parameters, instruction type set, and instruction set. This result includes: a list of instruction names obtained from the instruction set, the instruction parameter range corresponding to each instruction parameter in the instruction reference set, a list of instruction parameter types, and the number of second instruction parameters.

[0090] If all instruction names in the instruction name set exist in the instruction name list, all instruction parameters in the instruction parameter set are within their corresponding instruction parameter range, all instruction types in the instruction type set exist in the instruction type list, and the number of second instruction parameters is equal to the number of first instruction parameters, then the third verification result is a successful verification.

[0091] If any instruction name in the instruction name set does not exist in the instruction name list, the third verification result is that the verification failed.

[0092] If any instruction parameter in the instruction parameter set is not within its corresponding instruction parameter range, the third verification result is that the verification failed.

[0093] If any instruction type in the instruction type set does not exist in the instruction type list, the third verification result is that the verification failed.

[0094] If the number of parameters in the second instruction is not equal to the number of parameters in the first instruction, then the third verification result is that the verification failed.

[0095] Therefore, the parsed signal names and their parameters can be compared and verified with the signals in the DBC file. The verification items are: whether the signal name is in the DBC file, and whether the signal parameter values ​​are valid (whether they are within the value range). All of the above verifications must be satisfied for the second verification result to be considered as passing; otherwise, it fails and the reason for the failure is recorded.

[0096] Subsequently, the parsed instruction names and their parameters are compared and verified against the aforementioned instruction set. Verification includes: whether the instruction name exists in the instruction set; whether the number of instruction parameters is correct; whether the types of each instruction parameter are correct; and whether the values ​​of each instruction parameter are valid (whether they are within the range and whether the lower limit is less than or equal to the upper limit). All of the above verifications must be satisfied for the third verification result to be considered passed; otherwise, it fails and the reason for the failure is recorded.

[0097] When both the second and third verification results pass, the script information is deemed to have passed verification, allowing for a determination of whether the test steps match the test cases. Therefore, the initial matching check for test steps and test cases first obtains the second and third verification results. Since determining whether test steps match test cases requires the use of a large language model, while obtaining the second and third verification results does not, performing an initial check based on these results reduces the number of times the third large language model is called, thereby reducing resource consumption and improving verification speed.

[0098] The above-mentioned matching of test steps in the initial test script with test cases includes: inputting the test script, the second set of operations, and test cases into the third language model to obtain the matching results of test steps in the initial test script with test cases.

[0099] Furthermore, a fourth verification result can be obtained based on the matching result.

[0100] The third language model mentioned above can be a pre-trained model.

[0101] The above-mentioned input of test scripts, second operation sets, and test cases into the third language model can be achieved by combining the initial test script, second operation sets, and test cases through prompt words. For example, a template can be written in advance based on experience, the initial test script, second operation sets, and test cases can be filled into the template, and the filling results can be input into the third language model.

[0102] The third language model can determine whether the test steps in the initial test script are consistent with the requirements of the test cases, so as to avoid omissions or redundancies. If the test steps are consistent with the requirements of the test cases, it is determined that the test steps in the initial test script match the test cases, and the fourth verification result is passed; otherwise, the fourth verification result is failed.

[0103] S13, when the initial test script fails the verification, generate new script generation information based on the initial test script, and return to the step of generating the initial test script based on the script generation information.

[0104] Specifically, for each initial test script that fails validation, the reason for the validation failure is obtained for that initial test script. Based on the reason for the validation failure, the initial test script, configuration field information, test case information, target reference test cases, and interface mapping relationships, new script generation information is generated. Among them, the target reference test cases are the test cases corresponding to the test cases obtained from the pre-configured set of reference test cases, the interface mapping relationship is the mapping relationship between the interface of the BMS product under test and the interface of the test bench, and the test bench is the test bench used to test the BMS product under test.

[0105] The methods for obtaining the reasons for the above-mentioned verification failures include: obtaining the reasons for verification failures based on the first verification result. As an example, assuming the reason for the first verification failure is that the fourth verification result also fails, the reason for the verification failure is that the test steps in the initial test script are inconsistent with the requirements of the test case; assuming the reason for the first verification failure is that the second verification result fails because a signal name does not exist in the signal name list, then that signal name is taken as the target signal name, and the reason for the verification failure is the existence of an unknown target signal name; assuming the reason for the first verification failure is that the third verification result fails because the number of second instruction parameters is not equal to the number of first instruction parameters, then the reason for the verification failure is a problem with the number of instruction parameters.

[0106] The above-mentioned new script generation information, generated based on the reasons for the verification failure and the initial test script, includes: A template is prepared in advance based on experience. The reasons for validation failures, the initial test script, and the original input information, including the aforementioned configuration fields, the third signal set, the second operation set, the instruction set, the interface mapping relationship, and the target reference test cases, are written into the template to obtain new script generation information. Optionally, the aforementioned test cases can also be written into the template.

[0107] It should be noted that if a few test scripts still fail the verification after the specified number of iterations, they will be manually corrected.

[0108] S14. When the initial test script passes the verification, the initial test script will be used as the test script for the BMS product under test.

[0109] In summary, the test script generation method of this invention generates script generation information for pre-configured test cases based on the product information of the BMS product under test; generates an initial test script based on the script generation information and verifies the initial test script; if the initial test script fails verification, generates new script generation information based on the initial test script and returns to the step of generating the initial test script based on the script generation information; if the initial test script passes verification, it is used as the test script for the BMS product under test. This enables automatic test script generation, improving the efficiency and reliability of BMS testing and reducing the reliance on experience. Furthermore, a multi-stage, hierarchical information filtering and generation process is designed to ensure the accuracy of test script generation. Specifically, by obtaining signal sets, operation sets, and instruction sets step by step in an unchangeable order, complex test requirements are decomposed layer by layer into specific executable instructions. This structured process reduces the dependence on the experience of test engineers, making the script generation process more systematic and traceable, discarding information irrelevant to test cases, and improving the accuracy and adaptability of the scripts. Furthermore, a closed-loop automated verification and iterative correction mechanism is introduced to enhance script reliability. Specifically, the generated test script undergoes verification. If verification fails, the system combines the error cause with the original input information to regenerate the script, forming a closed loop of "generation-verification-correction." This iterative mechanism ensures that the script ultimately meets test requirements, reduces manual intervention, and improves the robustness of the overall testing process.

[0110] Furthermore, this invention proposes a BMS product testing method.

[0111] Figure 2 This is a flowchart of a BMS product testing method according to an embodiment of the present invention.

[0112] like Figure 2 As shown, the BMS product testing methods include: S21, Generate the BMS test script for the BMS product under test.

[0113] The BMS test script is a test script generated according to the test script generation method of the above embodiments.

[0114] S22, Test the BMS product under test according to the BMS test script.

[0115] The following description uses a specific example.

[0116] See Figure 3First, input the BMS test case set, extract the parameter fields to be configured (i.e. the configuration fields mentioned above), extract the corresponding parameter values ​​(including the configuration field information and the second interface information mentioned above) from the product text (i.e. the text knowledge mentioned above) and the test bench, and form an interface mapping relationship.

[0117] Then, using a large model, for each test case, the corresponding subsets are obtained in a multi-stage, layered manner according to the order of signal file-operation set-instruction set, and the corresponding signal subset (i.e., the above signal set), operation subset (i.e., the above operation set), and instruction subset (i.e., the above instruction set) are obtained.

[0118] A library of historical BMS test cases and test scripts is built according to categories; for each test case, a one-shot learning mechanism is used by semantically matching templates.

[0119] Based on the aforementioned preset information, preset interface mapping relationships, message and signal subsets, and instruction subsets, a corresponding automated test script (i.e., the aforementioned initial test script) is generated for each test case based on the large language model.

[0120] The generated test script is automatically validated, including instruction validation, signal value validation, parameter count and valid value validation, and step validation. If the validation fails, the test script is regenerated.

[0121] On the test bench connected to the BMS product under test, import and execute the test scripts corresponding to each test case in batches, and record the corresponding test results.

[0122] In summary, the BMS product testing method of this invention can automatically generate test scripts, improve the efficiency and reliability of BMS testing, and reduce the requirements for experience.

[0123] Furthermore, the present invention proposes an electronic device.

[0124] Figure 4 This is a structural block diagram of an electronic device according to an embodiment of the present invention.

[0125] like Figure 4 As shown, the electronic device 500 includes a processor 501 and a memory 503. The processor 501 and the memory 503 are connected, for example, via a bus 502. Optionally, the electronic device 500 may also include a transceiver 504. It should be noted that in practical applications, the transceiver 504 is not limited to one type, and the structure of this electronic device 500 does not constitute a limitation on the embodiments of the present invention.

[0126] Processor 501 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It can implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this invention. Processor 501 may also be a combination that implements computational functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.

[0127] Bus 502 may include a pathway for transmitting information between the aforementioned components. Bus 502 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. Bus 502 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 4 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0128] The memory 503 is used to store a computer program corresponding to the test script generation method of the above embodiments of the present invention, or the BMS product testing method of the above embodiments, which is controlled and executed by the processor 501. The processor 501 is used to execute the computer program stored in the memory 503 to implement the content shown in the foregoing method embodiments.

[0129] in, Figure 4 The electronic device 500 shown is merely an example and should not be construed as limiting the functionality and scope of use of the embodiments of the present invention.

[0130] The electronic device according to the embodiments of the present invention, by implementing the test script generation method of the above embodiments, or the BMS product testing method of the above embodiments, can improve the efficiency and reliability of BMS testing and reduce the requirements for experience.

[0131] It should be noted that the logic and / or steps represented in the flowchart or otherwise described herein can be considered as a ordered list of executable instructions for implementing logical functions, which can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-included system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of computer-readable media include: an electrical connection having one or more wires (electronic device), a portable computer disk drive (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Alternatively, the computer-readable medium may be paper or other suitable media on which the program can be printed, since the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in a computer memory.

[0132] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. If implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0133] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0134] In the description of this specification, the terms "center," "longitudinal," "lateral," "length," "width," "thickness," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," "outer," "clockwise," "counterclockwise," "axial," "radial," and "circumferential" indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and should not be construed as limiting the present invention.

[0135] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this invention, "a plurality of" means at least two, such as two, three, etc., unless otherwise explicitly specified.

[0136] In this specification, unless otherwise stated, the terms "installation," "connection," "joining," and "fixing," etc., should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral part; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components, unless otherwise explicitly defined. Those skilled in the art can understand the specific meaning of the above terms in this invention according to the specific circumstances.

[0137] In this invention, unless otherwise explicitly specified and limited, "above" or "below" the second feature can mean that the first feature is in direct contact with the second feature, or that the first feature is in indirect contact with the second feature through an intermediate medium. Furthermore, "above," "over," and "on top" of the second feature can mean that the first feature is directly above or diagonally above the second feature, or simply that the first feature is at a higher horizontal level than the second feature. "Below," "below," and "under" the second feature can mean that the first feature is directly below or diagonally below the second feature, or simply that the first feature is at a lower horizontal level than the second feature.

[0138] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.

Claims

1. A method for generating test scripts, characterized in that, The method includes: Based on the product information of the BMS product under test, generate scripts to generate information for pre-configured test cases; An initial test script is generated based on the script generation information, and the initial test script is verified. If the initial test script fails the verification, new script generation information is generated based on the initial test script, and the step of generating the initial test script based on the script generation information is returned. When the initial test script passes the verification, the initial test script will be used as the test script for the BMS product under test.

2. The test script generation method according to claim 1, characterized in that, The process of generating scripts for pre-configured test cases based on the product information of the BMS product under test includes: The configuration fields were extracted from the test cases. The configuration field information is extracted from the product information based on the configuration field. Based on the configuration field information, script generation information corresponding to the test case is generated.

3. The test script generation method according to claim 2, characterized in that, The product information includes the DBC file of the BMS product under test, and the step of generating script generation information corresponding to the test cases based on the configuration field information includes: The test case information is obtained from the DBC file. The script generation information is generated based on the use case information and the configuration field information.

4. The test script generation method according to claim 3, characterized in that, The step of obtaining the test case information based on the DBC file includes: A first signal set is obtained by filtering from the DBC file, wherein the first signal set includes a first message name, a first signal name, and first parameter information corresponding to the test case; The first set of signals is used as the use case information.

5. The test script generation method according to claim 3, characterized in that, The step of obtaining the test case information based on the DBC file includes: A second signal set is obtained by filtering from the DBC file, wherein the second signal set includes a second message name, a second signal name, and second parameter information corresponding to the test case; A first set of operations corresponding to the test cases and the second set of signals is obtained by filtering from a pre-configured set of operations. The second signal set and the first operation set are used as the use case information.

6. The test script generation method according to claim 3, characterized in that, The step of obtaining the test case information based on the DBC file includes: A third signal set is obtained by filtering from the DBC file, wherein the third signal set includes a third message name, a third signal name, and third parameter information corresponding to the test case; A second set of operations corresponding to the test cases and the third set of signals is obtained by filtering from a pre-configured set of operations. The instruction set corresponding to the test case and the second operation set is obtained by filtering from the pre-configured instruction set; The third signal set, the second operation set, and the instruction set are used as the use case information.

7. The test script generation method according to any one of claims 3-6, characterized in that, The step of generating the script generation information based on the use case information and the configuration field information includes: The target reference test cases corresponding to the test cases are obtained based on the pre-configured set of reference test cases; Template input information is obtained based on the test cases, the configuration field information, the test case information, the target reference test cases, and the interface mapping relationship. The interface mapping relationship is the mapping relationship between the interface of the BMS product under test and the interface of the test bench. The test bench is the test bench used to test the BMS product under test. The template input information is filled into the pre-configured script generation information template to obtain the script generation information.

8. The test script generation method according to claim 6, characterized in that, The verification of the initial test script includes: The initial test script is parsed to obtain the script information of the initial test script; The script information is verified based on the DBC file and the instruction set; In response to the script information failing verification, it is determined that the initial test script has failed verification.

9. The test script generation method according to claim 8, characterized in that, The verification of the initial test script also includes: In response to the script information passing the verification, the test steps in the initial test script are matched with the test cases to obtain the matching result of the test steps and the test cases; When the matching result is a non-match, it is determined that the initial test script has failed the verification. When the matching result is a match, the initial test script is determined to have passed the verification.

10. The test script generation method according to claim 9, characterized in that, The step of generating new script generation information based on the initial test script includes: Get the reason why the verification failed; New script generation information is generated based on the reasons for the verification failure, the initial test script, the configuration field information, the test case information, the target reference test case, and the interface mapping relationship. The target reference test case is a test case corresponding to the test case obtained from a pre-configured set of reference test cases. The interface mapping relationship is the mapping relationship between the interface of the BMS product under test and the interface of the test bench. The test bench is the test bench used to test the BMS product under test.

11. A BMS product testing method, characterized in that, The method includes: Generate a BMS test script for the BMS product to be tested, wherein the BMS test script is a test script generated by the test script generation method according to any one of claims 1-10; The BMS product under test is tested according to the BMS test script.

12. An electronic device, characterized in that, It includes a memory, a processor, and a computer program stored in the memory and running on the processor. When the computer program is executed by the processor, it implements the test script generation method according to any one of claims 1-10, or implements the BMS product testing method according to claim 11.