Satellite domain code component-oriented test case reuse method and device

By creating component libraries and matching similar component units, the problem of test case reuse in software in satellite fields is solved, efficient and accurate test case reuse is achieved, and the efficiency of software development and testing is improved.

CN119847934APending Publication Date: 2025-04-18SHANGHAI AEROSPACE COMP TECH INST
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510010559.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-03
Publication Date
2025-04-18

AI Technical Summary

Technical Problem

Traditional use case design verification methods cannot meet the rapidly developing software development and testing needs, especially in the satellite field, how to effectively and reuse code components for effective and reliable use cases has become a key issue.

Method used

By creating a component library, the component units are bound to the corresponding test cases. After obtaining the satellite field test project, the requirements documents and code are analyzed, the same or similar component units are matched from the component library, and the component set is obtained, and the corresponding test cases are extracted based on the component set, so that the test cases in the component library can be reused.

Benefits of technology

The test case reuse of code components in the satellite field is realized, which improves testing efficiency and accuracy, and can perform unit tests more accurately and efficiently without relying on other parts of the entire program.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119847934A_ABST
    Figure CN119847934A_ABST
Patent Text Reader

Abstract

The invention discloses a satellite field code component-oriented test case reuse method, which comprises the following steps of: packaging a code function through a specific code component expression form to obtain a relatively independent functional unit, namely a component unit, and creating a component library based on the component unit; binding the component units in the component library with the corresponding test cases; after satellite field test items are obtained, analyzing demand documents and codes of the satellite field test items, and matching the same or similar component units from the component library to obtain a component set; and based on the component set, extracting a corresponding test case from the component library, so that the test case in the component library is reused. Due to the independence of the component units, unit testing can be carried out more easily, dependence on other parts of the whole program is not needed, and test case reuse can be carried out more accurately and efficiently.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention belongs to the technical field of software testing, and in particular relates to a test case reuse method and device for satellite field code components. Background Art

[0002] As the scale and complexity of software systems continue to grow, component reuse has become an important concept in the field of software development. Especially in satellite software with complex functions and high modularity, component reuse can avoid developing code for duplicate functions and reduce errors introduced by repeated development, thereby shortening the development cycle and improving development efficiency. At the same time, this also poses new challenges to the software testing process. The traditional use case design and verification method cannot meet the rapidly developing software development and testing needs.

[0003] Therefore, the reuse of test cases is particularly important. How to effectively and reliably reuse code components is a key issue that needs to be solved urgently. Summary of the invention

[0004] The purpose of the present invention is to provide a test case reuse method and device for satellite field code components, which calculates the similarity of component units in combination with the functional description and code structure of the software, thereby realizing the reuse of component test cases.

[0005] To solve the above problems, the technical solution of the present invention is: A test case reuse method for satellite field code components, comprising: Creating a component library, wherein the component library includes a plurality of component units, wherein the component units are relatively independent functional units in the software; Bind the component units in the component library with the corresponding test cases; Whenever a satellite field test project is obtained, its requirement documents and codes are analyzed, and the same or similar component units are matched from the component library to obtain a component set; Based on the component set, corresponding test cases are extracted from the component library, so that the test cases in the component library can be reused; Wherein, creating a component library further includes: Format component code to ensure component consistency, maintainability, and readability; Extract the code structure characteristics and function description of the components verified by the test, and obtain the code structure characteristic files and function description files of the corresponding component units; Formatting the test case of the component to obtain a test case file of the corresponding component unit; Generate a property description file of the component unit; The component unit folder composed of the code structure feature file, function description file, test case file and attribute description file of the component is compressed to generate corresponding component units, which are stored in the component library.

[0006] According to an embodiment of the present invention, extracting code features of components verified by testing further includes: Use ANTLR tool to convert component code into AST file; According to the node hierarchy of the AST file, convert its nodes into text vectors; The text vectors of multiple component code files are combined into a one- and two-dimensional array, and the two-dimensional array is converted into a word vector to obtain a feature vector of the code structure, which is saved as a .csv file.

[0007] According to an embodiment of the present invention, whenever a satellite field test project is obtained, its requirement documents and codes are analyzed, and the same or similar component units are matched from the component library to obtain a component set further comprising: Obtain satellite field test projects, split the requirement documents by functional points, and convert the resulting functional descriptions into vectors using word2Vec after word segmentation to obtain the feature vectors of the required functions; Calculate the similarity between the feature vector and the functional description in the component library to obtain the corresponding requirement similarity; The code file of the test project is converted through AST to obtain a code structure feature vector, and the similarity between the code structure feature vector and the code structure feature in the component library is calculated to obtain the corresponding code structure similarity; Combining the demand similarity and code structure similarity, the comprehensive similarity S is calculated using the following formula: in, is the demand similarity, is its weight; is the code structure similarity, is its weight; The calculated comprehensive similarities are sorted, and the component units corresponding to the calculation results greater than the preset threshold are taken to form a component set.

[0008] According to an embodiment of the present invention, based on the component set, according to the number of each component unit, the test cases bound to the number are extracted to obtain the test case set.

[0009] According to an embodiment of the present invention, one component unit is bound to one or more test cases.

[0010] According to an embodiment of the present invention, whenever a satellite field test project is obtained, its requirement documents and codes are analyzed, and the same or similar component units are matched from the component library to obtain a component set further comprising: Obtain satellite field test projects, split the requirement documents by functional points, and convert the resulting functional descriptions into vectors using word2Vec after word segmentation to obtain the feature vectors of the required functions; Calculate the similarity between the feature vector and the functional description in the component library to obtain the corresponding requirement similarity; Sort the obtained demand similarities, take the component units corresponding to the demand similarities greater than a preset threshold, and construct the first component set; Extract the code of the test project, use the Antlr tool to obtain the abstract syntax tree, convert the node information of the syntax tree into a vector, and obtain a code structure vector list; Extract the component description file in the code, convert it into word vectors, and obtain a list of component function vectors; Matching the code structure vector and the component function vector with the code structure features and function descriptions of the component library, extracting component units whose matching similarity is greater than a preset threshold, and constructing a second component set; According to the first component set and the second component set, corresponding test cases are extracted, and the test cases are deduplicated to obtain a test case set.

[0011] According to one embodiment of the present invention, when the code of the test project cannot match the corresponding component unit in the component library, the component unit is created for the code, and the code structure feature file, function description file, test case file and property description file of the component are obtained according to a preset format, and the corresponding component unit is generated and stored in the component library.

[0012] A test case reuse device for satellite field code components, comprising: The component library creation module is configured to create a component library, wherein the component library includes a plurality of component units, wherein the component units are relatively independent functional units in the software; and bind the component units in the component library with corresponding test cases; The component matching module is configured to analyze the requirement documents and codes of satellite field test projects whenever they are acquired, match the same or similar component units from the component library, and obtain a component set; The test case reuse module is configured to extract corresponding test cases from the component library based on the component set, so that the test cases in the component library can be reused; The component library creation module is further configured as follows: Format component code to ensure component consistency, maintainability, and readability; Extract the code structure characteristics and function description of the components verified by the test, and obtain the code structure characteristic files and function description files of the corresponding component units; Formatting the test case of the component to obtain a test case file of the corresponding component unit; Generate a property description file of the component unit; The component unit folder composed of the code structure feature file, function description file, test case file and attribute description file of the component is compressed to generate corresponding component units, which are stored in the component library.

[0013] Due to the adoption of the above technical solution, the present invention has the following advantages and positive effects compared with the prior art: The test case reuse method for satellite-domain code components in one embodiment of the present invention encapsulates code functions through specific code component expressions to obtain relatively independent functional units, namely component units, and creates a component library based on component units; binds component units in the component library with corresponding test cases; analyzes the requirement documents and codes of satellite-domain test projects every time, matches the same or similar component units from the component library to obtain a component set; extracts corresponding test cases from the component library based on the component set, so that the test cases in the component library can be reused. Due to the independence of the component unit, it is easier to perform unit testing, does not need to rely on other parts of the entire program, and can reuse test cases more accurately and efficiently. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] Figure 1 A flow chart of a test case reuse method for satellite domain code components in one embodiment of the present invention; Figure 2 The figure is a software testing flow chart in one embodiment of the present invention. DETAILED DESCRIPTION

[0015] The following is a further detailed description of a test case reuse method and device for satellite field code components proposed by the present invention in conjunction with the accompanying drawings and specific embodiments. The advantages and features of the present invention will become more apparent from the following description and claims.

[0016] Please see Figure 1 This embodiment provides a test case reuse method for satellite field code components, comprising the following steps: S1: Create a component library, which includes a number of component units established in a specific form, and the component unit is a relatively independent functional unit in the software; S2: Bind the component units in the component library with the corresponding test cases; S3: Whenever a satellite test project is obtained, its requirement documents and codes are analyzed, and the same or similar component units are matched from the component library to obtain a component set; S4: Based on the component set, the corresponding test cases are extracted from the component library so that the test cases in the component library can be reused.

[0017] In step S1, a component library is created by building component units in a specific form. Here, what can be built into component units are relatively independent, clearly identifiable, and have interfaces that are clearly dependent on the context, and can be independently deployed and assembled software entities in the software system. In the code, it is represented as a software entity composed of one or more files or functions.

[0018] A component unit is established in a specific form, which is packaged as a component folder, including component code files, code structure feature files, component function description files, component property description files and component test case files.

[0019] Specifically, the establishment of the component unit includes the following steps: Step 1.1: Format the component code. Component formatting is crucial to ensure component consistency, maintainability, and readability. The component formatting operation is as follows: Step 1.1.1: Unify the naming of components. Function, method, and variable names should clearly express their functions or purposes. Step 1.1.2: Unify component composition. Each component contains a main file, which defines the main functions of the component. Related auxiliary functions are placed in separate files in the same directory as the main file. In addition to the component code, each mature component should contain a component feature file, a component attribute description file, a component function description file, and a component test case file.

[0020] The component feature file represents the code features of the component, the component attribute description file records the classification, version and other information of the component, the component function description file describes the design method, function, parameters, interface and instructions of the component, and the component test case file records the test process of the component.

[0021] Step 1.2: Extract component code features. The extracted component code features are saved as component feature files for rapid matching of large-scale components. This includes the following steps: Step 1.2.1: First, use the ANTLR tool to convert the component code into AST form; Step 1.2.2: Convert the component AST obtained in step 1.2.1 into a text vector according to the AST node hierarchy, combine the text vectors of multiple component code files into a two-dimensional list, and use the word2Vec tool to convert the two-dimensional array into a word vector to obtain the code structure feature vector; Before using the word2Vec tool, you need to use the previously prepared satellite field training data and vocabulary to train the model to make it more suitable for the satellite field text description.

[0022] Step 1.2.3: Save the code structure feature vector in step 1.2.2 as a code structure feature file in .csv format.

[0023] Step 1.3: Extract the component document function description, and save the component design description, function description and other information as a function description file; Step 1.4: Format the component test case and record the component test case in the form of an EXCEL table. The test case attributes include the test case name, identifier, steps, results and other information; Step 1.5: Generate a component property description file, recording the component name, version, domain classification, code structure feature file name, function description file name, and component test case file name in yaml file format; Step 1.6: Compress the component folder obtained in the above steps and store it in the component library. The component library is a collection of component units formed by functional components that have been verified by testers to be correct.

[0024] In step S2, the component units in the component library are bound to the corresponding test cases. Each component unit in the component library is provided with a unique ID number, and is bound to its test case through the ID number. A component unit may have one test case or multiple test cases, depending on the actual situation. The test case set of the component unit can be obtained through the ID number to perform subsequent software testing.

[0025] In step S3, whenever a satellite field test project is obtained, its requirement documents and codes are analyzed, and the same or similar component units are matched from the component library to obtain a component set. The obtained satellite field test project is called the test project. Figure 2 ,For the project to be tested, analyze its requirement documents and codes, match the same or similar component units from the component library, and obtain the component set further including: Step 3.1: Obtain satellite field test projects, split the requirement documents by functional points, and after word segmentation, convert the split functional descriptions into vectors using word2Vec to obtain the feature vectors of the required functions; the splitting of the requirement documents by functional points can be completed by testers.

[0026] Step 3.2: Calculate the similarity between the feature vector and the functional description in the component library to obtain the corresponding requirement similarity.

[0027] Step 3.3: The code file of the test project is converted through AST to obtain a code structure feature vector, and the similarity between the code structure feature vector and the code structure feature in the component library is calculated to obtain the corresponding code structure similarity.

[0028] Step 3.4: Combine the requirement similarity and code structure similarity to calculate the comprehensive similarity S using the following formula: in, is the demand similarity, is its weight; is the code structure similarity, is its weight.

[0029] Step 3.5: Sort the calculated comprehensive similarities, and take the component units corresponding to the calculation results greater than the preset threshold to form a component set.

[0030] In step S4, based on the component set, corresponding test cases are extracted from the component library so that the test cases in the component library can be reused.

[0031] When the code of the project under test cannot match the corresponding component unit in the component library, a new component unit is created for the code, and the component's code structure feature file, function description file, test case file and property description file are obtained according to the preset format, and the corresponding component unit is generated and stored in the component library for use.

[0032] In addition to the above matching methods, you can also use the following methods: Obtain satellite field test projects, split the requirement documents by functional points, and convert the resulting functional descriptions into vectors using word2Vec after word segmentation to obtain the feature vectors of the required functions; Calculate the similarity between the feature vector and the functional description in the component library to obtain the corresponding requirement similarity; Sort the obtained demand similarities, take the component units corresponding to the demand similarities greater than a preset threshold, and construct the first component set; Extract the code of the test project, use the Antlr tool to obtain the abstract syntax tree AST, convert the node information of the syntax tree AST into a vector, and obtain a code structure vector list; Extract the component description file in the code, convert it into word vectors, and obtain a list of component function vectors; Matching the code structure vector and the component function vector with the code structure features and function descriptions of the component library, extracting component units whose matching similarity is greater than a preset threshold, and constructing a second component set; According to the first component set and the second component set, corresponding test cases are extracted, and the test cases are deduplicated to obtain a test case set.

[0033] After the test is completed, if componentizable code is found in the project under test, the function description, code structure characteristics, functional characteristics, test cases and other information are extracted in the established format and added to the component folder to become a component unit and stored in the component library.

[0034] Through the test case reuse method for satellite code components, the test cases generated in the satellite software testing process are fully utilized. The similarity is calculated according to the functional description and code structure of the components to obtain reusable test cases, which can reuse test cases more accurately and efficiently.

[0035] Based on the same concept, this embodiment also provides a test case reuse device for satellite field code components, including: The component library creation module is configured to create a component library, which includes a number of component units, which are relatively independent functional units in the software; bind the component units in the component library with corresponding test cases; The component matching module is configured to analyze the requirement documents and codes of satellite field test projects whenever they are acquired, match the same or similar component units from the component library, and obtain a component set; The test case reuse module is configured to extract corresponding test cases from the component library based on the component set, so that the test cases in the component library can be reused; The component library creation module is further configured as follows: Format component code to ensure component consistency, maintainability, and readability; Extract the code structure characteristics and function description of the components verified by the test, and obtain the code structure characteristic files and function description files of the corresponding component units; Format the test case of the component to obtain the test case file of the corresponding component unit; Generate property description files of component units; The component unit folder composed of the code structure feature file, function description file, test case file and attribute description file of the compressed component generates the corresponding component unit and stores it in the component library.

[0036] The device is used to implement the above-mentioned test case reuse method for satellite-domain code components. Its functions and implementation methods are similar and will not be repeated here.

[0037] The embodiments of the present invention are described in detail above in conjunction with the accompanying drawings, but the present invention is not limited to the above embodiments. Even if various changes are made to the present invention, if these changes fall within the scope of the claims of the present invention and their equivalents, they still fall within the protection scope of the present invention.

Claims

1. A test case reuse method for satellite field code components, characterized in that: include: Creating a component library, wherein the component library includes a plurality of component units, wherein the component units are relatively independent functional units in the software; Bind the component units in the component library with the corresponding test cases; Whenever a satellite field test project is obtained, its requirement documents and codes are analyzed, and the same or similar component units are matched from the component library to obtain a component set; Based on the component set, corresponding test cases are extracted from the component library, so that the test cases in the component library can be reused; Wherein, creating a component library further includes: Format component code to ensure component consistency, maintainability, and readability; Extract the code structure characteristics and function description of the components verified by the test, and obtain the code structure characteristic files and function description files of the corresponding component units; Formatting the test case of the component to obtain a test case file of the corresponding component unit; Generate a property description file of the component unit; The component unit folder composed of the code structure feature file, function description file, test case file and attribute description file of the component is compressed to generate corresponding component units, which are stored in the component library.

2. The test case reuse method for satellite domain code components as claimed in claim 1, characterized in that: The extracting of code features of the component verified by the test further comprises: Use ANTLR tool to convert component code into AST file; According to the node hierarchy of the AST file, convert its nodes into text vectors; The text vectors of multiple component code files are combined into a one- and two-dimensional array, and the two-dimensional array is converted into a word vector to obtain a feature vector of the code structure, which is saved as a .csv file.

3. The test case reuse method for satellite domain code components as claimed in claim 1, characterized in that: Whenever a satellite field test project is obtained, its requirement documents and codes are analyzed, and the same or similar component units are matched from the component library to obtain a component set further including: Obtain satellite field test projects, split the requirement documents by functional points, and convert the resulting functional descriptions into vectors using word2Vec after word segmentation to obtain the feature vectors of the required functions; Calculate the similarity between the feature vector and the functional description in the component library to obtain the corresponding requirement similarity; The code file of the test project is converted through AST to obtain a code structure feature vector, and the similarity between the code structure feature vector and the code structure feature in the component library is calculated to obtain the corresponding code structure similarity; Combining the demand similarity and code structure similarity, the comprehensive similarity S is calculated using the following formula: in, is the demand similarity, is its weight; is the code structure similarity, is its weight; The calculated comprehensive similarities are sorted, and the component units corresponding to the calculation results greater than the preset threshold are taken to form a component set.

4. The test case reuse method for satellite domain code components as claimed in claim 3, characterized in that: Based on the component set, according to the number of each component unit, the test cases bound to the number are extracted to obtain the test case set.

5. The test case reuse method for satellite domain code components as claimed in claim 4, characterized in that: A component unit is bound to one or more test cases.

6. The test case reuse method for satellite domain code components as claimed in claim 1, characterized in that: Whenever a satellite field test project is obtained, its requirement documents and codes are analyzed, and the same or similar component units are matched from the component library to obtain a component set further including: Obtain satellite field test projects, split the requirement documents by functional points, and convert the resulting functional descriptions into vectors using word2Vec after word segmentation to obtain the feature vectors of the required functions; Calculate the similarity between the feature vector and the functional description in the component library to obtain the corresponding requirement similarity; Sort the obtained demand similarities, take the component units corresponding to the demand similarities greater than a preset threshold, and construct the first component set; Extract the code of the test project, use the Antlr tool to obtain the abstract syntax tree, convert the node information of the syntax tree into a vector, and obtain a code structure vector list; Extract the component description file in the code, convert it into word vectors, and obtain a list of component function vectors; Matching the code structure vector and the component function vector with the code structure features and function descriptions of the component library, extracting component units whose matching similarity is greater than a preset threshold, and constructing a second component set; According to the first component set and the second component set, corresponding test cases are extracted, and the test cases are deduplicated to obtain a test case set.

7. The test case reuse method for satellite domain code components as claimed in claim 1, characterized in that: When the code of the test project cannot match the corresponding component unit in the component library, a component unit is created for the code, and the component code structure feature file, function description file, test case file and attribute description file are obtained according to the preset format, and the corresponding component unit is generated and stored in the component library.

8. A test case reuse device for satellite field code components, characterized in that: include: The component library creation module is configured to create a component library, wherein the component library includes a plurality of component units, and the component units are relatively independent functional units in the software; Bind the component units in the component library with the corresponding test cases; The component matching module is configured to analyze the requirement documents and codes of satellite field test projects whenever they are acquired, match the same or similar component units from the component library, and obtain a component set; The test case reuse module is configured to extract corresponding test cases from the component library based on the component set, so that the test cases in the component library can be reused; The component library creation module is further configured as follows: Format component code to ensure component consistency, maintainability, and readability; Extract the code structure characteristics and function description of the components verified by the test, and obtain the code structure characteristic files and function description files of the corresponding component units; Formatting the test case of the component to obtain a test case file of the corresponding component unit; Generate a property description file of the component unit; The component unit folder composed of the code structure feature file, function description file, test case file and attribute description file of the component is compressed to generate corresponding component units, which are stored in the component library.