Automatic testing method and device

By automatically generating calling functions and orchestrating calling flow methods, the problem of high labor cost for writing traditional automated test cases is solved, and an efficient and automated test process is achieved.

CN119557224APending Publication Date: 2025-03-04KE COM (BEIJING) TECHNOLOGY CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411711803.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-27
Publication Date
2025-03-04

AI Technical Summary

Technical Problem

The writing of traditional automated test cases requires a lot of manual intervention, which is time-consuming and labor-intensive, error-prone, and is difficult to maintain and update test scripts.

Method used

By obtaining test cases generation requests, generating task information, including task dependency information, interface documents and test parameters, automatically generate calling functions, and orchestrate the call flow based on task dependency information to execute tests.

Benefits of technology

It greatly reduces the workload and difficulty of manually writing interface automation use cases, improves the degree of automation and efficiency of tests, and simplifies the maintenance and update of test scripts.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119557224A_ABST
    Figure CN119557224A_ABST
Patent Text Reader

Abstract

The invention provides an automatic test method and device. The method comprises the following steps: acquiring a test case generation request; generating task information according to the test case generation request; wherein the task information comprises task dependency information corresponding to each task, an interface document corresponding to each task and a test parameter extracted based on the test case generation request; according to the interface document corresponding to each task and a test parameter extracted based on the test case generation request, generating a calling function corresponding to each task; and according to the task dependency information corresponding to each task, arranging the corresponding call function, generating a call stream, and executing the call stream to obtain a test result. According to the method and the system, automatic testing is realized, the workload and the difficulty of manually writing interface automatic cases are greatly reduced, the flexibility, the customizability, the automation degree, the accuracy, the maintainability and the efficiency of testing are improved, meanwhile, problems are conveniently positioned and solved, and the quality and the effect of software testing are favorably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to an automatic testing method and device. Background Art

[0002] With the development of the Internet, the number and complexity of web applications are increasing, and the demand for testing web applications is also increasing. As an effective solution to today's testing needs, automated testing can simulate user operations and conduct comprehensive and rapid testing of web applications.

[0003] However, traditional automated test cases usually require a lot of manual intervention, including writing test scripts, mock test data, etc. Test scripts are usually written manually by testers, which requires testers to have high programming skills. It is not only time-consuming and labor-intensive, but also prone to errors. In addition, the maintenance and updating of test scripts are also difficult. Summary of the invention

[0004] The present invention provides an automated testing method and device, which are used to solve the defect of high manual cost of writing automated test cases in the prior art, realize automated testing, and greatly reduce the workload and difficulty of manually writing interface automation cases.

[0005] The present invention provides an automated testing method, comprising: obtaining a test case generation request; generating task information according to the test case generation request; wherein the task information comprises task dependency information corresponding to each task, an interface document corresponding to each task and a test parameter extracted based on the test case generation request; generating a call function corresponding to each task according to the interface document corresponding to each task and the test parameter extracted based on the test case generation request; arranging the corresponding call function according to the task dependency information corresponding to each task, generating a call flow and executing it, and obtaining a test result.

[0006] According to an automated testing method provided by the present invention, task information is generated according to a test case generation request, including: performing scenario recognition on the test case generation request to obtain a scenario recognition result; querying a knowledge base according to the scenario recognition result and the test case generation request to obtain task dependency information corresponding to each task and an interface document corresponding to each task; wherein the knowledge base is first constructed based on business logic information; and performing parameter extraction on the test case generation request to obtain test parameters.

[0007] According to an automated testing method provided by the present invention, scene recognition is performed on a test case generation request to obtain a scene recognition result, including: inputting the test case generation request into a scene recognition model to obtain a scene recognition result output by the scene recognition model; wherein the scene recognition model is trained based on historical request text and scene labels corresponding to the historical request text.

[0008] According to an automated testing method provided by the present invention, parameters are extracted from a test case generation request to obtain test parameters, including: inputting the test case generation request into a parameter extraction model to obtain test parameters output by the parameter extraction model; wherein the parameter extraction model is trained based on historical request texts and parameter labels corresponding to the historical request texts; the parameter extraction model performs natural language processing on the input test case generation request, and extracts parameters based on the processing results.

[0009] According to an automated testing method provided by the present invention, a parameter extraction model includes: a natural language processing layer, which performs word segmentation and part-of-speech tagging on a test case generation request to obtain multiple word segments and the part-of-speech of each word segment; a named entity recognition layer, which performs named entity recognition on multiple word segments according to the multiple word segments and the part-of-speech of each word segment to obtain named entities; a pattern matching layer, which performs pattern matching on each named entity according to preset pattern matching rules to obtain test parameters; wherein the preset pattern matching rules are established based on the request pattern and parameter type.

[0010] According to an automated testing method provided by the present invention, a calling function corresponding to each task is generated according to an interface document corresponding to each task and a test parameter extracted based on a test case generation request, comprising: inputting the interface document corresponding to each task and the test parameter extracted based on the test case generation request into a function generation model to obtain a calling function corresponding to each task output by the function generation model; wherein the function generation model is trained based on an interface document sample and historical request texts, historical test parameters and function labels corresponding to each interface document sample; and the function generation model performs semantic analysis on the input interface document and the corresponding test parameters to generate a calling function.

[0011] According to an automated testing method provided by the present invention, a function generation model includes: a semantic analysis layer, which performs semantic analysis on the interface documents corresponding to each task to obtain corresponding input parameter information and output parameter information; a function generation layer, which generates a calling function of the corresponding task based on the input parameter information, output parameter information and test parameters in combination with a preset function template.

[0012] According to an automated testing method provided by the present invention, before the interface documents corresponding to each task and the test parameters extracted based on the test case generation request are input into the function generation model, the method also includes: obtaining interface document samples and historical request texts corresponding to each interface document sample; extracting parameters from the historical request texts to obtain historical test parameters; annotating each interface document sample to obtain a function label; using the interface document samples and the corresponding historical test parameters as input data for training, and using the function labels as labels for training, to train the model to be trained, and obtain a function generation model for generating the calling functions corresponding to each task.

[0013] The present invention also provides an automated testing device, comprising: a request acquisition module, which acquires a test case generation request; a task planning module, which generates task information according to the test case generation request; wherein the task information includes task dependency information corresponding to each task, an interface document corresponding to each task, and test parameters extracted based on the test case generation request; a function generation module, which generates a calling function corresponding to each task according to the interface document corresponding to each task and the test parameters extracted based on the test case generation request; and a combined calling module, which arranges the corresponding calling functions according to the task dependency information corresponding to each task, generates a calling flow and executes it to obtain a test result.

[0014] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the above-mentioned automated testing methods when executing the computer program.

[0015] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, any of the above-mentioned automated testing methods is implemented.

[0016] The present invention also provides a computer program product, comprising a computer program, and when the computer program is executed by a processor, any one of the above-mentioned automated testing methods is implemented.

[0017] The automated testing method and device provided by the present invention obtain test case generation requests according to different requirements and scenarios, adapt to various test objectives and system characteristics, and can obtain the latest test requirements at any time, respond to system changes and updates in a timely manner, ensure the timeliness and accuracy of the test, and convert the test case generation request into specific task information to clearly define the task information, avoid duplication of work and unnecessary testing, improve test efficiency and coverage, and facilitate management and tracking of the test process. The interface document and test parameters are further used to automatically generate a call function, which reduces the workload of manual code writing and improves the automation of the test. The generated call function can be automatically updated and adjusted according to the changes in the interface document, and the maintainability of the test code is improved, so that it is convenient to arrange the call function according to the task dependency information, ensure that the test is executed in the correct order, avoid inaccurate test results caused by the wrong task execution order, make full use of system resources, improve the execution efficiency of the test, shorten the test time, and thus improve the flexibility, customizability, automation, accuracy, maintainability and efficiency of the test, and at the same time facilitate the location and resolution of problems, which helps to improve the quality and effect of software testing. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0019] Figure 1 This is one of the flow charts of the automated testing method provided by the present invention.

[0020] Figure 2 This is the second flow chart of the automated testing method provided by the present invention.

[0021] Figure 3 It is a structural schematic diagram of the automatic testing device provided by the present invention.

[0022] Figure 4 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0023] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0024] Figure 1 : is a flow chart of the automated testing method provided by the present invention, the method comprising: S11, obtaining a test case generation request; S12, generating task information according to the test case generation request; wherein the task information includes task dependency information corresponding to each task, interface documents corresponding to each task, and test parameters extracted based on the test case generation request; S13, generating a calling function corresponding to each task according to the interface document corresponding to each task and the test parameters extracted based on the test case generation request; S14, according to the task dependency information corresponding to each task, arrange the corresponding calling functions, generate the calling flow and execute it to obtain the test result.

[0025] It should be noted that the step numbers "S1N" in this manual do not represent the order of the automated test method. Figure 2 The automated testing method of the present invention is described.

[0026] Step S11, obtaining a test case generation request.

[0027] It should be noted that the test case generation request is used to request the test cases that the user needs to generate, which can be determined according to the actual needs of the user. For example, a new organization is created with the organization code LW8888 and the parent organization LW12345. No further limitation is made here.

[0028] Step S12, generating task information according to the test case generation request; wherein the task information includes task dependency information corresponding to each task, interface documents corresponding to each task, and test parameters extracted based on the test case generation request.

[0029] In this embodiment, task information is generated according to a test case generation request, including: performing scenario recognition on the test case generation request to obtain a scenario recognition result; querying a knowledge base according to the scenario recognition result and the test case generation request to obtain task dependency information corresponding to each task and an interface document corresponding to each task; wherein the knowledge base is first constructed based on business logic information; and performing parameter extraction on the test case generation request to obtain test parameters.

[0030] It should be noted that business logic information includes task information and task dependency information. Task information includes task ID identification and interface documents corresponding to each task ID. The knowledge base is constructed through business logic information, which provides a solid foundation for subsequent task processing, so as to facilitate the generation of requests through scene recognition results and test cases, accurately obtain task information from the knowledge base, and clarify the specific task content. At the same time, the task dependency information corresponding to each task can also be obtained, which helps to determine the sequence and dependency relationship between tasks and ensure that the tasks can be executed according to the correct process. In addition, the interface documents corresponding to each task can also be obtained from the information of each task. The interface documents provide detailed specifications and instructions for the execution of tasks, so that different system modules can interact and collaborate effectively.

[0031] Furthermore, scene recognition is performed on the test case generation request to obtain a scene recognition result, including: inputting the test case generation request into a scene recognition model to obtain a scene recognition result output by the scene recognition model; wherein the scene recognition model is trained based on historical request text and scene labels corresponding to the historical request text.

[0032] In addition, parameters are extracted from the test case generation request to obtain test parameters, including: inputting the test case generation request into a parameter extraction model to obtain test parameters output by the parameter extraction model; wherein the parameter extraction model is trained based on historical request texts and parameter labels corresponding to the historical request texts; the parameter extraction model performs natural language processing on the input test case generation request, and extracts parameters based on the processing results.

[0033] Specifically, the parameter extraction model includes: a natural language processing layer, which performs word segmentation and part-of-speech tagging on the test case generation request to obtain multiple word segments and the part-of-speech of each word segment; a named entity recognition layer, which performs named entity recognition on multiple word segments based on the multiple word segments and the part-of-speech of each word segment to obtain named entities; a pattern matching layer, which performs pattern matching on each named entity according to preset pattern matching rules to obtain test parameters; wherein the preset pattern matching rules are established based on the request pattern and parameter type.

[0034] It should be noted that by performing word segmentation and part-of-speech tagging on the input test case generation request, specific entities in the request can be identified to ensure that key information in the request can be accurately extracted, parameter recognition errors due to semantic ambiguity or complex structure can be avoided, and the accuracy of parameter determination can be improved. Further, by matching the previously established pattern matching rules, the parts that meet the rules are found to obtain the test parameters, so that the parameter determination process is more standardized and normalized, the interference of human factors is reduced, the reliability of the results is enhanced, and efficient parameter determination is achieved, which saves a lot of time and labor costs and improves the efficiency of the entire test case processing.

[0035] In addition, the preset pattern matching rules can establish corresponding string templates according to different requests, so that when pattern matching is performed on each named entity according to the preset pattern matching rules, the corresponding parameters can be extracted by replacing the test case generation request with the corresponding string template.

[0036] Accordingly, the test case generation request is input into the parameter extraction model to obtain the test parameters output by the parameter extraction model, including: inputting the test case generation request into the natural language processing layer for word segmentation and part-of-speech tagging to obtain multiple word segments and the part-of-speech of each word segment; inputting the multiple word segments and the part-of-speech of each word segment into the named entity recognition layer for named entity recognition to obtain named entities; inputting the named entities into the pattern matching layer for pattern matching in combination with preset pattern matching rules to obtain test parameters.

[0037] In an optional embodiment, the parameter extraction model can use a language model manager (Language Model Manager, LMM for short) to effectively extract parameters in the test case generation request, so as to better process the request and provide accurate response. The specific implementation method can be adjusted and optimized according to the specific application scenario and requirements, and is not further limited here.

[0038] In addition, before the test case generation request is input into the parameter extraction model, it includes: obtaining historical request text; cleaning and preprocessing the historical request text to remove noise, errors and irrelevant content; annotating the processed historical request text to obtain parameter labels; selecting a suitable language model architecture according to specific needs and application scenarios, and determining the model's hyperparameters, which include hidden layer size, number of layers, learning rate, etc.; inputting the processed historical request text into the language model architecture that determines the hyperparameters for training, and constructing a loss function based on the training results and parameter labels until the loss function converges and the training ends.

[0039] Furthermore, during the training process, an optimization algorithm may be used to minimize the loss function, such as stochastic gradient descent. The optimization algorithm may be set based on the actually selected language model architecture and design requirements, and is not further limited here.

[0040] For example, refer to Figure 2 , the test case generation request is to create a new organization, the organization code is LW8888, and the parent organization is LW12345. According to the test case generation request, the scenario recognition result is determined to be the organization construction scenario. The corresponding task information obtained by querying the knowledge base includes the first task, the second task, the third task and the fourth task. The first task is to obtain the parent organization details parameter: parent organization code, the second task is to calculate the organization level category parameter: parent organization category, the third task is to calculate the organization level parameter: parent organization level, and the fourth task is to create a new organization parameter: organization code, parent organization code, organization level, etc. Among them, the second task depends on the first task, the third task depends on the first task, and the fourth task depends on the first task, the second task and the third task. In addition, the test case generation request is parameter extracted, and the obtained test parameters are [LW8888] and [LW12345]. The note [LW8888] is the organization code, and the note [LW12345] is the parent organization, so that when the calling function is generated later, the test parameters can be filled into the preset function template according to the note information.

[0041] Step S13, generating a calling function corresponding to each task according to the interface document corresponding to each task and the test parameters extracted based on the test case generation request.

[0042] In this embodiment, a calling function corresponding to each task is generated according to the interface document corresponding to each task and the test parameters extracted based on the test case generation request, including: inputting the interface document corresponding to each task and the test parameters extracted based on the test case generation request into a function generation model to obtain the calling function corresponding to each task output by the function generation model; wherein the function generation model is trained based on interface document samples and historical request texts, historical test parameters and function labels corresponding to each interface document sample; the function generation model performs semantic analysis on the input interface document and the corresponding test parameters to generate a calling function.

[0043] Specifically, the function generation model includes: a semantic analysis layer, which performs semantic analysis on the interface documents corresponding to each task to obtain the corresponding input parameter information and output parameter information; a function generation layer, which generates a calling function for the corresponding task based on the input parameter information, output parameter information and test parameters in combination with a preset function template.

[0044] It should be added that the interface document includes the request header, request body, request method, request address, interface, input parameter information and output parameter information. The input parameter information includes the input parameter type and format, and the output parameter information includes the output parameter type and format. In addition, the preset function template can be pre-generated based on the actual selected programming language and writing rules, so that after the function generation model inputs the interface documents corresponding to each task and the test parameters extracted based on the test case generation request, the calling function can be quickly generated, saving time and effort in manually writing code.

[0045] Correspondingly, the interface document corresponding to each task and the test parameters extracted based on the test case generation request are input into the function generation model to obtain the calling function corresponding to each task output by the function generation model, including: inputting the interface document corresponding to each task into the semantic analysis layer for semantic analysis to obtain the corresponding input parameter information and output parameter information; inputting the input parameter information, output parameter information and test parameters into the function generation layer to combine with the preset function template to generate the calling function of the corresponding task.

[0046] It should be noted that by performing semantic analysis on the interface documents corresponding to each task to quickly and accurately extract input and output parameter information, the workload of manual analysis of interface documents is reduced, and development efficiency is further improved. The corresponding calling functions can be quickly generated based on the input and output parameter information and test parameters, reducing the possibility of human errors and greatly speeding up the development progress, thereby ensuring that the generated calling functions can run correctly in actual usage scenarios.

[0047] In an optional embodiment, before the interface documents corresponding to each task and the test parameters extracted based on the test case generation request are input into the function generation model, it also includes: obtaining interface document samples and historical request texts corresponding to each interface document sample; extracting parameters from the historical request texts to obtain historical test parameters; annotating each interface document sample to obtain a function label; using the interface document samples and the corresponding historical test parameters as input data for training, and using the function labels as labels for training, to train the model to be trained, and obtain a function generation model for generating the call functions corresponding to each task.

[0048] It should be added that the interface document samples obtained include different request methods, parameter types, and return result structures, etc., in order to construct a rich and diverse training data set, and through annotation, determine the correct calling function corresponding to each interface document sample, so as to train the model using the annotated interface document samples and the corresponding historical test parameters, so that the model can learn a large number of samples and gradually master how to generate the correct calling function based on the interface document samples and test parameters, and ensure the accuracy of model training by optimizing the difference between the predicted calling function and the function label.

[0049] In an optional embodiment, after extracting parameters from historical request texts and obtaining historical test parameters, the following steps are performed: data preprocessing of interface document samples and data preprocessing of historical test parameters to convert interface document samples and historical test parameters into a unified format, so that the model can more easily identify and understand data from different sources, reducing confusion in the model when processing data in different formats. In addition, the format can be set according to the actual model and design requirements involved, such as a text sequence or a specific encoding form, which is not further defined here.

[0050] Step S14, according to the task dependency information corresponding to each task, arrange the corresponding calling functions, generate the calling flow and execute it to obtain the test result.

[0051] In this embodiment, the corresponding calling functions are arranged according to the task dependency information corresponding to each task to generate a calling flow, including: determining the execution order of the tasks according to the task dependency ID identifier in the task dependency information corresponding to each task; and arranging the calling functions corresponding to each task according to the determined execution order of the tasks to obtain a calling flow.

[0052] It should be noted that when arranging the calling function, control structures in the programming language, such as conditional statements, loops, etc., can also be used to control the calling flow. Continuing with the above example, the test case generation request is to create a new organization, the organization code is LW8888, the parent organization is LW12345, and the first task, the second task, the third task and the fourth task are obtained. The second task depends on the first task, the third task depends on the first task, and the fourth task depends on the first task, the second task and the third task.

[0053] The calling function corresponding to the first task is executed by means of function call to execute the first task, and the corresponding parameters are passed to the second task, the third task and the fourth task according to the task dependency relationship; after the second task and the third task receive the relevant parameters passed by the calling function corresponding to the first task, the calling functions corresponding to the second task and the third task are continued to be called to execute the corresponding second task and the third task respectively, and the relevant parameters of the second task and the third task are passed to the fourth task according to the task dependency relationship; after the fourth task receives the relevant parameters passed by the calling functions corresponding to the second task and the third task, the calling function corresponding to the fourth task is continued to be called to execute the fourth task, thereby realizing the control of the calling flow.

[0054] It is worth noting that since there is no dependency between the second task and the third task, the execution order of the second task and the third task can be set based on actual design requirements. This is only an example.

[0055] In summary, the embodiments of the present invention obtain test case generation requests according to different requirements and scenarios, adapt to various test objectives and system characteristics, and can obtain the latest test requirements at any time, respond to system changes and updates in a timely manner, ensure the timeliness and accuracy of the test, and convert the test case generation request into specific task information to clearly define the task information, avoid duplication of work and unnecessary testing, improve test efficiency and coverage, and facilitate management and tracking of the test process. The interface document and test parameters are further used to automatically generate a call function, which reduces the workload of manual code writing and improves the automation of the test. The generated call function can be automatically updated and adjusted according to the changes in the interface document, which improves the maintainability of the test code, thereby facilitating the arrangement of the call function according to the task dependency information, ensuring that the test is executed in the correct order, avoiding inaccurate test results caused by the wrong task execution order, making full use of system resources, improving the execution efficiency of the test, shortening the test time, and thus improving the flexibility, customizability, automation, accuracy, maintainability and efficiency of the test, while facilitating the location and resolution of problems, and helping to improve the quality and effect of software testing.

[0056] The automated testing device provided by the present invention is described below. The automated testing device described below and the automated testing method described above can be referenced to each other.

[0057] Figure 3 A schematic diagram of the structure of an automated testing device is shown, the device comprising: A request acquisition module 31 acquires a test case generation request; The task planning module 32 generates task information according to the test case generation request; wherein the task information includes task dependency information corresponding to each task, interface documents corresponding to each task, and test parameters extracted based on the test case generation request; The function generation module 33 generates a calling function corresponding to each task according to the interface document corresponding to each task and the test parameters extracted based on the test case generation request; The combined calling module 34 arranges the corresponding calling functions according to the task dependency information corresponding to each task, generates a calling flow and executes it to obtain the test result.

[0058] In this embodiment, the task planning module 32 includes: a scene recognition unit, which performs scene recognition on the test case generation request to obtain a scene recognition result; a task planning unit, which queries the knowledge base according to the scene recognition result and the test case generation request to obtain the task dependency information corresponding to each task and the interface document corresponding to each task; wherein the knowledge base is first constructed based on the business logic information; and a first parameter extraction unit, which performs parameter extraction on the test case generation request to obtain test parameters.

[0059] Furthermore, the scene recognition unit is used to: input the test case generation request into the scene recognition model to obtain the scene recognition result output by the scene recognition model; wherein the scene recognition model is trained based on the historical request text and the scene labels corresponding to the historical request text.

[0060] In addition, the first parameter extraction unit is used to: input the test case generation request into the parameter extraction model to obtain the test parameters output by the parameter extraction model; wherein the parameter extraction model is trained based on the historical request text and the parameter labels corresponding to the historical request text; the parameter extraction model performs natural language processing on the input test case generation request, and extracts parameters based on the processing results.

[0061] Specifically, the parameter extraction model includes: a natural language processing layer, which performs word segmentation and part-of-speech tagging on the test case generation request to obtain multiple word segments and the part-of-speech of each word segment; a named entity recognition layer, which performs named entity recognition on multiple word segments based on the multiple word segments and the part-of-speech of each word segment to obtain named entities; a pattern matching layer, which performs pattern matching on each named entity according to preset pattern matching rules to obtain test parameters; wherein the preset pattern matching rules are established based on the request pattern and parameter type.

[0062] Correspondingly, the first parameter extraction unit includes: a natural language processing sub-unit, which inputs the test case generation request into the natural language processing layer for word segmentation and part-of-speech tagging to obtain multiple word segments and the part-of-speech of each word segment; a named entity recognition sub-unit, which inputs the multiple word segments and the part-of-speech of each word segment into the named entity recognition layer for named entity recognition to obtain named entities; and a pattern matching sub-unit, which inputs the named entities into the pattern matching layer for pattern matching in combination with preset pattern matching rules to obtain test parameters.

[0063] In an optional embodiment, the first parameter extraction unit also includes: a historical text acquisition subunit, which acquires historical request text before inputting the test case generation request into the parameter extraction model; a data processing subunit, which cleans and preprocesses the historical request text to remove noise, errors and irrelevant content; a labeling subunit, which labels the processed historical request text to obtain parameter labels; a model selection subunit, which selects a suitable language model architecture according to specific needs and application scenarios, and determines the hyperparameters of the model, the hyperparameters including the size of the hidden layer, the number of layers, the learning rate, etc.; a training subunit, which inputs the processed historical request text into the language model architecture for determining the hyperparameters for training, and constructs a loss function based on the training results and parameter labels until the loss function converges and the training ends.

[0064] The function generation module 33 is used to: input the interface document corresponding to each task and the test parameters extracted based on the test case generation request into the function generation model, and obtain the calling function corresponding to each task output by the function generation model; wherein the function generation model is trained based on the interface document sample and the historical request text, historical test parameters and function labels corresponding to each interface document sample; the function generation model performs semantic analysis on the input interface document and the corresponding test parameters to generate a calling function.

[0065] Specifically, the function generation model includes: a semantic analysis layer, which performs semantic analysis on the interface documents corresponding to each task to obtain the corresponding input parameter information and output parameter information; a function generation layer, which generates a calling function for the corresponding task based on the input parameter information, output parameter information and test parameters in combination with a preset function template.

[0066] Correspondingly, the function generation module 33 includes: a semantic analysis unit, which inputs the interface document corresponding to each task into the semantic analysis layer for semantic analysis to obtain corresponding input parameter information and output parameter information; a function generation unit, which inputs the input parameter information, output parameter information and test parameters into the function generation layer to combine with the preset function template to generate a calling function for the corresponding task.

[0067] In an optional embodiment, the function generation module 33 also includes: a data acquisition unit, which acquires interface document samples and historical request texts corresponding to each interface document sample before inputting the interface document corresponding to each task and the test parameters extracted based on the test case generation request into the function generation model; a second parameter extraction unit, which extracts parameters from the historical request text to obtain historical test parameters; a labeling unit, which labels each interface document sample to obtain a function label; and a training unit, which uses the interface document samples and the corresponding historical test parameters as input data for training, and uses the function label as a label for training, to train the model to be trained, and obtain a function generation model for generating a call function corresponding to each task.

[0068] In an optional embodiment, the function generation module 33 also includes: a data processing unit, which, after extracting parameters from the historical request text and obtaining the historical test parameters, performs data preprocessing on the interface document samples and data preprocessing on the historical test parameters to convert the interface document samples and historical test parameters into a unified format.

[0069] The combined calling module 34 includes: a sequence determination unit, which determines the execution order of tasks according to the task dependency ID identification in the task dependency information corresponding to each task; and an orchestration unit, which orchestrates the calling functions corresponding to each task according to the determined execution order of the tasks to obtain a calling flow.

[0070] In summary, the embodiment of the present invention obtains test case generation requests according to different requirements and scenarios through the request acquisition module, adapts to various test objectives and system characteristics, and can obtain the latest test requirements at any time, respond to system changes and updates in a timely manner, ensure the timeliness and accuracy of the test, and convert the test case generation request into specific task information through the task planning module to clearly define the task information, avoid duplication of work and unnecessary testing, improve test efficiency and coverage, and facilitate management and tracking of the test process. Further, the function generation module uses the interface document and test parameters to automatically generate a call function, which reduces the workload of manual code writing and improves the automation of the test. The generated call function can be automatically updated and adjusted according to the changes in the interface document, which improves the maintainability of the test code, thereby facilitating the combined call module to arrange the call function according to the task dependency information, ensuring that the test is executed in the correct order, avoiding inaccurate test results caused by the wrong task execution order, making full use of system resources, improving the execution efficiency of the test, shortening the test time, and thus improving the flexibility, customizability, automation, accuracy, maintainability and efficiency of the test, while facilitating the location and resolution of problems, and helping to improve the quality and effect of software testing.

[0071] Figure 4 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 4 As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430 and a communication bus 440, wherein the processor 410, the communication interface 420 and the memory 430 complete mutual communication through the communication bus 440. The processor 410 may call the logic instructions in the memory 430 to execute the automated testing method, which includes: obtaining a test case generation request; generating task information according to the test case generation request; wherein the task information includes task dependency information corresponding to each task, an interface document corresponding to each task and a test parameter extracted based on the test case generation request; generating a call function corresponding to each task according to the interface document corresponding to each task and the test parameter extracted based on the test case generation request; arranging the corresponding call function according to the task dependency information corresponding to each task, generating a call flow and executing it, and obtaining a test result.

[0072] In addition, the logic instructions in the above-mentioned memory 430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0073] On the other hand, the present invention also provides a computer program product, which includes a computer program, and the computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the automated testing method provided by the above-mentioned methods, and the method includes: obtaining a test case generation request; generating task information according to the test case generation request; wherein the task information includes task dependency information corresponding to each task, an interface document corresponding to each task, and a test parameter extracted based on the test case generation request; generating a calling function corresponding to each task according to the interface document corresponding to each task and the test parameter extracted based on the test case generation request; according to the task dependency information corresponding to each task, the corresponding calling function is arranged, a call flow is generated and executed, and a test result is obtained.

[0074] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute the automated testing method provided by the above-mentioned methods, the method comprising: obtaining a test case generation request; generating task information according to the test case generation request; wherein the task information comprises task dependency information corresponding to each task, an interface document corresponding to each task, and test parameters extracted based on the test case generation request; generating a calling function corresponding to each task according to the interface document corresponding to each task and the test parameters extracted based on the test case generation request; arranging the corresponding calling functions according to the task dependency information corresponding to each task, generating a calling flow and executing it, and obtaining a test result.

[0075] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0076] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0077] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. An automated testing method, characterized in that: include: Get the test case generation request; Generate task information according to the test case generation request; wherein the task information includes task dependency information corresponding to each task, interface documents corresponding to each task, and test parameters extracted based on the test case generation request; Generate a calling function corresponding to each of the tasks according to the interface document corresponding to each of the tasks and the test parameters extracted based on the test case generation request; According to the task dependency information corresponding to each of the tasks, the corresponding calling functions are arranged, a calling flow is generated and executed, and a test result is obtained.

2. The automated testing method according to claim 1, characterized in that: The step of generating a request and task information according to the test case includes: Performing scene recognition on the test case generation request to obtain a scene recognition result; According to the scenario recognition result and the test case generation request, a knowledge base is queried to obtain task dependency information corresponding to each task and an interface document corresponding to each task; wherein the knowledge base is previously constructed based on business logic information; Parameters are extracted from the test case generation request to obtain test parameters.

3. The automated testing method according to claim 2, characterized in that: Performing scene recognition on the test case generation request to obtain a scene recognition result includes: The test case generation request is input into a scene recognition model to obtain a scene recognition result output by the scene recognition model; wherein the scene recognition model is trained based on historical request texts and scene labels corresponding to the historical request texts.

4. The automated testing method according to claim 2, characterized in that: Parameters are extracted from the test case generation request to obtain test parameters, including: The test case generation request is input into a parameter extraction model to obtain test parameters output by the parameter extraction model; wherein the parameter extraction model is trained based on historical request texts and parameter labels corresponding to the historical request texts; the parameter extraction model performs natural language processing on the input test case generation request, and extracts parameters based on the processing results.

5. The automated testing method according to claim 4, characterized in that: The parameter extraction model includes: A natural language processing layer performs word segmentation and part-of-speech tagging on the test case generation request to obtain multiple word segments and the part-of-speech of each word segment; A named entity recognition layer, performing named entity recognition on the multiple segmented words according to the multiple segmented words and the part of speech of each segmented word, to obtain a named entity; The pattern matching layer performs pattern matching on each of the named entities according to preset pattern matching rules to obtain test parameters; wherein the preset pattern matching rules are established based on the request pattern and parameter type.

6. The automated testing method according to claim 1, characterized in that: Generate a calling function corresponding to each of the tasks according to the interface document corresponding to each of the tasks and the test parameters extracted based on the test case generation request, including: The interface document corresponding to each of the tasks and the test parameters extracted based on the test case generation request are input into the function generation model to obtain the calling function corresponding to each of the tasks output by the function generation model; wherein the function generation model is trained based on the interface document samples and the historical request texts, historical test parameters and function labels corresponding to each of the interface document samples; the function generation model performs semantic analysis on the input interface documents and corresponding test parameters to generate a calling function.

7. The automated testing method according to claim 6, characterized in that: The function generation model includes: The semantic analysis layer performs semantic analysis on the interface documents corresponding to each task to obtain the corresponding input parameter information and output parameter information; The function generation layer generates a calling function of the corresponding task according to the input parameter information, the output parameter information and the test parameters in combination with a preset function template.

8. The automated testing method according to claim 6, characterized in that: Before inputting the interface documents corresponding to each of the tasks and the test parameters extracted based on the test case generation request into the function generation model, the method further includes: Obtain interface document samples and historical request texts corresponding to each of the interface document samples; Extracting parameters from the historical request text to obtain historical test parameters; Labeling each of the interface document samples to obtain a function label; The interface document samples and the corresponding historical test parameters are used as input data for training, and the function labels are used as labels for training. The training model is trained to obtain a function generation model for generating calling functions corresponding to each task.

9. An automated testing device, characterized in that: include: Request acquisition module, obtains test case generation request; A task planning module generates task information according to the test case generation request; wherein the task information includes task dependency information corresponding to each task, interface documents corresponding to each task, and test parameters extracted based on the test case generation request; A function generation module generates a calling function corresponding to each of the tasks according to the interface document corresponding to each of the tasks and the test parameters extracted based on the test case generation request; The combined calling module arranges the corresponding calling functions according to the task dependency information corresponding to each task, generates a calling flow and executes it to obtain a test result.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the automated testing method according to any one of claims 1 to 8 is implemented.

Citation Information

Cited By

  • Interface verification and test method and device based on large model, medium and product

    CN121441793A