Test script generation method and device, equipment, storage medium and program product

By converting interface description information into numerical sequences and introducing context information, using script generation model to generate test scripts, the problems of inefficient and incomplete coverage of manual writing test scripts in the prior art are solved, and the generation and rapidity of automated test scripts are realized Respond to changes in functionality.

CN118939561APending Publication Date: 2024-11-12CHINA MOBILE M2M +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411329799.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-23
Publication Date
2024-11-12

AI Technical Summary

Technical Problem

In software interface testing, the existing technology requires a large number of manual writing of test scripts and test cases, and it is difficult to quickly respond to frequently changing test requirements, resulting in incomplete test coverage and difficulty in modifying.

Method used

By obtaining the description information of the target interface, converting it into a numerical sequence and introducing context information, using the pre-trained script generation model to generate automated test scripts, building attention weight matrix and context matrix, and generating a more comprehensive test script.

Benefits of technology

It realizes automated generation of comprehensive test scripts, reduces the need for manual writing, can quickly respond to function changes, and improves testing efficiency and coverage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118939561A_ABST
    Figure CN118939561A_ABST
Patent Text Reader

Abstract

The invention discloses a test script generation method and device, equipment, a storage medium and a program product. The method comprises the following steps: acquiring a text sequence for describing a target interface; converting the text sequence into a corresponding numerical value sequence, and obtaining context information corresponding to each numerical value sequence; inputting the numerical sequence and the context information into a script generation model, and constructing the context information into a context matrix by utilizing the script generation model; generating a corresponding attention weight matrix based on the attention score matrix corresponding to each numerical sequence and the corresponding context matrix by utilizing a script generation model, and coding the corresponding numerical sequence by utilizing the attention weight matrix to obtain a coded sequence; and decoding the corresponding coding sequence by using each attention weight matrix to obtain an output sequence, and generating a test script for testing the target interface by using the output sequence. According to the embodiment of the invention, the test script with more comprehensive coverage content is automatically generated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the technical field of software testing, and in particular, relates to a test script generation method, device, equipment, storage medium and program product. Background Art

[0002] In software interface testing, based on the established test environment, test scripts or test cases are often written manually before the interface to be tested is tested. Since the test scripts or test cases need to include various normal scenarios and abnormal scenarios, such as sending requests, verifying responses, etc., not only a large amount of human resources are required to complete the writing of test scripts or test cases, but also during the writing process, there is still a problem that the written content is not comprehensive enough, resulting in the test scripts or test cases failing to cover all functions.

[0003] In addition, not only will the functions of the interface to be tested change frequently during the development process, but the functions of the interface will also be frequently iterated during the application process. Therefore, when testing interfaces with frequently changing functions, it is necessary to frequently modify the test scripts or test cases. However, due to the limited testing cycle in actual work, the modification of test scripts or test cases is still difficult to quickly respond to frequently changing test requirements. Summary of the invention

[0004] Embodiments of the present application provide a test script generation method, apparatus, device, storage medium, and program product that can automatically generate comprehensive test scripts.

[0005] In a first aspect, an embodiment of the present application provides a test script generation method, the method comprising:

[0006] Obtaining description information of a target interface, where the description information includes at least one text sequence;

[0007] Convert at least one text sequence into at least one corresponding numerical sequence, and obtain context information corresponding to each numerical sequence, where each piece of context information includes a feature exhibited by the corresponding numerical sequence when used;

[0008] Inputting at least one numerical sequence and corresponding context information into a script generation model, and constructing each context information into a context matrix using the script generation model;

[0009] Using the script generation model, a corresponding attention weight matrix is ​​generated based on the attention score matrix and the corresponding context matrix corresponding to each numerical sequence, and the corresponding numerical sequence is encoded using the attention weight matrix to obtain the corresponding encoding sequence;

[0010] Each attention weight matrix is ​​used to decode the corresponding encoding sequence to obtain the corresponding output sequence, and all output sequences are used to generate a test script for testing the target interface.

[0011] Wherein, each numerical sequence includes at least one vocabulary vector;

[0012] Furthermore, the script generation model is used to construct each context information into a context matrix, including:

[0013] Compressing a piece of context information corresponding to each vocabulary vector in each numerical sequence into a corresponding single context vector, each piece of context information including a feature exhibited by the corresponding vocabulary vector when used;

[0014] The context vector corresponding to each vocabulary vector in the numerical sequence is used to form a context matrix corresponding to the numerical sequence.

[0015] Furthermore, a corresponding attention weight matrix is ​​generated based on the attention score matrix and the corresponding context matrix corresponding to each numerical sequence, including:

[0016] Obtain the context weight parameters of the context matrix corresponding to each numerical sequence;

[0017] The product of the context matrix corresponding to each numerical sequence and the corresponding context weight parameter is normalized with the corresponding attention score matrix to obtain the corresponding attention weight matrix.

[0018] Furthermore, all output sequences are used to generate a test script for testing the target interface, including:

[0019] Each output sequence is restored to a running code in a predetermined format, and each running code is combined into a test script.

[0020] Furthermore, before inputting at least one numerical sequence and corresponding context information into the script generation model, the method further includes:

[0021] Obtaining a target sequence and corresponding context information corresponding to a training sequence, wherein the training sequence includes a text sequence corresponding to description information of each interface, each target sequence represents a sequence expected to be generated when predicting using the corresponding training sequence, and each piece of context information includes a feature exhibited by the corresponding training sequence when used;

[0022] The training sequence, the corresponding target sequence and the corresponding context information are input into the initial script generation model, and the script generation model is used to construct each context information into a context matrix;

[0023] Using the initial script generation model, a corresponding attention weight matrix is ​​generated based on the attention score matrix and the corresponding context matrix corresponding to each training sequence, and the corresponding training sequence is encoded using the attention weight matrix to obtain a corresponding encoding sequence;

[0024] Decode the corresponding encoding sequence using each attention weight matrix to obtain the probability of outputting each target sequence using the training sequence;

[0025] The cross entropy loss is determined using the probability of the target sequence corresponding to each training sequence output;

[0026] When the cross entropy loss meets the preset convergence threshold, the script generation model is obtained.

[0027] Further, after determining the cross entropy loss using the probability of each training sequence outputting the corresponding target sequence, the method further includes:

[0028] When the cross entropy loss does not meet the preset convergence threshold, the parameters in the initial script generation model are adjusted to obtain the script generation model to be trained;

[0029] Input each training sequence and the corresponding target sequence used for training into the script generation model to be trained, and use the probability of each training sequence outputting the corresponding target sequence to determine the cross entropy loss;

[0030] When the cross entropy loss meets the preset convergence threshold, the script generation model is obtained.

[0031] In a second aspect, an embodiment of the present application provides a test script generating device, the device comprising:

[0032] An acquisition module, used for acquiring description information of a target interface, where the description information includes at least one text sequence;

[0033] A conversion module, used to convert at least one text sequence into at least one corresponding numerical sequence, and obtain context information corresponding to each numerical sequence, each piece of context information including a feature exhibited by the corresponding numerical sequence when in use;

[0034] A context information processing module, used to input at least one numerical sequence and corresponding context information into a script generation model, and construct each context information into a context matrix using the script generation model;

[0035] A prediction module is used to generate a model using a script, generate a corresponding attention weight matrix based on the attention score matrix and the corresponding context matrix corresponding to each numerical sequence, and encode the corresponding numerical sequence using the attention weight matrix to obtain a corresponding encoding sequence;

[0036] The output module is used to use each attention weight matrix to decode the corresponding encoding sequence to obtain the corresponding output sequence, and use all the output sequences to generate a test script for testing the target interface.

[0037] In a third aspect, an embodiment of the present application provides an electronic device, the device comprising:

[0038] a processor and a memory storing computer program instructions;

[0039] When the processor executes the computer program instructions, a test script generation method as described in any of the above items is implemented.

[0040] In a fourth aspect, an embodiment of the present application provides a computer storage medium, on which computer program instructions are stored. When the computer program instructions are executed by a processor, a test script generation method as described in any of the above items is implemented.

[0041] In a fifth aspect, an embodiment of the present application provides a method for generating a test script as described above, wherein when instructions in a computer program product are executed by a processor of an electronic device, the electronic device executes the method.

[0042] The test script generation method, apparatus, device, storage medium and program product of the embodiments of the present application are based on a pre-trained script generation model, so that the sequence data obtained after scanning the target interface to be tested can be directly input into the script generation model, thereby integrating the two actions of scanning the target interface and generating the test script.

[0043] Furthermore, before using the script generation model to generate a test script, the acquired text sequence used to describe the target interface is converted into a numerical sequence so that the script generation model can understand the description information of the target interface, thereby realizing the docking of the text sequence with the script generation model. When using the script generation model to generate a test script, in addition to inputting the numerical sequence into the script generation model, the acquired context information is also input into the script generation model, so that the script generation model can consider the corresponding context information when using the numerical sequence for prediction, thereby improving the attention to important information. Specifically, the script generation model constructs the upper and lower information into a context matrix, thereby introducing the context matrix when performing attention weight matrix operations on the numerical sequence, so that a coding sequence is generated, and the output sequence decoded using the coding sequence can balance the relationship between the numerical sequence and related features, have better performance in prediction, and obtain a better output sequence, and then the content of the test script converted from the output sequence is more comprehensive. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the technical solution of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0045] Figure 1 It is a flowchart of a test script generation method provided in an embodiment of the present application;

[0046] Figure 2 It is a flowchart of an interface test provided in an embodiment of the present application;

[0047] Figure 3 It is a structural schematic diagram of a test script generating device provided in an embodiment of the present application;

[0048] Figure 4 It is a structural diagram of an electronic device provided by yet another embodiment of the present application. DETAILED DESCRIPTION

[0049] The features and exemplary embodiments of various aspects of the present application will be described in detail below. In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in conjunction with the accompanying drawings and specific embodiments. It should be understood that the specific embodiments described herein are only intended to explain the present application, rather than to limit the present application. For those skilled in the art, the present application can be implemented without the need for some of these specific details. The following description of the embodiments is only to provide a better understanding of the present application by illustrating the examples of the present application.

[0050] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "include..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0051] As described in the background technology section, the related test script generation technology is still difficult to meet the needs of actual work.

[0052] In the process of implementing the present application, the applicant discovered that the main problem with the related test script generation technology is that in the interface testing of the software, it is necessary to pre-build a test script or test case to test the interface to be tested.

[0053] The test script or test case includes: various normal scenarios and abnormal scenarios constructed according to the interface and requirements, as well as the operations performed on the interface in each scenario, such as sending requests and verifying responses.

[0054] However, currently test scripts or test cases are often written manually. Therefore, not only a large amount of human resources is required to complete the writing of test scripts or test cases, but also during the writing process, there are still many scenarios that are not comprehensive enough and the operations performed are not comprehensive enough, which leads to the test scripts or test cases failing to cover the testing of all functions of the interface.

[0055] In addition, the functions of the interfaces to be tested will change frequently during the development process, and the functions of the interfaces will also be frequently iterated during the application process. Therefore, when testing interfaces with frequently changing functions, it is necessary to frequently modify the test scripts or test cases. However, due to the limited testing cycle in actual work, the modification of test scripts or test cases is still difficult to quickly respond to frequently changing test requirements.

[0056] In order to solve the problems of the prior art, the embodiments of the present application provide a test script generation method, apparatus, equipment, storage medium and program product. By training an artificial intelligence model, the test script generation model obtained by training is used to predict the test script, and when predicting the test script, context information with the test script is introduced into the test script generation model, so that it can be automatically generated, thereby replacing manual writing, and the generated test script can cover more comprehensive information. In addition, since the test script generation model is used to generate the test script in the present method, for interfaces with frequently changing functions, it is also possible to quickly respond to frequently changing test requirements, that is, to quickly and automatically generate or modify the corresponding test script.

[0057] The following first introduces the test script generation method provided in the embodiment of the present application.

[0058] In this embodiment, Figure 1 A flow chart of a test script generator provided by an embodiment of the present application is shown.

[0059] like Figure 1 As shown, the test script generation method provided in the embodiment of the present application includes the following steps:

[0060] Step S101: Acquire description information of a target interface, where the description information includes at least one text sequence.

[0061] Step S102: convert the at least one text sequence into at least one corresponding numerical sequence, and obtain context information corresponding to each numerical sequence, where each piece of context information includes a feature exhibited by the corresponding numerical sequence when in use.

[0062] Step S103: input the at least one numerical sequence and the corresponding context information into a script generation model, and construct each context information into a context matrix using the script generation model.

[0063] Step S104: using the script to generate a model, generating a corresponding attention weight matrix based on the attention score matrix corresponding to each numerical sequence and the corresponding context matrix, and using the attention weight matrix to encode the corresponding numerical sequence to obtain a corresponding encoding sequence.

[0064] Step S105: Use each attention weight matrix to decode the corresponding encoding sequence to obtain the corresponding output sequence, and use all the output sequences to generate a test script for testing the target interface.

[0065] The specific implementation methods of the above steps are introduced below.

[0066] In some embodiments, in S101, when obtaining description information for the target interface to be tested, an interface scanning tool may be used to scan the target interface to obtain the description information of the target interface.

[0067] Specifically, when developers develop each interface, they will annotate the interface in the source code. When obtaining the description information of the interface, they can use the interface scanning tool to traverse the class path and load all the class files in it, and obtain the annotation information through reflection and other methods, thereby constructing the description information of the interface.

[0068] The annotation information may include the hypertext transfer protocol method, interface path, request header, request body type, parameter verification information, response type and other contents.

[0069] Furthermore, based on the collected annotation information, the annotation information may be preprocessed.

[0070] Specifically, the annotation information can be converted into a form that can be understood by the model. For example, the original request and response can be converted into a structured JSON format, and special characters, spaces, and line breaks can be processed accordingly to complete the preprocessing and obtain the description information.

[0071] The preprocessed description information may be in the form of a text sequence, that is, the description information contains at least one text sequence.

[0072] It can be seen that in this step, by using the scanning tool, the description information of the interface can be generated or updated in real time by identifying the source code.

[0073] In some embodiments, in S102, based on the description information of the target interface obtained in the aforementioned steps, each text sequence therein can be converted into a corresponding numerical sequence, so that the relevant information of the target interface can be applicable to the following script generation model; in addition, contextual information related to each numerical sequence is also obtained to obtain more comprehensive information about the target interface.

[0074] Specifically, in this step, when converting each text sequence into a numerical sequence, a vocabulary can be created for the description information, and the character strings expected to appear in each text sequence are added to the vocabulary, where these character strings can be, for example, words, tokens, fields, characters and other vocabulary, and specifically describe the relevant information of the target interface, such as the Hypertext Transfer Protocol method, interface path, request header, request body type, parameter verification information and response type, etc.

[0075] Based on this, a natural language processing model can be used to convert each text sequence into a corresponding numerical sequence.

[0076] Among them, the natural preamble processing model can be, for example, a bidirectional encoder representation model (BidirectionalEncoder Representation from Transformers, BERT), which can use the part of BERT responsible for word segmentation, adding special tags and encoding of the input text to process each string in the vocabulary. Specifically, it can be processed by techniques such as vocabulary segmentation of each string, thereby converting each word into a vocabulary vector and obtaining a numerical sequence containing at least one vocabulary vector.

[0077] Based on this, the numerical sequence corresponding to each text sequence can be obtained. By replacing the text sequence with the numerical sequence and inputting it into the script generation model, the connection between the text sequence and the following script generation model is achieved, so that the generalization ability of the following script generation model when generating test scripts is significantly improved.

[0078] Furthermore, in this step, after the text sequence is obtained, a plurality of context information is also obtained accordingly.

[0079] Among them, each piece of context information corresponds to a word in the text sequence, and each piece of context information corresponding to each text sequence specifically includes the interface test results of the text sequence or the corresponding numerical sequence during historical use, the code structure characteristics exhibited during use, and other contents.

[0080] That is to say, each word vector in the numerical sequence converted from each text sequence corresponds to a piece of context information.

[0081] In some embodiments, in S103, based on the numerical sequence and context information obtained in the above steps, each numerical sequence and the corresponding context information are input into a pre-trained script generation model.

[0082] Based on this, the script generation model can first compress the context information corresponding to each vocabulary vector into a single context vector. For each numerical sequence, the context vectors corresponding to each vocabulary vector are combined into a context matrix suitable for the script generation model.

[0083] Based on this, the script generation model can process the numerical sequence and, at the same time, introduce a context matrix containing corresponding context information corresponding to the numerical sequence, so that the predicted test script contains more comprehensive content.

[0084] In some embodiments, in S104, based on the various numerical sequences and their corresponding context matrices obtained using the script generation model in the aforementioned steps, the attention unit in the script generation model can generate an attention weight matrix corresponding to each numerical sequence, thereby increasing the attention to important information when predicting the test script.

[0085] In this embodiment, the script generation model can adopt the structure of a sequence-to-sequence model (Sequence 2Sequence model), wherein in the script generation model, the complexity and expressiveness of the model are increased by stacking multiple encoders and multiple decoders, so that the generated test script is more accurate and comprehensive.

[0086] In some embodiments, for the decoder in the script generation model, label smoothing technology or other regularization technology can be used to soften the probability distribution of each category label during prediction, thereby reducing the overfitting of the script generation model during prediction and obtaining better generalization performance.

[0087] In this embodiment, in the script generation model based on the sequence-to-sequence structure, the Transformer architecture can be specifically used. The Transformer architecture is a model architecture that adds an attention mechanism to the sequence-to-sequence structure. By introducing the attention mechanism, the problems of gradient vanishing and information forgetting when processing long sequences are improved. In the script generation model of this embodiment, an attention unit that runs the attention mechanism is provided in at least one encoder.

[0088] Based on this, after using the script generation model to obtain the numerical sequence and the context matrix, the attention unit in the encoder first performs attention weight matrix operations on the numerical sequence and the context matrix.

[0089] Specifically, for each numerical sequence, the attention unit is used to determine the query vector q, key vector k, and value vector v corresponding to each vocabulary vector in the numerical sequence.

[0090] Furthermore, the query vectors q corresponding to each vocabulary vector in the numerical sequence constitute the query matrix Q corresponding to the numerical sequence, the key vectors k corresponding to each vocabulary vector in the numerical sequence constitute the key matrix K corresponding to the numerical sequence, and the value vectors v corresponding to each vocabulary vector in the numerical sequence constitute the value matrix V corresponding to the numerical sequence.

[0091] Based on this, the query matrix Q and key matrix K corresponding to each numerical sequence are used to determine the corresponding attention score matrix.

[0092] Specifically, the key matrix K can be transposed and then multiplied with the query matrix Q, and the corresponding attention score matrix can be calculated based on the dimension of the key matrix.

[0093] In a specific example, the attention score matrix can be calculated according to the following formula (1):

[0094]

[0095] Where T represents the transposition of the matrix, d k Represents the dimension of the K matrix.

[0096] Furthermore, a corresponding context weight parameter γ may be set for each context matrix, and the context weight parameter γ is a parameter that can be continuously learned.

[0097] Based on this, after multiplying the context matrix with the context weight, the normalized activation function is operated with the attention score matrix, and combined with the value matrix to obtain the corresponding attention weight matrix.

[0098] In a specific example, the attention weight matrix can be calculated according to the following formula (2):

[0099]

[0100] Among them, C represents the context matrix, softmax represents the operation of the normalized activation function, and Attention(Q, K, V) represents the attention weight matrix obtained based on the corresponding query matrix Q, key matrix K and value matrix V.

[0101] Based on this, when using the encoder to encode the numerical sequence, the influence of the attention weight matrix can be added to obtain the encoding sequence corresponding to the numerical sequence.

[0102] It can be seen that in this embodiment, the attention matrix is ​​calculated by utilizing the attention mechanism in the attention unit. When encoding the numerical sequence, the attention weight matrix is ​​used to increase the attention to important information. Moreover, since the context matrix is ​​added in the calculation of the attention weight matrix, the corresponding context information is fully considered when encoding the numerical sequence, and the encoded sequence obtained by encoding in the encoder covers more comprehensive content.

[0103] In some embodiments, in S105, based on the coding sequence determined in the above steps, the obtained coding sequence can be input into a decoder, and the decoder is used to decode each coding sequence, so that the script generation model generates an output sequence.

[0104] Furthermore, each output word is organized into a predetermined code format, thereby obtaining a test script that is complete in form and meets the grammatical requirements during testing.

[0105] The content of the generated test script may include various operations such as parameter verification, request sending, encryption and decryption, and injection of structured query language, as well as expected response results of each operation.

[0106] It can be seen that this embodiment converts the acquired text sequence used to describe the target interface into a numerical sequence, so that the script generation model can understand the description information of the target interface, thereby realizing the docking of the text sequence with the script generation model. When using the script generation model to generate a test script, in addition to inputting the numerical sequence into the script generation model, the acquired context information is also input into the script generation model, so that the script generation model can consider the corresponding context information when using the numerical sequence for prediction, thereby improving the attention to important information. Specifically, the script generation model constructs the upper and lower information into a context matrix, thereby introducing the context matrix when performing the operation of the attention weight matrix on the numerical sequence, so that the encoding sequence is generated, and the output sequence decoded by the encoding sequence can balance the relationship between the numerical sequence and the related features, have better performance in the prediction, and obtain a better output sequence, and then the content of the test script converted from the output sequence is more comprehensive.

[0107] In another embodiment of the present application, before inputting the numerical sequence and the corresponding context information into the script generation model, the initial script generation model needs to be trained to obtain a script generation model that has been trained and is used to generate test scripts.

[0108] In this embodiment, in order to train the initial script generation model, multiple training sequences for training can be first obtained, and corresponding target sequences can be configured for the training sequences, wherein the target sequence is the correct sequence expected to be generated after the training sequence is input into the script generation model, wherein the target sequence can be not only specific sequence data but also a label for distinguishing categories.

[0109] Based on this, each training sequence and the corresponding target sequence can be input into the initial script generation model.

[0110] Furthermore, corresponding context information is obtained for each training sequence.

[0111] Each piece of context information corresponds to a word in the training sequence, and each piece of context information corresponding to each training sequence specifically includes interface test results of the training sequence in historical use, code structure characteristics exhibited during use, and other contents.

[0112] That is to say, each vocabulary vector in each training sequence corresponds to a piece of context information.

[0113] Furthermore, each training sequence, the corresponding context information and the corresponding target sequence are input into the initial script generation model, and the context information corresponding to each training sequence is constructed into a context matrix in the same context matrix construction method as in the above step S103.

[0114] In this embodiment, the initial script generation model has the same structure as the script generation model trained in the aforementioned embodiment.

[0115] Based on this, the attention score matrix of each training sequence is calculated according to the same model operation mode as the above step S104, and the attention score matrix and the corresponding context matrix are used to generate a corresponding attention weight matrix for the training sequence, and the attention weight matrix is ​​used to encode the corresponding training sequence to obtain the encoded sequence.

[0116] Furthermore, according to the same model operation mode as the above-mentioned step S105, the corresponding encoding sequences are decoded using the various attention weight matrices determined above, so that for each training sequence, the initial script generation model is obtained as the probability of outputting each target sequence based on the training sequence, wherein for the training sequence, only the corresponding target sequence is the expected correct result, and other non-corresponding target sequences can be considered as erroneous results.

[0117] In other words, using the initial script to generate the model can obtain the probability of outputting the correct result and the probability of outputting other incorrect results.

[0118] In this embodiment, the probability of the initial script generation model outputting the correct result, that is, the probability of outputting the corresponding target sequence, can be considered as the difference between the initial script generation model and the correct result.

[0119] Based on this, in each round of training, the probability of each training sequence outputting the correct result can be used to calculate the cross entropy loss, and whether the training is completed can be determined based on the cross entropy loss.

[0120] Specifically, the cross entropy loss can be determined according to the following formula (3), that is, the cross entropy loss function:

[0121]

[0122] Where L represents the cross entropy loss, N represents the total number of training sequences, i represents the i-th training sequence, t represents the t-th time step of the decoder, and T y represents the total number of time steps, y t represents the target sequence or the label representing the target sequence, w yt Represents y t The weight of x represents the input training sequence, P(y t |y <t, x) means that when the training sequence x is input, the target sequence y is output at the tth time step t probability.

[0123] Further, based on the cross entropy loss determined above and a preset convergence threshold, when the cross entropy loss satisfies the convergence threshold, it is considered that the initial script generation model has completed training.

[0124] Furthermore, when the cross entropy loss does not meet the convergence threshold, the parameters in the initial script generation model are adjusted to obtain the script generation model to be trained.

[0125] Furthermore, each training sequence and its corresponding target sequence are input into the script generation model to be trained, so as to carry out the next round of model training.

[0126] Furthermore, each training sequence is predicted in the above manner to obtain the probability of each training sequence outputting a corresponding target sequence.

[0127] Based on this, the cross entropy loss in this round of training is determined, and the convergence threshold set above is used to determine whether the cross entropy loss of the current round meets the convergence threshold.

[0128] Furthermore, when the convergence threshold is met, it is considered that the script generation model to be trained in the current round has completed training.

[0129] It can be seen that in this embodiment, when the initial script generation model is trained, the context information is introduced so that the trained script generation model can incorporate the context information into the prediction, and due to the introduced context information, the trained script generation model can generate a test script with more comprehensive content.

[0130] In another embodiment of the present application, reference Figure 2 , provides the overall process of using pre-trained script generation models to complete interface testing.

[0131] In this embodiment, if Figure 2 As shown, the overall process of interface testing is divided into obtaining interface information, model processing, obtaining test scripts, verifying and modifying test scripts, executing test scripts and generating reports.

[0132] When acquiring the interface information, firstly, step S201 is executed to determine the interface to be tested.

[0133] After the interface to be tested is determined, step S202 is further performed to scan the description information of the interface and generate a corresponding file.

[0134] In this step, a preset scanning tool may be used to scan the interface to be tested, thereby obtaining description information of the test interface.

[0135] Further, the model processing process is entered, and step S203 is executed to input a script to generate a model.

[0136] The interface scanning tool is automatically connected to the script generation model, so that the scanning tool can directly and automatically input the description information of the scanned interface into the script generation model, and make the script generation model execute step S204 to generate a test script.

[0137] In this step, the script generation model generates a corresponding test script according to the description information of the interface in accordance with the generation method in the above-mentioned embodiment.

[0138] Based on this, step S205 is further executed on the generated test script to determine whether manual verification is required.

[0139] In this step, the interface tester can make a judgment based on the actual situation.

[0140] Furthermore, when the judgment result of step S205 is no, no manual verification is performed, and accordingly, step S206 can be further executed to execute the test script.

[0141] Specifically, according to the normal scenario or abnormal scenario in the test script, each instruction or operation therein is executed for the interface to be tested, so as to obtain the response of the interface to be tested, and use the corresponding result as a test report, that is, executing step S207 and outputting the test report.

[0142] In this step, the response obtained by executing the test script may specifically include, for example, information such as input parameters of the interface to be tested, response results, and response duration.

[0143] In some embodiments, the response status and the detailed analysis thereof may be automatically generated into a visual test report for visual presentation.

[0144] In this embodiment, based on the judgment in step S205, when the judgment result is yes, that is, manual verification is performed, step S208, manual verification, is further performed.

[0145] In this step, the generated test scripts are manually verified to enhance the quality of the test scripts, avoid significant errors in the fully automatically generated test scripts, and ensure that the test scripts are comprehensive, correct and effective.

[0146] Further, based on the manual verification, step S209 is further executed to determine whether the verification is passed.

[0147] When the judgment result of step S209 is no, that is, there is a problem with the automatically generated test script, it returns to step S204 to allow the script generation model to generate the test script again. Before generating the test script again, the problems in the test script are analyzed to optimize the parameters of the script generation model, thereby achieving the effect of providing feedback to the script generation model.

[0148] Further, when the judgment result of step S209 is yes, that is, the verification is passed, the process proceeds to step S206, so as to complete the test of the interface to be tested by using the test script.

[0149] It can be seen that in this embodiment, by connecting the scanning tool with the script generation model, an automated process from scanning the interface to generating the test script is achieved, and the quality of the automatically generated test script is further guaranteed through the manual verification link.

[0150] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, an embodiment of the present application further provides a test script generating device.

[0151] refer to Figure 3 , the test script generating device comprises:

[0152] An acquisition module 301 is used to acquire description information of a target interface, where the description information includes at least one text sequence;

[0153] A conversion module 302, configured to convert at least one text sequence into at least one corresponding numerical sequence, and obtain context information corresponding to each numerical sequence, wherein each piece of context information includes a feature exhibited by the corresponding numerical sequence when in use;

[0154] A context information processing module 303, configured to input at least one numerical sequence and corresponding context information into a script generation model, and construct each context information into a context matrix using the script generation model;

[0155] A prediction module 304 is used to generate a corresponding attention weight matrix based on the attention score matrix and the corresponding context matrix corresponding to each numerical sequence using a script generation model, and encode the corresponding numerical sequence using the attention weight matrix to obtain a corresponding encoding sequence;

[0156] The output module 305 is used to use each attention weight matrix to decode the corresponding encoding sequence to obtain the corresponding output sequence, and use all the output sequences to generate a test script for testing the target interface.

[0157] The context information processing module 303 is specifically used to: compress a piece of context information corresponding to each vocabulary vector in each numerical sequence into a corresponding single context vector, where each piece of context information includes a feature exhibited by the corresponding vocabulary vector when in use;

[0158] The context vector corresponding to each vocabulary vector in the numerical sequence is used to form a context matrix corresponding to the numerical sequence.

[0159] Each numerical sequence includes at least one vocabulary vector.

[0160] The prediction module 304 is specifically used to obtain the context weight parameter of the context matrix corresponding to each numerical sequence;

[0161] The product of the context matrix corresponding to each numerical sequence and the corresponding context weight parameter is normalized with the corresponding attention score matrix to obtain the corresponding attention weight matrix.

[0162] Furthermore, before inputting at least one numerical sequence and corresponding context information into the script generation model, the following is further performed:

[0163] Obtaining a target sequence and corresponding context information corresponding to a training sequence, wherein the training sequence includes a text sequence corresponding to description information of each interface, each target sequence represents a sequence expected to be generated when predicting using the corresponding training sequence, and each piece of context information includes a feature exhibited by the corresponding training sequence when used;

[0164] The training sequence, the corresponding target sequence and the corresponding context information are input into the initial script generation model, and the script generation model is used to construct each context information into a context matrix;

[0165] Using the initial script generation model, a corresponding attention weight matrix is ​​generated based on the attention score matrix and the corresponding context matrix corresponding to each training sequence, and the corresponding training sequence is encoded using the attention weight matrix to obtain a corresponding encoding sequence;

[0166] Decode the corresponding encoding sequence using each attention weight matrix to obtain the probability of outputting each target sequence using the training sequence;

[0167] The cross entropy loss is determined using the probability of the target sequence corresponding to each training sequence output;

[0168] When the cross entropy loss meets the preset convergence threshold, the script generation model is obtained.

[0169] Furthermore, after determining the cross entropy loss using the probability of the target sequence corresponding to each training sequence output, the following is performed:

[0170] When the cross entropy loss does not meet the preset convergence threshold, the parameters in the initial script generation model are adjusted to obtain the script generation model to be trained;

[0171] Input each training sequence and the corresponding target sequence used for training into the script generation model to be trained, and use the probability of each training sequence outputting the corresponding target sequence to determine the cross entropy loss;

[0172] When the cross entropy loss meets the preset convergence threshold, the script generation model is obtained.

[0173] The output module 305 is specifically used to restore each output sequence to a running code in a predetermined format, and compose each running code into a test script.

[0174] Figure 4 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application is shown.

[0175] The electronic device may include a processor 401 and a memory 402 storing computer program instructions.

[0176] Specifically, the processor 401 may include a central processing unit (CPU), or an application specific integrated circuit (ASIC), or may be configured to implement one or more integrated circuits of the embodiments of the present application.

[0177] Memory 402 may include a large capacity memory for data or instructions. By way of example and not limitation, memory 402 may include a hard disk drive (HDD), a floppy disk drive, a flash memory, an optical disk, a magneto-optical disk, a magnetic tape, or a universal serial bus (USB) drive or a combination of two or more of these. In appropriate cases, memory 402 may include a removable or non-removable (or fixed) medium. In appropriate cases, memory 402 may be inside or outside of an integrated gateway disaster recovery device. In a specific embodiment, memory 402 is a non-volatile solid-state memory.

[0178] The memory 402 may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk storage medium device, an optical storage medium device, a flash memory device, an electrical, optical or other physical / tangible memory storage device. Thus, typically, the memory includes one or more tangible (non-transitory) computer-readable storage media (e.g., a memory device) encoded with software including computer-executable instructions, and when the software is executed (e.g., by one or more processors), it is operable to perform the operations described with reference to the method according to an aspect of the present disclosure.

[0179] The processor 401 implements any one of the test script generation methods in the above embodiments by reading and executing computer program instructions stored in the memory 402 .

[0180] In one example, the electronic device may further include a communication interface 403 and a bus 410. Figure 4 As shown, the processor 401, the memory 402, and the communication interface 403 are connected via a bus 410 and communicate with each other.

[0181] The communication interface 403 is mainly used to implement communication between various modules, devices, units and / or equipment in the embodiments of the present application.

[0182] Bus 410 includes hardware, software or both, and the components of online data flow billing equipment are coupled to each other. For example, but not limitation, bus may include accelerated graphics port (Accelerated Graphics Port, AGP) or other graphics bus, enhanced industry standard architecture (Extended Industry Standard Architecture, EISA) bus, front-end bus (FSB), hypertransmission (Hyper Transport, HT) interconnection, industry standard architecture (IndustryStandard Architecture, ISA) bus, infinite bandwidth interconnection, low pin count (LPC) bus, memory bus, micro channel architecture (MCA) bus, peripheral component interconnection (PCI) bus, PCI-Express (PCI-X) bus, serial advanced technology attachment (SATA) bus, video electronics standard association local (VLB) bus or other suitable bus or two or more of these combinations. In appropriate cases, bus 410 may include one or more buses. Although the present application embodiment describes and shows a specific bus, the present application considers any suitable bus or interconnection.

[0183] In addition, in combination with the test script generation method in the above embodiment, the embodiment of the present application can provide a computer storage medium for implementation. The computer storage medium stores computer program instructions; when the computer program instructions are executed by a processor, any one of the test script generation methods in the above embodiment is implemented.

[0184] An embodiment of the present application also provides a computer program product, including a computer program, which implements any one of the test script generation methods in the above embodiments when the computer program is processed and executed.

[0185] It should be clear that the present application is not limited to the specific configuration and processing described above and shown in the figures. For the sake of simplicity, a detailed description of the known method is omitted here. In the above embodiments, several specific steps are described and shown as examples. However, the method process of the present application is not limited to the specific steps described and shown, and those skilled in the art can make various changes, modifications and additions, or change the order between the steps after understanding the spirit of the present application.

[0186] The functional blocks shown in the above-described block diagram can be implemented as hardware, software, firmware or a combination thereof. When implemented in hardware, it can be, for example, an electronic circuit, an application specific integrated circuit (ASIC), appropriate firmware, a plug-in, a function card, etc. When implemented in software, the elements of the present application are programs or code segments that are used to perform the required tasks. The program or code segment can be stored in a machine-readable medium, or transmitted on a transmission medium or a communication link by a data signal carried in a carrier wave. "Machine-readable medium" can include any medium capable of storing or transmitting information. Examples of machine-readable media include electronic circuits, semiconductor memory devices, ROM, flash memory, erasable ROM (EROM), floppy disks, CD-ROMs, optical disks, hard disks, optical fiber media, radio frequency (RF) links, etc. The code segment can be downloaded via a computer network such as the Internet, an intranet, etc.

[0187] It should also be noted that the exemplary embodiments mentioned in this application describe some methods or systems based on a series of steps or devices. However, this application is not limited to the order of the above steps, that is, the steps can be performed in the order mentioned in the embodiment, or in a different order from the embodiment, or several steps can be performed simultaneously.

[0188] Aspects of the present disclosure are described above with reference to the flowchart and / or block diagram of the method, device (system) and computer program product according to the embodiment of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device to produce a machine so that these instructions executed by the processor of the computer or other programmable data processing device enable the implementation of the function / action specified in one or more boxes of the flowchart and / or block diagram. Such a processor can be, but is not limited to, a general-purpose processor, a special-purpose processor, a special application processor, or a field programmable logic circuit. It can also be understood that each box in the block diagram and / or flowchart and the combination of boxes in the block diagram and / or flowchart can also be implemented by dedicated hardware that performs a specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions.

[0189] The above is only a specific implementation of the present application. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, modules and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here. It should be understood that the protection scope of the present application is not limited to this. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in this application, and these modifications or replacements should be included in the protection scope of this application.

Claims

1. A test script generation method, It is characterized in that include: Acquire description information of a target interface, wherein the description information includes at least one text sequence; Converting the at least one text sequence into at least one corresponding numerical sequence, and obtaining context information corresponding to each numerical sequence, each piece of context information including a feature exhibited by the corresponding numerical sequence when in use; Inputting the at least one numerical sequence and the corresponding context information into a script generation model, and constructing each context information into a context matrix using the script generation model; Using the script generation model, generating a corresponding attention weight matrix based on the attention score matrix corresponding to each numerical sequence and the corresponding context matrix, and encoding the corresponding numerical sequence using the attention weight matrix to obtain a corresponding encoding sequence; The corresponding encoding sequence is decoded using each attention weight matrix to obtain the corresponding output sequence, and all the output sequences are used to generate a test script for testing the target interface.

2. The test script generation method according to claim 1, It is characterized in that Each numerical sequence includes at least one vocabulary vector; The script generation model is used to construct each context information into a context matrix, including: Compressing a piece of context information corresponding to each vocabulary vector in each numerical sequence into a corresponding single context vector, each piece of context information including a feature exhibited by the corresponding vocabulary vector when used; The context vector corresponding to each vocabulary vector in the numerical sequence is used to form a context matrix corresponding to the numerical sequence.

3. The test script generating method according to claim 2, It is characterized in that The generating a corresponding attention weight matrix based on the attention score matrix corresponding to each numerical sequence and the corresponding context matrix includes: Obtain the context weight parameters of the context matrix corresponding to each numerical sequence; The product of the context matrix corresponding to each numerical sequence and the corresponding context weight parameter is normalized with the corresponding attention score matrix to obtain the corresponding attention weight matrix.

4. The test script generating method according to claim 1, It is characterized in that The step of generating a test script for testing the target interface by using all output sequences includes: Each output sequence is restored to a running code in a predetermined format, and each running code is combined into the test script.

5. The test script generating method according to claim 1, It is characterized in that Before inputting the at least one numerical sequence and the corresponding context information into the script generation model, the method further includes: Obtaining a target sequence and corresponding context information corresponding to a training sequence, wherein the training sequence includes a text sequence corresponding to description information of each interface, each target sequence represents a sequence expected to be generated when predicting using the corresponding training sequence, and each piece of context information includes a feature exhibited by the corresponding training sequence when used; Inputting the training sequence, the corresponding target sequence and the corresponding context information into an initial script generation model, and constructing each context information into a context matrix using the script generation model; The initial script generation model is used to obtain the context information corresponding to each training sequence and construct a context matrix, where each piece of context information includes the characteristics exhibited by the corresponding training sequence when used; Using the initial script generation model, a corresponding attention weight matrix is ​​generated based on the attention score matrix and the corresponding context matrix corresponding to each training sequence, and the corresponding training sequence is encoded using the attention weight matrix to obtain a corresponding encoding sequence; Decode the corresponding encoding sequence using each attention weight matrix to obtain the probability of outputting each target sequence using the training sequence; The cross entropy loss is determined using the probability of the target sequence corresponding to each training sequence output; When the cross entropy loss satisfies a preset convergence threshold, the script generation model is obtained.

6. The test script generating method according to claim 5, It is characterized in that After determining the cross entropy loss by using the probability of outputting the corresponding target sequence of each training sequence, the method further includes: When the cross entropy loss does not meet a preset convergence threshold, adjusting parameters in the initial script generation model to obtain a script generation model to be trained; Input each training sequence and the corresponding target sequence used for training into the script generation model to be trained, and determine the cross entropy loss using the probability of each training sequence outputting the corresponding target sequence; When the cross entropy loss meets a preset convergence threshold, the script generation model is obtained.

7. A test script generating device, It is characterized in that The device comprises: An acquisition module, used for acquiring description information of a target interface, wherein the description information includes at least one text sequence; a conversion module, configured to convert the at least one text sequence into at least one corresponding numerical sequence, and obtain context information corresponding to each numerical sequence, wherein each piece of context information includes a feature exhibited by the corresponding numerical sequence when in use; A context information processing module, used for inputting the at least one numerical sequence and the corresponding context information into a script generation model, and constructing each context information into a context matrix using the script generation model; A prediction module, used to generate a corresponding attention weight matrix based on the attention score matrix and the corresponding context matrix corresponding to each numerical sequence using the script generation model, and encode the corresponding numerical sequence using the attention weight matrix to obtain a corresponding encoding sequence; The output module is used to use each attention weight matrix to decode the corresponding encoding sequence to obtain the corresponding output sequence, and use all the output sequences to generate a test script for testing the target interface.

8. An electronic device, It is characterized in that The device comprises: a processor and a memory storing computer program instructions; When the processor executes the computer program instructions, the test script generating method according to any one of claims 1 to 6 is implemented.

9. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer program instructions, and when the computer program instructions are executed by a processor, the test script generating method according to any one of claims 1 to 6 is implemented.

10. A computer program product, It is characterized in that When the instructions in the computer program product are executed by a processor of an electronic device, the electronic device executes the test script generating method as described in any one of claims 1 to 6.