Test case determination method and device, electronic equipment and storage medium
By converting the source code and system data of the battery management system into a syntax tree structure and using encoders and decoders to generate test cases, the problems of time-consuming and labor-intensive BMS test case design and incomplete coverage are solved, and more efficient and accurate test case generation is achieved.
Patent Information
- Application Number
- CN202510724566.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-30
- Publication Date
- 2025-09-26
AI Technical Summary
The design of existing BMS test cases is time-consuming and labor-intensive, with a complex design process. It cannot cover all operating scenarios and is easily affected by subjective factors, resulting in incomplete testing and increased system risks.
By obtaining the source code and system data of the battery management system, converting them into target code with a syntax tree structure, and vectorizing them with the system data, the preset encoder and decoder are used to generate target test cases. Combined with the actual operation scenarios and battery management system data, the adaptability and accuracy of the test cases are improved.
No need to manually design tests. Test cases generated using the battery management system's source code and system data cover more operating scenarios, improving generation efficiency and accuracy and reducing system risks.
Smart Images

Figure CN120705034A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure belongs to the field of data processing technology, and in particular relates to a method, device, electronic device, and storage medium for determining a test case. Background Art
[0002] In the battery energy storage industry, the core of the battery state of charge (SOC) calculation method is to calculate the actual capacity of the battery.
[0003] In energy management systems, the Battery Management System (BMS) is the core component of the energy storage system. The correctness and safety of its functions are directly related to the performance and safe operation of the entire system. Therefore, BMS testing is extremely important.
[0004] In related technologies, BMS testing typically relies on manually designed test cases. This approach is not only time-consuming and labor-intensive, but also complex and unable to cover all operational scenarios. Furthermore, due to manual design, test cases are susceptible to subjective factors and may not fully account for extreme or edge cases, resulting in incomplete testing. This increases potential system risks and reduces design efficiency. Summary of the Invention
[0005] The embodiments of the present disclosure provide a solution to solve the problem in the related art that traditional BMS design test cases are not only time-consuming and labor-intensive, but also have a complex design process, cannot cover all operating scenarios, and have low design efficiency.
[0006] In a first aspect, the present disclosure provides a method for determining a test case, the method comprising:
[0007] Obtaining source code, system data, and a first test case of a battery management system, wherein the system data includes current data, temperature data, and voltage data acquired by the battery management system, and the test case is a document used to describe a battery test task;
[0008] Converting the source code into a target code with a syntax tree structure;
[0009] Vectorizing the target code and the system data respectively to obtain a first eigenvector and a second eigenvector;
[0010] Encoding the first eigenvector and the second eigenvector based on a preset encoder to obtain a third eigenvector;
[0011] Decoding the third feature vector based on a preset decoder to obtain a second test case;
[0012] A target test case is obtained based on the second test case and the first test case.
[0013] In a second aspect, the present disclosure provides a device for determining a test case, the device comprising:
[0014] an acquisition unit, configured to acquire source code, system data, and a first test case of a battery management system, wherein the system data includes current data, temperature data, and voltage data acquired by the battery management system, and the test case is a document describing a battery test task;
[0015] A conversion unit, configured to convert the source code into a target code with a syntax tree structure;
[0016] The conversion unit is further configured to vectorize the target code and the system data respectively to obtain a first feature vector and a second feature vector;
[0017] an encoding unit, configured to encode the first eigenvector and the second eigenvector based on a preset encoder to obtain a third eigenvector;
[0018] a decoding unit, configured to decode the third feature vector based on a preset decoder to obtain a second test case;
[0019] A determining unit is configured to obtain a target test case based on the second test case and the first test case.
[0020] In a third aspect, the present disclosure provides an electronic device, comprising:
[0021] processor; and
[0022] a memory for storing executable instructions of the processor;
[0023] The processor is configured to execute any method in the first aspect or any possible implementation of the first aspect by executing the executable instructions.
[0024] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any method in the first aspect or any possible implementation of the first aspect.
[0025] The technical solution provided by the present disclosure obtains the source code, system data and first test case of the battery management system, wherein the system data includes the current data, temperature data and voltage data obtained by the battery management system, and the test case is a document for describing the battery test task; converts the source code into a target code with a syntax tree structure; vectorizes the target code and the system data respectively to obtain a first feature vector and a second feature vector; encodes the first feature vector and the second feature vector based on a preset encoder to obtain a third feature vector; decodes the third feature vector based on a preset decoder to obtain a second test case; and obtains a target test case based on the second test case and the first test case. The technical solution provided by each embodiment of the present disclosure does not require manual test design. By utilizing the source code and system data of the battery management system, the adaptability of the generated test cases can be improved by combining the source code and system data of the battery management system and covering more operation scenarios; and by combining the encoder and decoder, the relationship between the source code and the system data can be improved, and the accuracy of the generated test cases can be improved, thereby greatly improving the generation efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are some embodiments of the present disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0027] Figure 1 A flowchart of a method for determining a test case provided by an embodiment of the present disclosure;
[0028] Figure 2 A schematic diagram of a process for converting the source code into a target code with a syntax tree structure according to an embodiment of the present disclosure;
[0029] Figure 3 A schematic diagram of a process for vectorizing the target code to obtain the first feature vector provided in one embodiment of the present disclosure;
[0030] Figure 4 A schematic diagram of a process for vectorizing the grammatical features to obtain a fourth feature vector provided by an embodiment of the present disclosure;
[0031] Figure 5 A schematic diagram of a process for obtaining a second test case provided by an embodiment of the present disclosure;
[0032] Figure 6A flowchart of an embodiment of the present disclosure provides a method for modifying the second test case based on the first test case and the loss function to obtain a target test case;
[0033] Figure 7 A schematic diagram of the structure of a device for determining a test case provided by an embodiment of the present disclosure;
[0034] Figure 8 A schematic structural diagram of an electronic device provided in one embodiment of the present disclosure. DETAILED DESCRIPTION
[0035] The embodiments of the present disclosure are described in detail below, and examples of the embodiments are shown in the accompanying drawings. The embodiments described below with reference to the accompanying drawings are exemplary and intended to be used to explain the present disclosure, but should not be understood as limiting the present disclosure.
[0036] The terms "first" and "second" and the like in the specification, claims, and drawings of the embodiments of the present disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the embodiments of the present disclosure described herein can, for example, be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product, or apparatus comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products, or apparatus.
[0037] The method for determining test cases provided by the embodiments of the present disclosure can be run on a terminal device or a server. The terminal device can be a local terminal device, including wearable devices such as VR (Virtual Reality), AR (Augmented Reality), and MR (Mixed Reality). The server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms.
[0038] In the battery energy storage industry, the core of the battery state of charge (SOC) calculation method is to calculate the actual capacity of the battery.
[0039] In energy management systems, the Battery Management System (BMS) is the core component of the energy storage system. The correctness and safety of its functions are directly related to the performance and safe operation of the entire system. Therefore, BMS testing is extremely important.
[0040] In related technologies, BMS testing typically relies on manually designed test cases. This approach is not only time-consuming and labor-intensive, but also complex and unable to cover all operational scenarios. Furthermore, due to manual design, test cases are susceptible to subjective factors and may not fully account for extreme or edge cases, resulting in incomplete testing. This increases potential system risks and reduces design efficiency.
[0041] Figure 1 This is a flow chart of a method for determining a test case provided by an exemplary embodiment of the present disclosure. The method can be applied to a device having a data processing function. Taking the method applied to a management device as an example, the solution includes at least the following steps S101-S106:
[0042] S101, obtaining source code, system data, and a first test case of a battery management system.
[0043] In some embodiments, the system data includes current data, temperature data, and voltage data acquired by the battery management system.
[0044] In some embodiments, the test case is a document describing a battery test task. For example, taking logging into a battery management system as an example, a login test case may include a login process, including logging in with an account, entering a password, entering a verification code, receiving a verification code, and confirming login, as well as the corresponding process code.
[0045] In some embodiments, obtaining the system data includes: obtaining initial data, and performing a first preprocessing on the initial data to obtain the system data.
[0046] In this embodiment, the initial data is primarily obtained from the battery management system's real-time monitoring of the energy storage device. This system data may also include charge and discharge status, output power, etc. To ensure the accuracy and completeness of the acquired data, the initial data must be processed to convert it into system data in a clean format suitable for subsequent processing.
[0047] Specifically, the first preprocessing includes at least: data cleaning, outlier processing, and format conversion.
[0048] Taking data cleaning as an example, data with missing values in the initial data can be deleted.
[0049] Taking outlier processing as an example, interpolation and mean filling methods are used to process missing values in the initial data.
[0050] Taking format processing as an example, when the battery management system obtains the system data of the energy storage device, the numerical range of the collected system data varies greatly due to different working conditions and equipment. Therefore, in order to ensure the uniformity in the subsequent calculation process, the initial data needs to be normalized. Specifically, Min-Max normalization can be used to map the system data to the [0,1] interval, and Z-score normalization can be used to process the initial data into zero mean and unit variance.
[0051] S102, converting the source code into a target code with a syntax tree structure.
[0052] In some embodiments, the syntax tree structure is an abstract representation of the syntax structure of the source code, which represents the syntax structure of the programming language in a tree-like form, with each node on the tree representing a structure in the source code.
[0053] In some embodiments, as Figure 2 As shown, converting the source code into a target code with a syntax tree structure includes steps S11-S13:
[0054] S11, performing a second preprocessing on the source code.
[0055] In some embodiments, the second pre-processing includes removing spaces and removing comments.
[0056] S12: Divide the source code after the second preprocessing into a plurality of lexical units.
[0057] In some embodiments, the lexical units include keywords, variable names, constants, and operators.
[0058] S13, using a parsing tool to convert the multiple lexical units into target codes with a syntax tree structure.
[0059] In some embodiments, because the source code of the battery management system contains irrelevant data, such as comments and spaces, the source code needs to be preprocessed to make it more concise. Specifically, spaces and comments are removed, and the source code is then divided into different lexical units. Finally, the compiler's parsing tools are used to organize the lexical units into code in a syntax tree structure. Each node in the target code in the syntax tree structure represents a grammatical component, such as a function, conditional statement, or loop statement. Finally, the target code is simplified to remove redundant information, making it more concise and easier to process in subsequent steps.
[0060] S103 , vectorizing the target code and the system data respectively to obtain a first eigenvector and a second eigenvector.
[0061] In some embodiments, after obtaining the target code through steps S101-S102, it is further necessary to extract grammatical features from each node in the target code, and then convert the grammatical features into vector representations corresponding to feature vectors required in subsequent processes.
[0062] In some embodiments, as Figure 3 As shown, the target code is vectorized to obtain the first feature vector, including steps S21-S24:
[0063] S21, extracting grammatical features from all nodes in the target code.
[0064] In actual operation, it is necessary to traverse each node of the target code and extract the grammatical features of each node. Specifically, the grammatical features include at least: node type information, node attribute information, and relationship information between nodes.
[0065] In some embodiments, the type information includes variables, functions, and operations.
[0066] In some embodiments, the attribute information includes variable name, data type, and operation type.
[0067] In some embodiments, the relationship information includes a structural relationship between a node and its parent node and its child nodes.
[0068] S22: Vectorize the grammatical features to obtain a fourth feature vector.
[0069] In some embodiments, as Figure 4 As shown, the grammatical features are vectorized to obtain a fourth feature vector, including steps S221-S222:
[0070] S221: Classify the grammatical features according to preset rules to obtain a plurality of grammatical sub-features.
[0071] Specifically, you can classify by node type or by symbolic features, i.e. variable name or function name. You can set this up based on your actual situation.
[0072] S222: Vectorize the multiple grammatical sub-features according to their respective vectorization rules to obtain multiple fourth sub-feature vectors, and use the multiple fourth sub-feature vectors as the fourth feature vector.
[0073] Among them, different categories of grammatical sub-features correspond to different vectorization rules.
[0074] Specifically, for grammatical features of node types, one-hot encoding can be used to encode them, representing each node type's grammatical features as a high-dimensional sparse vector. For symbolic features (such as variable and function names), Word2Vec word embedding is used to convert them into low-dimensional dense vectors. Other vectorization rules are not detailed here.
[0075] S23: Convert the vocabulary in the first test case into a fifth feature vector.
[0076] In some embodiments, converting the vocabulary in the first test case into a fifth feature vector includes: converting the vocabulary in the first test case into a fifth feature vector through a word embedding model.
[0077] The word embedding model is obtained by training with source code and sample test cases. Specifically, the word embedding model is a single hidden layer neural network model, comprising an input layer, a hidden layer, and an output layer. The CBOW model structure is mainly adopted. The input layer receives a one-hot encoded center word. Each center word is a one-hot vector whose dimension is equal to the vocabulary size, the corresponding word position is 1, and the remaining positions are 0. The hidden layer is connected to the input layer through a weight matrix W. The weight matrix is a word embedding matrix, and each row corresponds to the embedding vector of a word in the vocabulary. The output layer is a Softmax layer, which receives the output of the hidden layer, passes through the weight matrix and the bias term, and generates a probability distribution through the Softmax function.
[0078] S24: Determine the first eigenvector based on the fourth eigenvector and the fifth eigenvector.
[0079] In some embodiments, determining the first eigenvector based on the fourth eigenvector and the fifth eigenvector includes: concatenating the fourth eigenvector and the fifth eigenvector to obtain the first eigenvector.
[0080] In other embodiments, vectorizing the system data to obtain the second feature vector includes: converting the system data into the second feature vector through a sliding window technology.
[0081] Specifically, before the system data is vectorized, it needs to be further processed. In order to make the obtained second feature vector more consistent with the above test case, it is necessary to select features related to the first test case through feature engineering, including calculating statistical features such as average value, maximum value, minimum value, variance, kurtosis, skewness, etc., as well as dynamic features such as volatility, time periods of frequent fluctuations, number and frequency of charging and discharging, or use long short-term memory network (LSTM) to extract time series features, such as changes in voltage and current in the past n moments.
[0082] S104: Encode the first eigenvector and the second eigenvector based on a preset encoder to obtain a third eigenvector.
[0083] In some embodiments, the preset encoder refers to the encoder in the Transformer model. The encoder consists of a multi-layer neural network, each layer of which includes a self-attention mechanism and a feedforward neural network. Its main function is to encode the input data and generate a high-dimensional feature vector.
[0084] In this embodiment, during actual operation, the first feature vector and the second feature vector are used as inputs of a preset encoder, and the preset encoder encodes the first feature vector and the second feature vector to obtain a high-dimensional feature vector, that is, a third feature vector.
[0085] In some embodiments, encoding the first feature vector and the second feature vector based on a preset encoder to obtain a third feature vector includes: obtaining the third feature vector using the preset encoder based on the first feature vector, the second feature vector, and the fifth feature vector.
[0086] Specifically, during actual operation, the vectorized system data and source code can be combined with the feature vectors of key events (referring to the features related to the first test case, such as the start and end of charging and discharging, and the features of the nodes where the code is executed) to ensure that different system data and test cases are logically corresponding. Through this combination, different working conditions can be applied, and more targeted test cases can be generated.
[0087] In order to better understand step S104, taking the encoder as an example, the basic structure of the encoder is to stack multiple identical encoder layers, and each layer includes two main sub-modules: self-attention mechanism and feedforward neural network. Each sub-module is followed by residual connection (ResidualConnection) and layer normalization (Layer Normalization). The present invention preferably uses 8 encoder layers. The specific number of layers can be adjusted according to the complexity of the acquired system data and the source code. Simple tasks use 2-4 layers and complex tasks use 8-12 layers. Specifically, the dimension of each layer input is the same as the word embedding dimension 512 to ensure the consistency of the dimension during the model processing. The self-attention mechanism of each layer is divided into 8 attention heads to capture the dependencies between different positions.
[0088] S105 : Decode the third feature vector based on a preset decoder to obtain a second test case.
[0089] In some embodiments, the preset decoder refers to the decoder in the Transformer model. The decoder also consists of a multi-layer neural network, but each layer includes a self-attention mechanism, encoder-decoder attention, and a feedforward neural network. Its main function is to generate the output sequence.
[0090] In some embodiments, as Figure 5 As shown, based on the preset decoder, the third feature vector is decoded to obtain a second test case, including steps S31-S32:
[0091] S31: Decode the third feature vector based on a preset decoder to obtain an output sequence.
[0092] S32: Construct the second test case based on the output sequence.
[0093] The decoder is another core part of the Transformer model, and its main function is to generate the output sequence. In the present invention, the decoder is used to generate test cases. By training a Transformer-based decoder, the joint feature expression obtained by encoding can be decoded to reconstruct the input test case. The decoder uses an autoregressive approach to generate each word in the test case in turn. When generating each word, the self-attention mechanism is used to obtain the contextual information of the input sequence, and the positional encoding is used to integrate the positional information of the sequence into the model.
[0094] To better understand step S105, let's take the decoder as an example. The decoder's structure is similar to the encoder's, consisting of a multi-head self-attention mechanism and a feedforward neural network. The difference is that the decoder also includes an additional cross-attention mechanism layer to capture the dependencies between the encoder's output features and the decoder's own input. The decoder of the present invention preferably uses 8 decoding layers, and the specific number of layers can be adjusted according to the complexity of the task.
[0095] S106: Obtain a target test case based on the second test case and the first test case.
[0096] In some embodiments, as Figure 6 As shown, based on the first test case and the loss function, the second test case is modified to obtain a target test case, including steps S41-S42:
[0097] S41, if the first test case is the same as the second test case, taking the second test case as the target test case;
[0098] S42: If the first test case is different from the second test case, the second test case is corrected based on the first test case and the loss function to obtain the target test case.
[0099] In some embodiments, the loss function is preferably a multi-task learning loss function (Multi-Task Loss Function), which simultaneously optimizes both source code characteristics and system data characteristics to generate more accurate and effective test cases. Specifically, the loss function can detect the differences between the first test case and the second test case, and then modify the second test case based on the differences to obtain the target test case.
[0100] The technical solution provided by the present disclosure obtains the source code, system data and first test case of the battery management system, wherein the system data includes the current data, temperature data and voltage data obtained by the battery management system, and the test case is a document for describing the battery test task; converts the source code into a target code with a syntax tree structure; vectorizes the target code and the system data respectively to obtain a first feature vector and a second feature vector; encodes the first feature vector and the second feature vector based on a preset encoder to obtain a third feature vector; decodes the third feature vector based on a preset decoder to obtain a second test case; and obtains a target test case based on the second test case and the first test case. The technical solution provided by each embodiment of the present disclosure does not require manual test design. By utilizing the source code and system data of the battery management system, the adaptability of the generated test cases can be improved by combining the source code and system data of the battery management system and covering more operation scenarios; and by combining the encoder and decoder, the relationship between the source code and the system data can be improved, and the accuracy of the generated test cases can be improved, thereby greatly improving the generation efficiency.
[0101] Figure 7 A schematic structural diagram of a device for determining a test case provided by an exemplary embodiment of the present disclosure;
[0102] The device includes: a first determination unit 201, a conversion unit 202, an encoding unit 203, a decoding unit 204, and a second determination unit 205;
[0103] A first acquisition unit 201 is configured to acquire source code, system data, and a first test case of a battery management system, wherein the system data includes current data, temperature data, and voltage data acquired by the battery management system, and the test case is a document describing a battery test task;
[0104] A conversion unit 202, configured to convert the source code into a target code in a syntax tree structure;
[0105] The conversion unit 202 is further configured to vectorize the target code and the system data respectively to obtain a first feature vector and a second feature vector;
[0106] An encoding unit 203 is configured to encode the first eigenvector and the second eigenvector based on a preset encoder to obtain a third eigenvector;
[0107] A decoding unit 204 is configured to decode the third feature vector based on a preset decoder to obtain a second test case;
[0108] The second determining unit 205 is configured to obtain a target test case based on the second test case and the first test case.
[0109] In some embodiments, the device is used to obtain the system data, and the device is specifically used to:
[0110] Acquiring initial data, and performing a first preprocessing on the initial data to obtain the system data;
[0111] The first preprocessing includes at least: data cleaning, outlier processing, and format conversion.
[0112] In some embodiments, the apparatus is used to convert the source code into a target code with a syntax tree structure, and the apparatus is specifically used to:
[0113] Performing a second preprocessing on the source code, wherein the second preprocessing includes removing spaces and comments;
[0114] Dividing the source code after the second preprocessing into a plurality of lexical units, wherein the lexical units include keywords, variable names, constants, and operators;
[0115] The plurality of lexical units are converted into target codes in a syntax tree structure by using a parsing tool.
[0116] In some embodiments, the apparatus is used to vectorize the target code to obtain the first feature vector, and the apparatus is specifically used to:
[0117] Extracting grammatical features from all nodes in the target code, the grammatical features including at least: node type information, node attribute information, and relationship information between nodes, the type information including variables, functions, and operations, the attribute information including variable names, data types, and operands, and the relationship information including structural relationships between nodes and their parent nodes and child nodes;
[0118] Vectorizing the grammatical features to obtain a fourth feature vector;
[0119] Converting the vocabulary in the first test case into a fifth feature vector;
[0120] The first eigenvector is determined based on the fourth eigenvector and the fifth eigenvector.
[0121] In some embodiments, the apparatus is configured to vectorize the grammatical features to obtain a fourth feature vector, and the apparatus is specifically configured to:
[0122] Classifying the grammatical features according to preset rules to obtain multiple grammatical sub-features;
[0123] Vectorizing the multiple grammatical sub-features according to respective vectorization rules to obtain multiple fourth sub-feature vectors, and using the multiple fourth sub-feature vectors as the fourth feature vector;
[0124] Among them, different categories of grammatical sub-features correspond to different vectorization rules.
[0125] In some embodiments, the apparatus is configured to encode the first feature vector and the second feature vector based on a preset encoder to obtain a third feature vector, and the apparatus is specifically configured to:
[0126] A third eigenvector is obtained based on the first eigenvector, the second eigenvector, and the fifth eigenvector using the preset encoder.
[0127] In some embodiments, the apparatus is configured to decode the third feature vector based on a preset decoder to obtain a second test case, and the apparatus is specifically configured to:
[0128] Decoding the third feature vector based on a preset decoder to obtain an output sequence;
[0129] Based on the output sequence, the second test case is constructed.
[0130] In some embodiments, the apparatus is configured to obtain a target test case based on the second test case and the first test case, and the apparatus is specifically configured to:
[0131] Based on the first test case and the loss function, the second test case is modified to obtain a target test case.
[0132] In some embodiments, the apparatus is configured to modify the second test case based on the first test case and the loss function to obtain a target test case, and the apparatus is specifically configured to:
[0133] If the first test case is the same as the second test case, taking the second test case as the target test case;
[0134] If the first test case is different from the second test case, the second test case is corrected based on the first test case and the loss function to obtain the target test case.
[0135] The technical solution provided by the present disclosure obtains the source code, system data and first test case of the battery management system, wherein the system data includes the current data, temperature data and voltage data obtained by the battery management system, and the test case is a document for describing the battery test task; converts the source code into a target code with a syntax tree structure; vectorizes the target code and the system data respectively to obtain a first feature vector and a second feature vector; encodes the first feature vector and the second feature vector based on a preset encoder to obtain a third feature vector; decodes the third feature vector based on a preset decoder to obtain a second test case; and obtains a target test case based on the second test case and the first test case. The technical solution provided by each embodiment of the present disclosure does not require manual test design. By utilizing the source code and system data of the battery management system, the adaptability of the generated test cases can be improved by combining the source code and system data of the battery management system and covering more operation scenarios; and by combining the encoder and decoder, the relationship between the source code and the system data can be improved, and the accuracy of the generated test cases can be improved, thereby greatly improving the generation efficiency.
[0136] It should be understood that the device embodiments and the method embodiments may correspond to each other, and similar descriptions may refer to the method embodiments. To avoid repetition, they will not be described in detail here. Specifically, the device can perform the above-mentioned method embodiments, and the aforementioned and other operations and / or functions of each module in the device are the corresponding processes in each method in the above-mentioned method embodiments, which will not be described in detail here for the sake of brevity.
[0137] The above describes the apparatus of the embodiment of the present disclosure from the perspective of functional modules in conjunction with the accompanying drawings. It should be understood that the functional module can be implemented in the form of hardware, can be implemented by instructions in the form of software, or can be implemented by a combination of hardware and software modules. Specifically, the steps of the method embodiment in the embodiment of the present disclosure can be completed by the hardware integrated logic circuit and / or software instructions in the processor, and the steps of the method disclosed in conjunction with the embodiment of the present disclosure can be directly embodied as being executed by a hardware decoding processor, or can be executed by a combination of hardware and software modules in the decoding processor. Optionally, the software module can be located in a mature storage medium in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps in the above method embodiment in conjunction with its hardware.
[0138] Figure 8 is a schematic block diagram of an electronic device provided by an embodiment of the present disclosure, which may include:
[0139] The memory 301 and the processor 302 are configured to store computer programs and transmit the program code to the processor 302. In other words, the processor 302 can call and run the computer program from the memory 301 to implement the method in the embodiment of the present disclosure.
[0140] For example, the processor 302 may be configured to execute the above method embodiments according to instructions in the computer program.
[0141] In some embodiments of the present disclosure, the processor 302 may include but is not limited to:
[0142] General-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field-programmable gate array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, etc.
[0143] In some embodiments of the present disclosure, the memory 301 includes but is not limited to:
[0144] Volatile memory and / or non-volatile memory. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct RAM bus random access memory (DR RAM).
[0145] In some embodiments of the present disclosure, the computer program may be divided into one or more modules, which are stored in the memory 301 and executed by the processor 302 to implement the method provided by the present disclosure. The one or more modules may be a series of computer program instruction segments capable of implementing specific functions, and the instruction segments are used to describe the execution process of the computer program in the electronic device.
[0146] like Figure 8 As shown, the electronic device may further include:
[0147] The transceiver 303 may be connected to the processor 302 or the memory 301 .
[0148] The processor 302 may control the transceiver 303 to communicate with other devices. Specifically, the processor 302 may send information or data to other devices or receive information or data sent by other devices. The transceiver 303 may include a transmitter and a receiver. The transceiver 303 may further include one or more antennas.
[0149] It should be understood that the various components in the electronic device are connected via a bus system, wherein the bus system includes not only a data bus but also a power bus, a control bus and a status signal bus.
[0150] The present disclosure also provides a computer storage medium having a computer program stored thereon, which, when executed by a computer, enables the computer to perform the method of the above-mentioned method embodiment. Alternatively, the present disclosure also provides a computer program product containing instructions, which, when executed by a computer, enables the computer to perform the method of the above-mentioned method embodiment.
[0151] When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the embodiment of the present disclosure is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a digital video disc (DVD)), or a semiconductor medium (e.g., a solid state drive (SSD)).
[0152] Those skilled in the art will appreciate that the modules and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this disclosure.
[0153] In the several embodiments provided in the present disclosure, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the modules is merely a logical function division. In actual implementation, there may be other division methods, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.
[0154] Modules described as separate components may or may not be physically separate, and components displayed as modules may or may not be physical modules, i.e., they may be located in one place or distributed across multiple network elements. Some or all of the modules may be selected based on actual needs to achieve the purpose of the present embodiment. For example, the functional modules in the various embodiments of the present disclosure may be integrated into a single processing module, each module may exist physically separately, or two or more modules may be integrated into a single module.
[0155] The above are only specific embodiments of the present disclosure, but the scope of protection of the present disclosure is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this disclosure should be included in the scope of protection of the present disclosure. Therefore, the scope of protection of the present disclosure should be based on the scope of protection of the claims.
Claims
1. A method for determining a test case, characterized in that: The method comprises: Obtaining source code, system data, and a first test case of a battery management system, wherein the system data includes current data, temperature data, and voltage data acquired by the battery management system, and the test case is a document used to describe a battery test task; Converting the source code into a target code with a syntax tree structure; Vectorizing the target code and the system data respectively to obtain a first eigenvector and a second eigenvector; Encoding the first eigenvector and the second eigenvector based on a preset encoder to obtain a third eigenvector; Decoding the third feature vector based on a preset decoder to obtain a second test case; A target test case is obtained based on the second test case and the first test case.
2. The method according to claim 1, characterized in that Obtaining the system data includes: Acquiring initial data, and performing a first preprocessing on the initial data to obtain the system data; The first preprocessing includes at least: data cleaning, outlier processing, and format conversion.
3. The method according to claim 1, characterized in that Converting the source code into a target code with a syntax tree structure includes: Performing a second preprocessing on the source code, wherein the second preprocessing includes removing spaces and comments; Dividing the source code after the second preprocessing into a plurality of lexical units, wherein the lexical units include keywords, variable names, constants, and operators; The plurality of lexical units are converted into target codes in a syntax tree structure by using a parsing tool.
4. The method according to claim 1, wherein Vectorizing the target code to obtain the first feature vector includes: Extracting grammatical features from all nodes in the target code, the grammatical features including at least: node type information, node attribute information, and relationship information between nodes, the type information including variables, functions, and operations, the attribute information including variable names, data types, and operands, and the relationship information including structural relationships between nodes and their parent nodes and child nodes; Vectorizing the grammatical features to obtain a fourth feature vector; Converting the vocabulary in the first test case into a fifth feature vector; The first eigenvector is determined based on the fourth eigenvector and the fifth eigenvector.
5. The method according to claim 4, characterized in that Vectorize the grammatical features to obtain a fourth feature vector, including: Classifying the grammatical features according to preset rules to obtain multiple grammatical sub-features; Vectorizing the multiple grammatical sub-features according to respective vectorization rules to obtain multiple fourth sub-feature vectors, and using the multiple fourth sub-feature vectors as the fourth feature vector; Among them, different categories of grammatical sub-features correspond to different vectorization rules.
6. The method according to claim 1, wherein Encoding the first feature vector and the second feature vector based on a preset encoder to obtain a third feature vector includes: A third eigenvector is obtained based on the first eigenvector, the second eigenvector, and the fifth eigenvector using the preset encoder.
7. The method according to claim 1, characterized in that Decoding the third feature vector based on a preset decoder to obtain a second test case includes: Decoding the third feature vector based on a preset decoder to obtain an output sequence; Based on the output sequence, the second test case is constructed.
8. The method according to claim 1, characterized in that Obtaining a target test case based on the second test case and the first test case includes: Based on the first test case and the loss function, the second test case is modified to obtain a target test case.
9. The method according to claim 8, characterized in that Based on the first test case and the loss function, the second test case is modified to obtain a target test case, including: If the first test case is the same as the second test case, taking the second test case as the target test case; If the first test case is different from the second test case, the second test case is corrected based on the first test case and the loss function to obtain the target test case.
10. A device for determining a test case, characterized in that: The device comprises: an acquisition unit, configured to acquire source code, system data, and a first test case of a battery management system, wherein the system data includes current data, temperature data, and voltage data acquired by the battery management system, and the test case is a document describing a battery test task; A conversion unit, configured to convert the source code into a target code with a syntax tree structure; The conversion unit is further configured to vectorize the target code and the system data respectively to obtain a first feature vector and a second feature vector; an encoding unit, configured to encode the first eigenvector and the second eigenvector based on a preset encoder to obtain a third eigenvector; a decoding unit, configured to decode the third feature vector based on a preset decoder to obtain a second test case; A determining unit is configured to obtain a target test case based on the second test case and the first test case.
11. An electronic device, characterized in that: include: processor; as well as a memory for storing executable instructions of the processor; The processor is configured to perform the method according to any one of claims 1 to 9 by executing the executable instructions.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.