Object layer construction method of test framework, electronic device and storage medium

By automatically building and optimizing the object layer using two-layer generative adversarial network model and language model, the existing automated testing framework is solved and the problem of time-consuming and error-prone in the object layer construction process is improved, and the stability and adaptability of the test framework is improved. Ensure the accuracy and effectiveness of the test results.

CN119046169BActive Publication Date: 2025-02-11FUZHOU CHANGXIN INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411523239.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-30
Publication Date
2025-02-11
Estimated Expiration
2044-10-30

AI Technical Summary

Technical Problem

The existing automated testing framework is time-consuming and error-prone in the construction of the object layer, and lacks adaptability and intelligence in the face of complex or dynamically changing test requirements, resulting in inconsistent test results with the system status, affecting the effectiveness of the test Sex and accuracy.

Method used

The two-layer generation adversarial network model and language model are used to automatically analyze the structure of the system under test, identify the units and their relationships, generate the initial object layer, and adjust the object layer through iterative optimization to ensure that it is highly consistent with the actual system.

Benefits of technology

It significantly reduces the workload of developers, improves the stability and reliability of the test framework, enhances its adaptability and intelligence, and enables it to be widely used in large and complex systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119046169B_ABST
    Figure CN119046169B_ABST
Patent Text Reader

Abstract

The present application relates to the field of software testing, and provides an object layer construction method, electronic device and storage medium of a test framework. The method analyzes the structure of the system under test through a two-layer generative adversarial network model, identifies the units of the system under test and their mutual relationships, generates an initial object layer according to the system under test architecture and historical data; divides the initial object layer into functional modules that can be independently developed, tested and maintained; extracts the semantic information of the units from the design documents and code comments of the system under test through a language model, and integrates the semantic information into the attributes and method definitions of the functional module object layer; executes the system under test, and iteratively optimizes and adjusts the object layer. This method can significantly improve the overall performance and reliability of the test framework, reduce manual intervention and the occurrence of errors, and maintain the accuracy and effectiveness of the test results. It not only reduces the complexity of object layer construction and maintenance, but also enhances the adaptability and intelligence level of the test framework.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of software automated testing, and in particular to an object layer construction method, electronic device and storage medium of a test framework. Background Art

[0002] In order to save manpower, time or hardware resources and improve testing efficiency, automated testing has become a trend in software testing. Automated testing is to execute pre-written script commands to replace manual operations in manual testing. Functional verification can be automatically performed without human intervention during the automated testing process. The application of automated testing frameworks is to better support automated testing. The frameworks often contain some advanced design patterns, development ideas, and best practice strategies. In existing automated testing frameworks, the construction of the object layer is often a manual and complex process, requiring developers to have a deep understanding of the structure of the system under test and to implement the construction of the object layer through manual code writing.

[0003] However, the existing methods are not only time-consuming and error-prone, but also increase the difficulty of maintaining the test framework. Especially in large and complex systems, as the system continues to evolve and update, the workload and complexity of manually maintaining the object layer increase dramatically, which greatly affects the stability and maintainability of the test framework. In addition, the existing automated testing framework lacks sufficient adaptability and intelligent means when facing complex or dynamically changing test requirements. The management of test objects and the writing and maintenance of test scripts mainly rely on manual experience and manual operations, which not only increases the cost of testing, but also limits the application of the test framework in large and complex systems. Especially when the system under test is updated or a new module is introduced, the existing framework cannot reflect the changes in the system in a timely and accurate manner, resulting in inconsistencies between the test results and the system status, which in turn affects the effectiveness and accuracy of the test. Summary of the invention

[0004] In order to help improve the problem that existing object layer construction is time-consuming and error-prone, the present application provides an object layer construction method, electronic device and storage medium for a test framework.

[0005] In a first aspect, the present application provides a method for constructing an object layer of a test framework, using the following technical solution:

[0006] The structure of the system under test is analyzed through a two-layer generative adversarial network model, the units of the system under test and their relationships are identified, and the initial object layer is generated according to the architecture of the system under test and historical data;

[0007] Divide the initial object layer into at least two functional modules that can be independently developed, tested and maintained, each functional module corresponding to at least one unit in the system under test;

[0008] Extracting semantic information of units from design documents and / or code comments of the system under test through language models, and integrating the semantic information into the attribute and method definitions of the functional module object layer;

[0009] Execute the system under test and iteratively optimize and adjust the object layer.

[0010] By adopting the above technical solution, the tedious process of traditional manual code writing is avoided, greatly reducing the workload of developers; ensuring that the generated object layer structure is highly consistent with the actual system, effectively reducing errors caused by manual operations, thereby improving the stability and reliability of the test framework.

[0011] In a second aspect, the present application provides an electronic device, which adopts the following technical solution:

[0012] An electronic device, comprising:

[0013] at least one processor;

[0014] Memory;

[0015] At least one application program, wherein the at least one application program is stored in a memory and configured to be executed by at least one processor, the at least one application program being configured to: execute an object layer construction method of a test framework.

[0016] In a third aspect, the present application provides a computer-readable storage medium, which adopts the following technical solution:

[0017] A computer-readable storage medium stores a computer program, which, when executed in a computer, causes the computer to execute any object layer construction method of a test framework provided in the first aspect.

[0018] In summary, the method proposed in this application combines a two-layer generative adversarial network model and a language model to automatically form an object layer and iteratively optimize and adjust, which can significantly improve the overall performance and reliability of the test framework, reduce manual intervention and the occurrence of errors, and ensure that the test framework can quickly adapt to changes when the system is updated, maintaining the accuracy and effectiveness of the test results. This solution not only reduces the complexity of object layer construction and maintenance, but also enhances the adaptability and intelligence level of the test framework, enabling it to be more widely used in large and complex systems. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 It is a flowchart of the object layer construction method of the test framework provided in the embodiment of the present application;

[0020] Figure 2It is a flowchart of another embodiment of the object layer construction method of the test framework of the present application.

[0021] Figure 3 It is a schematic diagram of the module principle of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION

[0022] In order to make the purpose, technical solutions and advantages of this application more clear, the following Figure 1-3 It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0023] The embodiment of the present application provides an object layer construction method of a test framework, which is used in the testing of a business platform system.

[0024] This embodiment uses the test of the business platform system as an application example to specifically illustrate the above method. In actual implementation, the above method can also be used in the construction of an automated test framework for other software, which is not limited in this embodiment.

[0025] Specific reference Figure 1 and Figure 2 As shown, a method for constructing an object layer of a test framework, the method comprising:

[0026] S10: Analyze the structure of the system under test through a two-layer generative adversarial network model, identify the units of the system under test and their relationships, and generate the initial object layer according to the system under test architecture and historical data;

[0027] S20: Divide the initial object layer into at least two functional modules that can be independently developed, tested and maintained, each functional module corresponds to at least one unit in the system under test; it should be noted that the unit in the present invention includes a module and / or a component.

[0028] S30: extracting semantic information of the unit from the design documents and / or code comments of the system under test through the language model, and integrating the semantic information into the attribute and method definition of the object layer of the functional module;

[0029] S40: Execute the system under test and iteratively optimize and adjust the object layer.

[0030] S50: When the system under test is updated or a new unit is introduced, the changes are detected and corresponding functional modules are generated to keep the object layer structure consistent with the system update;

[0031] In the embodiment of the present invention, a visual object layer design and management tool is also provided, which allows the user to drag and drop, adjust and manage the object layer structure of the functional module through a graphical interface, and the tool automatically analyzes the user's adjustment and updates the underlying code;

[0032] In addition, it stores the optimized and adjusted object layer structure as a maintainable configuration file or database record and loads it for use in subsequent tests.

[0033] The method of this embodiment can significantly improve the overall performance and reliability of the test framework, reduce manual intervention and the occurrence of errors, and ensure that the test framework can quickly adapt to changes when the system is updated, maintaining the accuracy and effectiveness of the test results. This solution not only reduces the complexity of object layer construction and maintenance, but also enhances the adaptability and intelligence level of the test framework, enabling it to be more widely used in large and complex systems.

[0034] On the basis of the embodiment of the present method, further, the specific implementation of step S10 includes:

[0035] S11: Obtain the structure data G(V, E) of the system under test;

[0036] Among them, V represents the set of units in the system under test, and E represents the set of relationships between units; the mapping of the structure data of the system under test is expressed as:

[0037] ;

[0038] in, Represents a unit, Indicates mutual relationship, express and The correlation weight between express and The correlation function between

[0039] In this embodiment, the relevance function is implemented using cosine similarity:

[0040] ;

[0041] It can be understood that cosine similarity is used to evaluate the similarity between vectors, such as whether the feature vectors between components and relations have the same direction in the vector space;

[0042] S12: Construct a two-layer generative adversarial network model, including the first generator , the first discriminator , the second generator and the second discriminator ;

[0043] Among them, the first generator With random noise and historical data As input, generate a preliminary system structure representation :

[0044] ;

[0045] Among them, σ is the activation function, and is the weight matrix of the first layer generator, is random noise The characteristic representation of For historical data feature extraction, is the bias term;

[0046] In this embodiment, the activation function may be implemented using functions such as ReLU, Sigmoid, Tanh, or other activation functions, which are not limited to those described in this embodiment;

[0047] The first discriminator Judgment generation system structure representation Similarity to the real structure:

[0048] ;

[0049] in, The random noise input of the generator is used to guide the generator to generate a diverse object layer structure; It is historical data, which is used by the generator to refer to past system information and component relationships when generating the object layer structure; , The first layer generator and discriminator are used to generate preliminary system structure and make discrimination; The function is the expected value, which means the calculation of samples in the generated distribution and the true distribution; the p() function represents the probability distribution; is the loss function, which represents the optimization objective between the generator and the discriminator, and improves the quality of the generated results by minimizing the loss of the generator; G(V, E) is the graph model; Represents that the variable x is sampled from the graphical model G(V,E) of the real system structure; Denotes that the noise vector is sampled from the noise distribution.

[0050] Second Generator Receive the preliminary system structure representation generated by the first layer , and optimize to generate the object layer structure :

[0051] ;

[0052] Among them, γ is the activation function of the second layer generator, is the weight matrix, To represent the preliminary system structure feature extraction, is a bias term; in this embodiment, ReLU, Sigmoid or Tanh function is used as the activation function;

[0053] The second discriminator Determine the generated object layer structure Similarity with the real object layer structure:

[0054] ;

[0055] in, It is a preliminary system structure representation; , The second layer generator and discriminator are used to generate preliminary system structure and make discrimination; The function is the expected value, which means the calculation of samples in the generated distribution and the true distribution; the p() function represents the probability distribution; represents y sampled from the graphical model G(V,E) of the real system structure; y represents the system structure sample sampled from the real distribution; represents the samples sampled from the distribution of the preliminary system structure representation generated by the first layer; is the loss function, which represents the optimization objective between the generator and the discriminator, and improves the quality of the generated results by minimizing the loss of the generator.

[0056] S13: Adjust the first generator through iterative training , the first discriminator , the second generator and the second discriminator The weight matrix , , and bias term , , so that the generated object layer structure The similarity with the real system structure G(V, E) is maximized:

[0057] ;

[0058] S14: When the first generator and the second generator When the preset optimization goal is reached, the initial object layer structure is output :

[0059] ;

[0060] in, Represents the system structure after the nth iteration optimization; according to the tested system architecture and historical data, Mapped to the units in the object layer and their relationships.

[0061] It can be understood that the present invention uses a two-layer generative adversarial network model to automatically analyze the structure and component relationships of the system under test and generate an initial object layer structure, thereby avoiding the tedious process of traditional manual code writing and greatly reducing the workload of developers. It also ensures that the generated object layer structure is highly consistent with the actual system through continuous optimization of the generative adversarial network model, effectively reducing errors caused by manual operations, thereby improving the stability and reliability of the test framework.

[0062] On the basis of the embodiment of the present method, further, the specific implementation of step S20 includes:

[0063] S21: Initial object layer structure Analyze and determine the functional dependencies of each unit in the initial object layer, and express it as the dependency matrix R=[{r}_{ij}] ,in Representation unit With unit Dependence between The calculation is:

[0064] ;

[0065] in, represents the kth unit in the object layer, δ(M,C) indicates whether module M depends on unit C, when M depends on C, δ(M,C)=1, otherwise δ(M,C)=0, n represents the total number of units in the object layer;

[0066] S22: Based on the dependency matrix R, the initial object layer structure Modular clustering is performed to aggregate modules with high dependency into the same functional module. The modularized functional module set is expressed as ;

[0067] S23: For each functional module Allocate independent development and testing environments, and define interfaces between functional modules To call each other:

[0068] ;

[0069] in, Represents the parameters of the interface, Representative parameters The data type, Representative function module The required parameter set, Represents the corresponding data type set;

[0070] S24: According to the changes of the system under test, the functional module collection Dynamic adjustment is performed, and the adjusted functional module set is expressed as .

[0071] The modular processing method proposed in the present invention improves the scalability and maintainability of the object layer by dividing the initial object layer structure into several independent functional modules and allowing each functional module to be independently developed, tested and maintained.

[0072] On the basis of the embodiment of the present method, further, the specific implementation of step S30 includes:

[0073] S31: Preprocess the design documents and / or code comments of the system under test and convert them into text data sets ; Each text data item Represents the descriptive information of a unit in the system under test;

[0074] S32: Collecting text data Enter the BERT model , for each text data item Perform semantic vectorization processing to generate the corresponding semantic vector :

[0075] ;

[0076] in, represents the weighted sum of the multi-layer outputs of the BERT model, and is the hierarchical weight coefficient, represents the semantic vector output of the lth layer, is the inter-layer feature fusion function, is the model feature extraction function, is the semantic bias term of the text data item, and L represents the number of layers included in the BERT model;

[0077] Among them, in this embodiment, the inter-layer feature fusion function, feature extraction function, etc. can use conventional fusion functions and extraction functions, which are not described here one by one;

[0078] S33: Generate semantic vector Perform cluster analysis to group semantic vectors with similar semantics together to form semantic clusters :

[0079] ;

[0080] in, is the semantic vector With semantic vector The weight coefficient between is the semantic vector With semantic vector The cosine similarity between them, θ is the preset similarity threshold, Representing semantic clusters The number of vectors contained in ; cosine similarity is the cosine similarity function;

[0081] S34: Each semantic cluster The semantic information is integrated into the functional module set Functional modules in In the object layer:

[0082] ;

[0083] in, and Semantic clusters and The weight coefficient of and is the correlation coefficient between the vector within the semantic cluster and the attribute or method, and Represent the semantic vectors in the semantic cluster With semantic vector The corresponding attribute and method definitions, and Attribute and Method respectively represent the abstract definitions of object attributes and object methods in the object layer construction. Attribute represents the attribute definition of each functional module in the object layer, and Method represents the operation or behavior of each functional module in the object layer.

[0084] It should be noted that the present invention uses a pre-trained BERT model to extract the semantic information of components from system design documents and code comments, and automatically integrates the semantic information into the object layer properties and method definitions of each functional module, ensuring the semantic accuracy and consistency of the object layer and avoiding test failures due to semantic misunderstanding errors.

[0085] On the basis of the embodiment of the present method, further, the specific implementation of step S40 includes:

[0086] S41: During the execution of the system under test, the state data and test data of the system under test are monitored in real time, and the system state vector is recorded. and the test result vector ;in, represents the state of the system at time point t, Represents the test result of the system at time point t;

[0087] S42: The system state vector and the test result vector Input the intelligent optimization algorithm model, and the intelligent optimization algorithm model calculates the optimization target value according to the preset objective function ;

[0088] S43: Based on the optimization target value , dynamically adjust the function module set The object layer structure and content in the object layer structure are generated to optimize the object layer structure ,The adjustment includes reallocating dependencies among functional modules, modifying the ,definition of object layer attributes or methods, and updating the ,semantic information in the object layer;

[0089] S44: Optimized object layer structure Verify that the adjusted object layer adapts to system changes by executing regression tests; the success rate of regression tests The preset threshold must be met :

[0090] ;

[0091] in, is the result of the i-th regression test, and when successful =1, when failed =0, n is the number of regression tests, The preset threshold for the success rate of regression testing;

[0092] S45: When the optimized object layer structure After meeting the requirements of regression testing, the object layer structure is deployed to the automated testing framework to replace the original object layer structure.

[0093] It can be understood that this embodiment automatically detects changes in the system by real-time monitoring of updates to the system under test or the introduction of new modules, generates corresponding functional modules, and quickly integrates new functional modules or updated components into the object layer structure, ensuring the synchronous update of the object layer and the system structure, reducing the need for manual intervention, and avoiding inaccurate testing caused by mismatch between the object layer and the system.

[0094] On this basis, further, the above intelligent optimization algorithm model is constructed in the following ways:

[0095] Define the system state vector {S}_{t}=[{s}_{t1}, {s}_{t2}, ...., {s}_{tn}] And the test result vector {R}_{t}=[{r}_{t1},{r}_{t2},....,{r}_{tm}] ,in Contains multiple status indicators of the system at time point t, Contains multiple test results at corresponding time points;

[0096] Setting the objective function of the intelligent optimization algorithm model for:

[0097] ;

[0098] in, , and is the weight coefficient, O is the current object layer structure parameter, is the object layer structure parameter at the previous time point, and Respectively represent the changes of system status and test results at consecutive time points;

[0099] Calculate the objective function The gradient of the object layer structure parameter O :

[0100] ;

[0101] The above calculation is performed using the commonly used gradient calculation formula. To affect the gradient.

[0102] The object layer structure parameter O is iteratively updated by the gradient descent method, and the update rule is:

[0103] ;

[0104] in, is the learning rate, is the object layer structure parameter at the kth iteration;

[0105] According to the optimization target value , dynamically adjust the object layer structure to keep it consistent with the changes in system status and test results, and finally generate an optimized object layer structure In each iteration, the weight coefficient in the objective function is dynamically adjusted according to the current optimization result. , and .

[0106] The present invention introduces an intelligent optimization algorithm model, which analyzes test data and system status in real time and dynamically adjusts the object layer structure and content of functional modules, so that the object layer structure and content can adapt to changes in the system, ensuring that the test framework can still perform tests efficiently and accurately when facing complex or frequently changing systems.

[0107] On the basis of the embodiment of the present method, further, the specific implementation of step S50 includes:

[0108] S51: Monitor the changes of the units of the system under test in real time, and set the change event of the system under test as ,in Represents the set of change events of the system at time point t, including newly added and updated units;

[0109] S52: Change event to the system under test Parse to identify the new or updated units in the change event and represent them as update vectors ,in The attribute vector representing the i-th change event, which contains the module name, dependency relationship and function description information;

[0110] S53: Input the update vector into the pre-trained detection model, and the detection model generates the corresponding function module according to the attribute characteristics of the change event The initial object layer structure of the generation process is optimized as follows:

[0111] ;

[0112] in, Based on the change event The generated object layer structure, The object layer structure for reference, represents the difference between the generated structure and the reference structure, is the association weight between functional modules, Represents the generated functional module With existing functional modules The distance function between

[0113] S54: Optimize and integrate the generated functional modules, merge the optimized and integrated functional modules with the existing object layer structure, and the integrated object layer structure is represented as :

[0114] ;

[0115] in, Represents an optimized existing object hierarchy. It is the object layer of the generated new functional module.

[0116] For example, in one example, the tester constructed and optimized the object layer structure in the "user recommendation" module through the method of the present invention, and performed the following training and adjustments:

[0117] Initial training samples: The system extracted the purchase and browsing behaviors of 1,000 typical users from the data of shopping festival devices in the past year and generated an initial object layer structure. The structure extracted the semantic information of user behavior through the BERT model and integrated it into the attribute and method definitions of the object layer.

[0118] Optimize training samples: During the test, the system detected that the recommendation response time of 100 users exceeded expectations. Through the intelligent optimization algorithm, the system automatically adjusted the object layer structure of the recommendation algorithm and generated new training samples. The samples included optimized user behavior patterns and recommendation logic.

[0119] Final test sample: On the day of the shopping festival, the system monitored the recommendation responses of 10,000 users in real time. Finally, within 15 minutes, the system automatically adjusted the object layer structure for 1,000 users whose response time exceeded 1 second, ensuring that the recommendation response time of all users was within 1 second.

[0120] Through the application of this method, the e-commerce platform successfully handled a large number of user visits and order transactions during the shopping festival. The stability and adaptability of the system were significantly improved. All optimizations and adjustments were completed within a few minutes, which greatly reduced the need for manual intervention and ensured the efficient operation of the platform.

[0121] The present application also provides an electronic device, such as Figure 3 As shown, Figure 3 The electronic device 700 shown includes: a processor 701 and a memory 703. The processor 701 and the memory 703 are connected, such as through a bus 702. Optionally, the electronic device 700 may also include a transceiver 704. It should be noted that in actual applications, the transceiver 704 is not limited to one, and the structure of the electronic device 700 does not constitute a limitation on the embodiments of the present application.

[0122] Processor 701 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It may implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 701 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and the like.

[0123] The bus 702 may include a path to transmit information between the above components. The bus 702 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus 702 may be divided into an address bus, a data bus, etc. For ease of representation, Figure 3 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0124] The memory 703 can be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto.

[0125] The memory 703 is used to store the application code for executing the solution of the present application, and the execution is controlled by the processor 701. The processor 701 is used to execute the application code stored in the memory 703 to implement the contents shown in the above method embodiment.

[0126] The electronic devices include, but are not limited to, mobile terminals such as mobile phones, notebook computers, PDAs (personal digital assistants), PADs (tablet computers), etc., and fixed terminals such as digital TVs, desktop computers, etc. It can also be a server, etc. Figure 3 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0127] An embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed in a computer, the computer is caused to execute the object layer construction method of the test framework provided in the above embodiment.

[0128] The present invention uses a two-layer generative adversarial network model to automatically analyze the structure and component relationships of the system under test and generate an initial object layer structure, thereby avoiding the tedious process of traditional manual code writing and greatly reducing the workload of developers. By continuously optimizing the generative adversarial network model, the generated object layer structure is ensured to be highly consistent with the actual system, effectively reducing errors caused by manual operations, thereby improving the stability and reliability of the test framework.

[0129] Its modular processing method improves the scalability and maintainability of the object layer by dividing the initial object layer structure into several independent functional modules and allowing each functional module to be independently developed, tested and maintained. In addition, the present invention introduces an intelligent optimization algorithm model to dynamically adjust the object layer structure and content of the functional module by real-time analysis of test data and system status, so that the object layer structure and content can adapt to changes in the system, ensuring that the test framework can still perform tests efficiently and accurately when facing complex or frequently changing systems.

[0130] The embodiment uses a pre-trained BERT model to extract semantic information of components from system design documents and code comments, and automatically integrates the semantic information into the object layer properties and method definitions of each functional module, ensuring the semantic accuracy and consistency of the object layer and avoiding test failures due to errors in semantic understanding.

[0131] Finally, by real-time monitoring of updates to the system under test or the introduction of new modules, changes in the system are automatically detected, and corresponding functional modules are generated. New functional modules or updated components are quickly integrated into the object layer structure to ensure synchronous updates of the object layer and the system structure, reducing the need for manual intervention and avoiding inaccurate testing problems caused by mismatches between the object layer and the system.

[0132] It should be understood that although the steps in the flowchart of the accompanying drawings are shown in sequence according to the instructions of the arrows, these steps are not necessarily performed in the order indicated by the arrows. Unless otherwise clearly stated in this document, the execution of these steps is not strictly limited in order and can be performed in other orders.

[0133] The above are only some implementation methods of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A method for constructing an object layer of a test framework, characterized in that: The method comprises: S10: Analyze the structure of the system under test through a two-layer generative adversarial network model, identify the units of the system under test and their relationships, and generate the initial object layer according to the system under test architecture and historical data; S20: Divide the initial object layer into at least two functional modules that can be independently developed, tested, and maintained, each functional module corresponding to at least one unit in the system under test; S30: extracting semantic information of the unit from the design documents and / or code comments of the system under test through the language model, and integrating the semantic information into the attribute and method definition of the object layer of the functional module; S40: Execute the system under test to iteratively optimize and adjust the object layer, wherein step S40 includes: S41: During the execution of the system under test, the state data and test data of the system under test are monitored in real time, and the system state vector is recorded. and the test result vector ;in, represents the state of the system at time point t, Represents the test result of the system at time point t; S42: The system state vector and the test result vector Input the intelligent optimization algorithm model, and the intelligent optimization algorithm model calculates the optimization target value according to the preset objective function ; S43: Based on the optimization target value , dynamically adjust the function module set The object layer structure and content in the object layer structure are generated to optimize the object layer structure ,The adjustment includes reallocating dependencies among functional modules, modifying the ,definition of object layer attributes or methods, and updating the ,semantic information in the object layer; S44: Optimized object layer structure Verify that the adjusted object layer adapts to system changes by executing regression tests; the success rate of regression tests The preset threshold must be met : ; in, is the result of the i-th regression test, and when successful =1, when failed =0, n is the number of regression tests, The preset threshold for the success rate of regression testing; S45: When the optimized object layer structure After meeting the requirements of regression testing, the object layer structure is deployed to the automated testing framework to replace the original object layer structure.

2. The object layer construction method of the test framework according to claim 1, characterized in that: The structure data of the system under test is represented by the graph model G(V, E), where V represents the set of units in the system under test and E represents the set of relationships between units. The mapping of the structure data of the system under test is expressed as: ; in, Represents a unit, Indicates mutual relationship, express and The correlation weight between express and The correlation function between .

3. The object layer construction method of the test framework according to claim 2, characterized in that: Step S10 includes: S11: Obtain the structure data G(V, E) of the system under test; S12: Construct a two-layer generative adversarial network model, including the first generator , the first discriminator , the second generator and the second discriminator ; Among them, the first generator With random noise and historical data As input, generate a preliminary system structure representation : ; Among them, σ is the activation function, and is the weight matrix of the first layer generator, is random noise The characteristic representation of For historical data feature extraction, is the bias term; The first discriminator Judgment generation system structure representation Similarity to the real structure: ; in, is the loss function, which represents the optimization objective between the generator and the discriminator; is the expected value function; p() represents the probability distribution function; Represents that the variable x is sampled from the graphical model G(V,E) of the real system structure; indicates that the noise vector is sampled from the noise distribution; Second Generator Receive the preliminary system structure representation generated by the first layer , and optimize to generate the object layer structure : ; Among them, γ is the activation function of the second layer generator, is the weight matrix, To represent the preliminary system structure feature extraction, is the bias term; The second discriminator Determine the generated object layer structure Similarity with the real object layer structure: ; in, is the loss function, which represents the optimization objective between the generator and the discriminator; is the expected value function; p() represents the probability distribution function; represents y sampled from the graphical model G(V,E) of the real system structure; y represents the system structure sample sampled from the real distribution; represents the samples sampled from the distribution of the preliminary system structure representation generated by the first layer; S13: Adjust the first generator through iterative training , the first discriminator , the second generator and the second discriminator The weight matrix , , and bias term , , so that the generated object layer structure The similarity with the real system structure G(V,E) is maximized: ; S14: When the first generator and the second generator When the preset optimization goal is reached, the initial object layer structure is output : ; in, Represents the system structure after the nth iteration optimization; according to the tested system architecture and historical data, Mapped to the units in the object layer and their relationships.

4. The object layer construction method of the test framework according to claim 1, characterized in that: Step S20 includes: S21: Initial object layer structure Analyze and determine the functional dependencies of each unit in the initial object layer and express them as a dependency matrix ,in Representation unit With unit Dependence between The calculation is: ; in, represents the kth unit in the object layer, δ(M,C) represents whether module M depends on unit C, when M depends on C, δ(M,C)=1, otherwise δ(M,C)=0; n represents the total number of units in the object layer; S22: Based on the dependency matrix R, the initial object layer structure Modular clustering is performed to aggregate modules with high dependency into the same functional module. The modularized functional module set is expressed as ; S23: For each functional module Allocate independent development and testing environments, and define interfaces between functional modules To call each other: ; in, Represents the parameters of the interface, Representative parameters The data type, Representative function module The required parameter set, Represents the corresponding data type set; S24: According to the changes of the system under test, the functional module collection Dynamic adjustment is performed, and the adjusted functional module set is expressed as .

5. The object layer construction method of the test framework according to claim 1, characterized in that: Step S30 includes: S31: Preprocess the design documents and / or code comments of the system under test and convert them into text data sets ; Each text data item Represents the descriptive information of a unit in the system under test; S32: Collecting text data Enter the BERT model , for each text data item Perform semantic vectorization processing to generate the corresponding semantic vector : ; in, represents the weighted sum of the multi-layer outputs of the BERT model, and is the hierarchical weight coefficient, represents the semantic vector output of the lth layer, is the inter-layer feature fusion function, is the model feature extraction function, is the semantic bias term of the text data item, and L represents the number of layers included in the BERT model; S33: Generate semantic vector Perform cluster analysis to group semantic vectors with similar semantics together to form semantic clusters : ; in, is the semantic vector With semantic vector The weight coefficient between is the semantic vector With semantic vector The cosine similarity between them, θ is the preset similarity threshold, Representing semantic clusters The number of vectors contained in ; S34: Each semantic cluster The semantic information is integrated into the functional module set Functional modules in In the object layer: ; in, and Semantic clusters and The weight coefficient of and is the correlation coefficient between the vector within the semantic cluster and the attribute or method, and Represent the semantic vectors in the semantic cluster With semantic vector The corresponding property and method definitions.

6. The object layer construction method of the test framework according to claim 1, characterized in that: in, The construction method of the intelligent optimization algorithm model includes: Define the system state vector and the test result vector ,in Contains multiple status indicators of the system at time point t, Contains multiple test results at corresponding time points; Setting the objective function of the intelligent optimization algorithm model for: ; in, , and is the weight coefficient, O is the current object layer structure parameter, is the object layer structure parameter at the previous time point, and Respectively represent the changes of system status and test results at consecutive time points; Calculate the objective function The gradient of the object layer structure parameter O : ; The object layer structure parameter O is iteratively updated by the gradient descent method, and the update rule is: ; in, is the learning rate, is the object layer structure parameter at the kth iteration; According to the optimization target value , dynamically adjust the object layer structure to keep it consistent with the changes in system status and test results, and finally generate an optimized object layer structure In each iteration, the weight coefficient in the objective function is dynamically adjusted according to the current optimization result. , and .

7. The object layer construction method of the test framework according to claim 1, characterized in that: When the system under test is updated or a new unit is introduced, the changes are detected and the corresponding functional modules are generated to keep the object layer structure consistent with the system update.

8. An electronic device, characterized in that: The electronic device includes: at least one processor; Memory; At least one application, wherein the at least one application is stored in a memory and configured to be executed by at least one processor, and the at least one application is configured to: execute the object layer construction method of the test framework according to any one of claims 1 to 7.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed in a computer, the computer is caused to execute the object layer construction method of the test framework according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Interactive hierarchical topic modeling visual analysis method and device based on BERTopic

    CN117407520A

  • Test case generation method and device, storage medium and equipment

    CN118170668A