Test case generation method and device, computer storage medium and program product

By obtaining test requirements keywords and using the transfer matrix to generate test cases, the problem of low generation efficiency of test cases in the existing technology is solved, and the automated generation link is realized, which improves the generation efficiency and resource utilization of test cases.

CN119322750APending Publication Date: 2025-01-17BEIJING AUTONAVI YUNMAP TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411515652.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-28
Publication Date
2025-01-17

AI Technical Summary

Technical Problem

In the prior art, the generation efficiency of program code test cases is low, resulting in limited release of program codes, and it is necessary to improve the generation efficiency of test cases to reduce resource investment.

Method used

By obtaining test requirements keywords, using the pre-established transfer matrix to determine the use case keywords and use case keyword sequences, generate test cases, realize automated generation links, and batch-fast generation of test cases without manual writing.

Benefits of technology

It improves the generation efficiency of test cases, reduces resource investment, realizes batch and rapid generation of test cases, and reduces the need for manual writing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119322750A_ABST
    Figure CN119322750A_ABST
Patent Text Reader

Abstract

The invention provides a test case generation method and device, a computer storage medium and a program product. The method comprises the steps of obtaining at least one test demand keyword; based on a pre-established first transfer matrix, determining a first use case keyword of each test demand keyword; for a first use case keyword of one demand keyword, based on a pre-established second transfer matrix, determining a second use case keyword sequence appearing after the first use case keyword; and generating a test case corresponding to the demand keyword based on the first case keyword and a second case keyword included in the second case keyword sequence. Automatic generation of the test case is achieved, and the problem that the efficiency of manual generation of the test case is low is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of testing technology, and in particular to a method, device, computer storage medium and program product for generating a test case. Background Art

[0002] In most cases, program code needs to be tested before it is released, and only after the test passes can it be compiled into a software package for release or deployed as an online service. To test the program code, testers need to write test cases based on the functional items and test requirements described in the test requirements document, and test the program code based on the test cases to test whether the program code meets the corresponding requirements. Among them, the test requirements document specifies the functions, services, or performance that need to be verified, that is, it specifies "what to test". The test case specifies the specific steps and conditions for verifying the function, service, or performance, that is, it specifies "how to test".

[0003] Since the manual writing of test cases is too inefficient and affects the release of program codes, improving the efficiency of generating test cases has been a problem that technicians in this field have been trying to solve. Summary of the invention

[0004] The present application aims to solve one of the technical problems in the related art at least to some extent.

[0005] To this end, the first purpose of this application is to propose a test case generation method, which constructs a test case automatic generation link based on requirement keywords, use case keywords and a preset transition probability matrix, realizes batch and rapid generation of test cases without manual writing, improves the test case generation efficiency and reduces resource investment.

[0006] The second objective of this application is to provide a test case generation device.

[0007] The third object of the present application is to provide a computer-readable storage medium.

[0008] A fourth object of the present application is to provide a computer program product.

[0009] To achieve the above-mentioned purpose, the first embodiment of the present application proposes a method for generating a test case, comprising:

[0010] Get at least one test requirement keyword;

[0011] Determine a first use case keyword for each test requirement keyword based on a pre-established first transfer matrix;

[0012] For a first use case keyword of a test requirement keyword, based on a pre-established second transfer matrix, determining a second use case keyword sequence that appears after the first use case keyword, wherein the second use case keyword sequence includes at least one second use case keyword;

[0013] A test case corresponding to the test requirement keyword is generated based on the first use case keyword and the second use case keyword included in the second use case keyword sequence.

[0014] To achieve the above-mentioned purpose, the second embodiment of the present application proposes a test case generation device, including:

[0015] A first acquisition module, used to acquire at least one test requirement keyword;

[0016] A first determination module, configured to determine a first use case keyword for each test requirement keyword based on a pre-established first transfer matrix;

[0017] A second determination module is used to determine, for a first use case keyword of a test requirement keyword, a second use case keyword sequence that appears after the first use case keyword based on a pre-established second transfer matrix, wherein the second use case keyword sequence includes at least one second use case keyword;

[0018] The first generating module is used to generate a test case corresponding to the test requirement keyword based on the first use case keyword and the second use case keyword included in the second use case keyword sequence.

[0019] To achieve the above-mentioned purpose, the third aspect embodiment of the present application proposes a computer-readable storage medium, in which computer execution instructions are stored. When the computer execution instructions are executed by a processor, they are used to implement the test case generation method as described in the first aspect embodiment.

[0020] To achieve the above-mentioned purpose, the fourth aspect of the present application proposes a computer program product, including a computer program, which, when executed by a processor, implements the test case generation method as described in the first aspect of the embodiment.

[0021] The test case generation method, device, computer storage medium and program product provided by the present application first obtain at least one test requirement keyword, and then determine the first use case keyword of each test requirement keyword based on a pre-established first transfer matrix. Afterwards, for the first use case keyword of each test requirement keyword, a second use case keyword sequence that appears after the first use case keyword is determined using a pre-established second transfer matrix, thereby generating a test case corresponding to the test requirement keyword based on at least one second use case keyword included in the first use case keyword and the second use case keyword sequence. In this way, batch rapid generation of test cases can be achieved without manual writing, thereby improving the generation efficiency of test cases and reducing resource investment.

[0022] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:

[0024] Figure 1 A flowchart of a method for generating a test case provided in an embodiment of the present application;

[0025] Figure 2 A flowchart of another method for generating a test case provided in an embodiment of the present application;

[0026] Figure 3 A schematic diagram of a method for generating a transfer matrix provided in an embodiment of the present application;

[0027] Figure 4 A flowchart of another method for generating a test case provided in an embodiment of the present application;

[0028] Figure 5 A flowchart of another method for generating a test case provided in an embodiment of the present application;

[0029] Figure 6 A flowchart of another method for generating a test case provided in an embodiment of the present application;

[0030] Figure 7 A flowchart of another method for generating a test case provided in an embodiment of the present application;

[0031] Figure 8 A schematic diagram of the structure of a test case generation device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0032] Embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.

[0033] The following describes the test case generation method and device of the embodiment of the present application with reference to the accompanying drawings.

[0034] Figure 1 A flowchart of a method for generating a test case provided in an embodiment of the present application.

[0035] like Figure 1 As shown, the test case generation method includes the following steps:

[0036] Step 101, obtaining at least one test requirement keyword.

[0037] Among them, test requirement keywords are words or phrases used to clarify the test objectives, scenarios, etc. of the test cases.

[0038] In this application, at least one test requirement keyword input by the tester according to the actual test business needs can be obtained. Alternatively, the text input by the tester to describe the test requirements can be obtained, and then the text can be segmented using a word segmentation tool to obtain at least one word or phrase as the test requirement keyword after segmentation. Each test requirement keyword can be used to generate a corresponding test case.

[0039] In some possible embodiments, a test requirement document of the software to be tested may be obtained first, and then the content in the test requirement document may be segmented to obtain at least one test requirement keyword.

[0040] In an embodiment of the present application, any tool or model with a text segmentation function can be used to segment the content in the test requirement document, and then at least one word or phrase that can express the key points of the test requirement can be selected from the segmentation results as the test requirement keyword.

[0041] Since the test requirement document usually describes in detail the various conditions and standards that the software needs to meet during the testing phase, by segmenting the content in the test requirement document to obtain the test requirement keywords, we can quickly and accurately grasp the key points when testing the software and improve the quality of the test requirement keywords.

[0042] Step 102: determining a first use case keyword for each test requirement keyword based on a pre-established first transfer matrix.

[0043] Among them, use case keywords are used to describe and organize test cases, which can clarify the test objectives, steps, scope and methods for testers or machine testing processes.

[0044] The first transfer matrix is ​​pre-constructed based on the test requirement keywords and the use case keywords, and the first transfer matrix records the probability of the test requirement keywords being transformed into use case keywords. In other words, each element in the first transfer matrix can correspond to a test requirement keyword and a use case keyword, and the value of the element is the probability of the use case keyword appearing after the test requirement keyword when constructing the test case.

[0045] It should be noted that, in the embodiment of the present application, the scale of the first transfer matrix is ​​large enough, and the first transfer matrix can be used to determine the transition probability between any test requirement keyword and use case keyword.

[0046] In an embodiment of the present application, each test requirement keyword can be firstly passed into the first transfer matrix to obtain multiple transfer probabilities corresponding to each test requirement keyword (i.e., the values ​​of the elements in the first transfer matrix), and then the use case keyword corresponding to the maximum value among all the transfer probabilities can be determined as the first use case keyword of the test requirement keyword. When there are multiple maximum values, the use case keyword corresponding to each maximum value can be determined as the first use case keyword of the test requirement keyword.

[0047] Alternatively, a threshold for screening use case keywords may be pre-set according to the actual test case generation accuracy requirements, etc. Then, after obtaining multiple transition probabilities corresponding to each test requirement keyword, each transition probability is compared with the threshold, and the use case keyword corresponding to the transition probability greater than the threshold is determined as the first use case keyword of the test requirement keyword.

[0048] Step 103 , for a first use case keyword of a test requirement keyword, based on a pre-established second transfer matrix, determine a second use case keyword sequence that appears after the first use case keyword.

[0049] The second use case keyword sequence includes at least one second use case keyword.

[0050] The second transfer matrix is ​​pre-constructed based on the use case keywords, and records the probability of another use case keyword appearing directly after a use case keyword. In other words, each element in the second transfer matrix can correspond to two use case keywords, and the value of the element is the probability of one use case keyword being followed by another use case keyword when constructing a test case.

[0051] In the embodiment of the present application, each first use case keyword can be used as the starting point for generating a test case. Each first use case keyword can be passed into the second transfer matrix to obtain multiple transition probabilities corresponding to the first use case keyword (i.e., the values ​​of the elements in the second transfer matrix). Then, the use case keyword corresponding to the maximum value of all transition probabilities is determined as the first second use case keyword that appears after the first use case keyword. When there are multiple maximum values, the use case keyword corresponding to each maximum value can be determined as the first second use case keyword that appears after the first use case keyword.

[0052] Alternatively, a threshold for filtering use case keywords may be pre-set, and then after obtaining multiple transition probabilities corresponding to each test requirement keyword, each transition probability is compared with the threshold, and the use case keyword corresponding to the transition probability greater than the threshold is used to determine the first second use case keyword that appears after the first use case keyword.

[0053] Afterwards, the next second use case keyword can be determined according to the first second use case keyword determined above and the second transfer matrix. In this case, the method for determining the second use case keyword is the same as the method for determining the first second use case keyword. Repeating the operation of generating the next second use case keyword multiple times can obtain multiple second use case keywords that appear sequentially after the first use case keyword.

[0054] In order to prevent an infinite loop in the second use case keyword determination process, an end checkpoint may be set in the present application. When the end checkpoint is met, the determination of new second use case keywords is stopped, and at least one second use case keyword that has been determined is obtained in a determined order to obtain a second use case keyword sequence. The end checkpoint may be the number of operations for determining the next second use case keyword, or the obtained second use case keyword may be a keyword that marks the end of the use case content.

[0055] Step 104: Generate a test case corresponding to the test requirement keyword based on the first use case keyword and the second use case keyword included in the second use case keyword sequence.

[0056] In the embodiment of the present application, the first use case keyword and all the second use case keywords in the second use case keyword sequence can be combined together in a determined order to obtain a test case corresponding to the test requirement keyword.

[0057] For example, after obtaining the first use case keyword B corresponding to the test requirement keyword A and the second use case keyword C, second use case keyword D and second use case keyword E included in the second use case keyword sequence, a test case corresponding to the test requirement keyword A can be generated, namely: first use case keyword B, second use case keyword C, second use case keyword D, second use case keyword E.

[0058] In the embodiment of the present application, a parallel approach can be adopted to generate test cases for each test requirement keyword obtained in step 101 according to the method described in steps 102 to 104. Moreover, when there are multiple use case keywords determined in any one cycle, the next use case keyword to be transferred can also be determined for all use case keywords at the same time. In this way, batch generation of test cases can be achieved, further improving efficiency.

[0059] It should be noted that the test case generation method proposed in the present disclosure can generate test cases for guiding manual operation processes to verify whether manual operations are correctly performed according to predetermined steps and sequences, and check whether the operation results meet expectations, such as test cases corresponding to bank card withdrawal operations. Alternatively, test cases for guiding machine operation processes can be generated to verify whether machines (such as automated testing tools, robots, etc.) can correctly perform operations according to predetermined procedures and instructions, and check whether the operation results meet expectations, such as test cases corresponding to device data collection.

[0060] In this embodiment, at least one test requirement keyword is first obtained, and then the first use case keyword of each test requirement keyword is determined based on a pre-established first transfer matrix. Afterwards, for the first use case keyword of each test requirement keyword, a second use case keyword sequence that appears after the first use case keyword is determined using a pre-established second transfer matrix, thereby generating a test case corresponding to the test requirement keyword based on at least one second use case keyword included in the first use case keyword and the second use case keyword sequence. In this way, batch rapid generation of test cases can be achieved without manual writing, thereby improving the generation efficiency of test cases and reducing resource investment.

[0061] In addition, in the related art, in order to generate test cases, the nodes in the software network and the dependency strength between nodes can also be relied on as the state and the transition probability between states. Specifically, according to the software structure, the package-level and class-level software networks are generated respectively. Then, according to the class-level and package-level software network structures, the dependency strength between nodes in each network is calculated to determine the state probability and the transition probability; then, according to the hidden Markov model, test cases are automatically generated for the software. However, this method needs to consider the software structure, and now the software functions are becoming more and more abundant, the software structure is becoming more and more complex, and the changes in software structure are also changing more and more frequently. This method requires frequent generation of package-level and class-level software networks, as well as the dependency strength between nodes, and the generation efficiency is low.

[0062] Figure 2 A flowchart of a method for generating a test case provided in an embodiment of the present application.

[0063] like Figure 2 As shown, the test case generation method includes the following steps:

[0064] Step 201, obtaining at least one test requirement keyword.

[0065] Step 202: Determine a first use case keyword for each test requirement keyword based on a pre-established first transfer matrix.

[0066] For detailed description of the above steps 201 and 202, please refer to the above embodiments of the present application, which will not be repeated here.

[0067] Step 203: Determine the first second use case keyword that appears after the first use case keyword of a test requirement keyword based on the pre-established second transfer matrix.

[0068] In an embodiment of the present application, a first use case keyword is first passed into the second transfer matrix to obtain multiple transition probabilities corresponding to the first use case keyword in the second transfer matrix. Then, the use case keyword corresponding to the maximum transition probability among all the transition probabilities can be determined as the first second use case keyword that appears after the first use case keyword. When there are multiple maximum values, the use case keyword corresponding to each maximum transition probability can be determined as the first second use case keyword that appears after the first use case keyword.

[0069] Alternatively, a threshold for filtering use case keywords may be pre-set, and then after determining multiple transition probabilities corresponding to each test requirement keyword, each transition probability is compared with the threshold, and the use case keyword corresponding to the transition probability greater than the threshold is determined as the first second use case keyword that appears after the first use case keyword.

[0070] Step 204: Determine the (i+1)th second use case keyword that appears after the (i)th second use case keyword based on the second transfer matrix, where i is a natural number.

[0071] In the disclosed embodiment, i is a natural number. When the first second use case keyword appears after the first use case keyword, the value of i is 1, and i+1=2. Then, the second second use case keyword that appears after the first second use case keyword can be determined in the second transfer matrix.

[0072] It should be noted that the method for determining the second use case keyword should be the same. That is, each time the second use case keyword is determined, the use case keyword corresponding to the maximum transfer probability or the use case keyword with a transfer probability greater than a threshold should be selected.

[0073] Step 205, if i+1 is not equal to the preset threshold, and the i+1th second use case keyword is not the end keyword, then i=i+1, and return to the step of determining the i+1th second use case keyword that appears after the i-th second use case keyword.

[0074] The preset threshold refers to the maximum number of times the next second use case keyword is determined, and the threshold can be dynamically set by observing the quality of use case content generation.

[0075] The end keyword refers to a word or phrase used to indicate the end of the use case content, such as "inspection completed".

[0076] In an embodiment of the present application, each time a new second use case keyword is obtained, it can be determined whether the number of second use case keywords obtained previously (i.e., i+1) is equal to a preset threshold, and whether the i+1th second use case keyword is an end keyword.

[0077] When i+1 is not equal to the preset threshold and the i+1th second use case keyword is not the end keyword, it means that the generation of the current test case has not yet ended, and the process can return to step 204 to continue determining the next second use case keyword.

[0078] Step 206: If i+1 is equal to a preset threshold, or the i+1th second use case keyword is an end keyword, then all determined second use case keywords constitute a second use case keyword sequence.

[0079] In an embodiment of the present application, the operation of generating the next second use case keyword using the second transfer matrix is ​​repeated multiple times. After obtaining the second use case keyword once, if the number of second use case keywords obtained previously (i.e., i+1) is equal to a preset threshold, or the i+1th second use case keyword is any one of the end keywords, then stop determining a new second use case keyword and construct all determined second use case keywords into a second use case keyword sequence.

[0080] Step 207: Generate a test case corresponding to the requirement keyword based on the first use case keyword and the second use case keyword included in the second use case keyword sequence.

[0081] For a detailed description of the above step 207, please refer to the above embodiments of the present application, which will not be repeated here.

[0082] In this embodiment, the second use case keyword of the next transfer is determined in sequence by cyclically utilizing the second transfer matrix, thereby ensuring consistency among the use case keywords. In addition, whether the loop process is terminated is determined based on two conditions: whether the number of loops is equal to a preset threshold and whether the use case keyword is an end keyword. This can prevent an infinite loop of use case keyword determination operations, and is beneficial to ensuring efficient use of resources.

[0083] The following describes the test case generation process provided in this embodiment with reference to examples.

[0084] First, obtain the test requirement keyword A used to generate the test case, determine the maximum transfer probability corresponding to the test requirement keyword A in the first transfer matrix, and determine the use case keyword B corresponding to the maximum transfer probability as the first use case keyword of the test requirement keyword A.

[0085] Then determine the maximum transition probability corresponding to the use case keyword B in the second transfer matrix, and determine the use case keyword C corresponding to the maximum transition probability as the first second use case keyword, at this time i = 1. And in the second transfer matrix, according to the maximum transition probability corresponding to the use case keyword C, determine the use case keyword D corresponding to the maximum transition probability as the second second use case keyword. When the preset threshold is 10 and the end keyword is the end of detection, since i+1=2<10, and the use case keyword C is not the end keyword, the value of i can be added by 1, at this time i=2. Then in the second transfer matrix, according to the maximum transition probability corresponding to the use case keyword D, determine the use case keyword E corresponding to the maximum transition probability as the third second use case keyword. Since 3<10, but the use case keyword E is the end keyword, the second use case keyword sequence can be determined as: use case keyword C, use case keyword D, use case keyword E.

[0086] Afterwards, the first use case keyword and the second use case keyword can be combined to obtain the test cases corresponding to the test requirement keyword A: use case keyword B, use case keyword C, use case keyword D, and use case keyword E.

[0087] Alternatively, when the use case keyword E is not the end keyword, the next second use case keyword can be repeatedly determined. When the second use case keyword determined each time is not the end keyword, after the 10th second use case keyword is obtained (i.e., i+1=10), the determination of a new second use case keyword can be stopped, and the 10 second use case keywords determined previously form a second use case keyword sequence. After that, all the second use case keywords in the first use case keyword and the second use case keyword sequence are sequentially combined to obtain a test case.

[0088] It should be noted that, in the present application, the transition probabilities corresponding to the elements in the first transfer matrix and the second transfer matrix are obtained by statistics and calculations of historical test requirements and historical test cases. Figure 3 The method shown is used to generate the first transfer matrix and the second transfer matrix.

[0089] Figure 3 A schematic flow chart of a method for generating a transfer matrix provided in an embodiment of the present application.

[0090] like Figure 3 As shown, the method for generating a transfer matrix comprises the following steps:

[0091] Step 301 , obtaining a demand keyword library, wherein the demand keyword library includes: test demand keywords obtained based on historical test requirement documents.

[0092] In an embodiment of the present application, an existing demand keyword library may be obtained, and the test demand keywords contained in the demand keyword library may be obtained by performing word segmentation processing on a large number of historical test demand documents.

[0093] Step 302: Obtain a use case keyword library, where the use case keyword library includes: use case keywords obtained based on historical test cases.

[0094] In an embodiment of the present application, an existing use case keyword library may be obtained, and the use case keywords contained in the use case keyword library may be extracted from a large number of historical test cases.

[0095] Step 303: For each test requirement keyword in the requirement keyword library, calculate a first transfer probability of the test requirement keyword to each use case keyword in the use case keyword library.

[0096] Among them, the first transition probability of transferring to a use case keyword is calculated based on the ratio of the first number to the second number; the first number is: the number of times the use case keyword and the test requirement keyword appear at the same time in historical test requirement documents and historical test cases; the second number is: the number of times the test requirement keyword appears in historical test requirement documents and historical test cases.

[0097] In the embodiment of the present application, a Markov chain connecting the state space of the requirement keyword library and the state space of the use case keyword library can be established, and the first transition probability from one state in the requirement keyword library (i.e., the test requirement keyword) to another state in the use case keyword library (i.e., the use case keyword) is determined by using the first transition matrix, wherein the calculation formula of the first transition probability can be shown as follows (1):

[0098]

[0099] It should be noted that in formula (1), i is a test requirement keyword in the requirement keyword library, and j is a use case keyword in the use case keyword library. P′ represents the first transition probability from the test requirement keyword to the use case keyword, S′ n is the state before the transition in the Markov chain, S′ n+1 is the state after the transition in the Markov chain. count′(i,j) is the first count, and count′(i) is the second count.

[0100] For example, the first transition probability of the test requirement keyword A to the use case keyword B = (the number of times AB appear simultaneously in historical test requirement documents + the number of times AB appear simultaneously in historical test cases) / (the number of times A appears in historical test requirement documents + the number of times A appears in historical test cases).

[0101] Step 304: Generate a first transfer matrix based on the calculated first transfer probability.

[0102] In an embodiment of the present application, the test requirement keyword and use case keyword corresponding to each first transition probability can be used as the row coordinates and column coordinates of the first transition probability in the matrix, respectively, and the first transfer matrix can be obtained by determining all calculated first transition probabilities to corresponding positions.

[0103] Step 305: For any use case keyword in the use case keyword library, calculate a second transition probability of the use case keyword to other use case keywords.

[0104] Among them, the second transition probability of the use case keyword to the next use case keyword is calculated based on the ratio of the third number to the fourth number; the third number is: the number of times the next use case keyword appears in the next state of the use case keyword; the fourth number is: the number of times the use case keyword appears in historical test cases.

[0105] In an embodiment of the present application, a Markov chain corresponding to the state space of the use case keyword library can be constructed, and each use case keyword in the use case keyword library is a state. The Markov chain can determine the second transition probability of the use case keyword from one use case keyword to another state by using a second transition matrix. The calculation formula of the second transition probability can be shown as follows (2):

[0106]

[0107] It should be noted that in formula (2), i is a use case keyword in the use case keyword library (before transfer), j is another use case keyword different from i in the use case keyword library (after transfer), P represents the second transfer probability between use case keywords, S n is the state of the Markov chain before the transition, S n+1 is the state of the Markov chain after the conversion. count(i,j) is the third number, and count(i) is the fourth number.

[0108] For example, the second transition probability of use case keyword B to use case keyword C=(the number of times BC appear simultaneously in historical test cases and C is the next state of B) / (the number of times B appears in historical test cases).

[0109] Step 306: Generate a second transfer matrix based on the calculated second transfer probability.

[0110] In an embodiment of the present application, the use case keyword before the transfer and the use case keyword after the transfer corresponding to each second transition probability can be used as the row coordinate and column coordinate of the second transition probability in the matrix, respectively, and then the second transfer matrix is ​​obtained by determining all the calculated second transition probabilities to the corresponding positions.

[0111] In this embodiment, based on the keywords in historical test requirement documents and historical test cases, a requirement keyword library and a use case keyword library are constructed, and a first transfer matrix is ​​constructed by calculating the probability of transfer from a requirement keyword to a use case keyword, and a second transfer matrix is ​​constructed by calculating the probability of transfer from each use case keyword to other use case keywords.

[0112] It should be noted that, in the embodiment of the present application, the domain label corresponding to the test case to be generated can also be combined to supervise the generation process of the test case to ensure the reliability of the test case.

[0113] Figure 4 A flowchart of a method for generating a test case provided in an embodiment of the present application.

[0114] like Figure 4 As shown, the test case generation method includes the following steps:

[0115] Step 401, obtaining test requirement keywords and domain tags associated with the test requirement keywords.

[0116] Among them, the field tags associated with the test requirement keywords are used to limit the industry or application scenarios to which the test cases to be generated belong.

[0117] In the embodiment of the present application, the domain label associated with the test requirement keyword can be independently input by the tester in the test case generation system according to business needs, or it can be determined after obtaining the test requirement keyword by performing natural language analysis on the test requirement keyword. The present disclosure does not limit this. By using domain labels to limit the generation of test cases, it can be ensured that the test cases to be generated can cover the target functions or features required by the user, avoid generating irrelevant test cases, and improve the accuracy and pertinence of the test cases.

[0118] Step 402: Determine a first use case keyword corresponding to the test requirement keyword based on the first transfer matrix.

[0119] For a detailed description of step 402, please refer to other embodiments of the present application and will not be repeated here.

[0120] Step 403: Determine a first confidence level of a first use case keyword based on a language model associated with the domain tag.

[0121] Among them, the language model associated with domain labels refers to an open source model with natural language analysis capabilities, which can be a model trained and generated in advance based on professional knowledge associated with different domain labels.

[0122] In an embodiment of the present application, a language model associated with the domain label can be selected based on the acquired domain label, and then the requirement keyword and the first use case keyword can be input into the language model. Based on the target domain knowledge corresponding to the domain label, the necessity and availability of using the first use case keyword as a node of the test process corresponding to the test requirement keyword can be judged, thereby obtaining the first confidence level of the language model output for the first use case keyword.

[0123] Step 404: When the first confidence level is greater than or equal to the first threshold, determine the next use case keyword adjacent to the first use case keyword based on the first use case keyword and the second transfer matrix.

[0124] Among them, the first threshold is used to screen the use case keywords, indicating the minimum confidence level that can determine that a use case keyword meets the test requirements of the current target field, and its value can be determined according to the normative requirements of the test case to be generated in the target field, etc., and this application does not limit this. The larger the first threshold, the higher the degree of screening of the use case keywords.

[0125] In an embodiment of the present application, when the first confidence level is greater than or equal to the first threshold, it indicates that the first use case keyword is consistent with the field to which the test case to be generated belongs and has high availability. Then, in the second transfer matrix, the next use case keyword adjacent to the first use case keyword can be further determined.

[0126] It should be noted that, when the first confidence level is less than the first threshold, if the first use case keyword is used to continue to generate test cases, the generated test cases may not meet the needs of testers and have low usability. The first use case keyword corresponding to the test requirement keyword may be updated until the first confidence level corresponding to the first use case keyword is greater than or equal to the first threshold.

[0127] Step 405 , based on the first use case keyword and the next use case keyword, return to perform the operation of determining the first confidence level until a test case corresponding to the test requirement keyword is obtained.

[0128] In an embodiment of the present application, after determining the adjacent next use case keyword, the language model associated with the domain label can be used to determine the first confidence corresponding to the next use case keyword. When the first confidence is greater than or equal to the first threshold, the adjacent next use case keyword can be determined based on the next use case keyword and the second transfer matrix. Alternatively, when the first confidence is less than the first threshold, the next use case keyword can be updated, and the first confidence can be re-determined for the updated use case keyword. Then, the above operation is repeated until all use case keywords used to generate test cases are obtained.

[0129] It should be noted that in order to avoid determining use case keywords in an infinite loop, in this application, it is necessary to determine the end point of an operation cycle. The end point can be when the number of use case keywords reaches a preset number threshold, or when the most recently determined use case keyword is the keyword that marks the end of the use case content.

[0130] The quantity threshold may be dynamically set according to the quality requirements for the use case content generation, or may be determined according to the field type, etc., which is not limited in this application. The end identifier may be any one of the multiple end keywords commonly used in historical test cases.

[0131] That is to say, after each use case keyword is determined by the test case generation system, it can identify whether the use case keyword is an end mark, and the number of use case keywords is increased by 1, and the sum obtained is compared with the preset quantity threshold. When any use case keyword determined at one time is an end mark, or the corresponding number of use case keywords at this time is equal to the quantity threshold, the operation of determining the next use case keyword can be stopped, and all the use case keywords that have been obtained can be determined as use case keywords for generating test cases.

[0132] In an embodiment of the present application, after obtaining all use case keywords, the use case keywords can also be input into a general large model with natural language processing capabilities, allowing the large model to splice all use case keywords and output test cases.

[0133] In this embodiment, based on the transfer matrix, the use case keywords corresponding to the requirement keywords are first determined, and then the confidence of the use case keywords is verified using the language model of the field to which the requirement belongs. Only when the verification passes, the next use case keyword is generated until a test case is obtained. This realizes the automatic generation of test cases, improves the efficiency of test case generation, and supervises the use case generation process in combination with professional domain knowledge, further ensuring the accuracy and reliability of the generated use cases.

[0134] This embodiment provides another method for generating a test case. Figure 5 A flowchart of another test case generation method provided in an embodiment of the present application.

[0135] like Figure 5 As shown, the test case generation method may include the following steps:

[0136] Step 501, obtaining test requirement keywords and domain tags associated with the test requirement keywords.

[0137] Step 502: Determine a first use case keyword corresponding to the test requirement keyword based on the first transfer matrix.

[0138] Step 503: Determine a first confidence level of a first use case keyword based on a language model associated with the domain tag.

[0139] For detailed description of the above steps 501 to 503, please refer to the above embodiments of the present disclosure, which will not be repeated here.

[0140] It should be noted that, since in the first transfer matrix, there may be multiple matrix elements with equal values, it means that the transition probability between a test requirement keyword and multiple use case keywords may be equal, so a test requirement keyword may also have multiple first use case keywords, and multiple different test cases can be generated with different first use case keywords as the starting point.

[0141] Step 504 : Determine the next use case keyword adjacent to the first use case keyword based on each first use case keyword corresponding to the first confidence greater than or equal to the first threshold and the second transfer matrix.

[0142] In an embodiment of the present application, each first use case keyword whose corresponding first confidence is greater than or equal to the first threshold can be used as the starting point for generating a test case, and then according to the second transfer matrix and the method described in the above embodiment of the present application, the next use case keyword adjacent to it can be obtained respectively.

[0143] Step 505 , returning to perform the operation of determining the first confidence level based on each first use case keyword and the adjacent next use case keyword, until a plurality of test cases corresponding to the requirement keyword are obtained.

[0144] In the embodiment of the present application, the operation of determining the first confidence level corresponding to the use case keyword, comparing the first confidence level with the first threshold, and determining the next use case keyword adjacent to the use case keyword can be performed in a loop. Until the end point of the operation cycle is identified, all use case keywords used to generate each test case are obtained. Afterwards, the open source large model can be used to splice these use case keywords to obtain test cases.

[0145] That is to say, each test requirement keyword can identify at least one test case.

[0146] In the embodiment of the present application, when a requirement keyword corresponds to multiple use case keywords, different test cases are generated based on all use case keywords with confidence greater than a threshold. The number and content of generated use cases can be enriched, and a rich selection of test cases can be provided for testers.

[0147] Step 506, display multiple test cases.

[0148] In an embodiment of the present application, after a plurality of test cases are generated, in order to allow a user to more conveniently and intuitively select a test case to be executed as required, the plurality of test cases may be displayed in a user interface.

[0149] It should be noted that when displaying test cases, the requirement keywords corresponding to each test case can also be displayed in the area associated with the test case to show the user the generation source of each test case, facilitate users to evaluate and select different test cases, and optimize the user experience.

[0150] Step 507: upon receiving a selection operation for any test case, the test requirement keyword and any test case are associated and stored in a reference database.

[0151] In the embodiment of the present application, when the user clicks on any test case in the display interface, or clicks on a selection confirmation control related to any test case, etc., the test case generation system can receive the selection operation for any test case. Then, the test requirement keywords used to generate the test case and the test case association can be stored in the reference database to store the user's test case selection record, thereby providing a data basis for the subsequent update of the transfer matrix, so that the generated test case better meets the needs of the user.

[0152] Step 508: When the update condition is met, the first transfer matrix and the second transfer matrix are updated based on the data in the reference database.

[0153] Among them, the update condition may be that the current demand keyword library does not contain the currently acquired test demand keyword, or the amount of data in the reference database reaches a preset data amount threshold, which is not limited in this application.

[0154] It should be noted that when the acquired test requirement keyword is not included in the current requirement keyword library, the test requirement keyword cannot determine its corresponding transition probability and use case keyword in the first transfer matrix, and thus cannot generate the corresponding test case. Therefore, it is necessary to update the requirement keyword library and the first transfer matrix. In this application, requirement keywords that are similar to and semantically close to the test requirement keywords can be determined in the reference database, and their corresponding test cases and the newly acquired test requirement keywords are used as a set of data to update the first transfer matrix.

[0155] In an embodiment of the present application, when the update conditions are met, the first transition probability between the requirement keywords and the use case keywords in the test case can be adjusted based on the correspondence between the requirement keywords and the test cases in the reference database, and the second transition probability between the use case keywords can be adjusted based on the various test cases in the reference database, thereby completing the update of the first transfer matrix and the second transfer matrix.

[0156] In this embodiment, by using the test case finally selected by the user and the associated requirement keywords to reversely update the transition probability matrix, the reliability of the transition probability matrix can be further improved, providing conditions for making the generated test case more in line with user requirements.

[0157] This embodiment provides another method for generating a test case. Figure 6 A flowchart of another test case generation method provided in an embodiment of the present application.

[0158] like Figure 6 As shown, the test case generation method may include the following steps:

[0159] Step 601, obtaining test requirement keywords and domain tags associated with the test requirement keywords.

[0160] Step 602: Determine a first use case keyword corresponding to the test requirement keyword based on the first transfer matrix.

[0161] Step 603: Determine a first confidence level of a first use case keyword based on a language model associated with the domain tag.

[0162] For detailed description of the above steps 601 to 603, please refer to the above embodiments of the present disclosure, which will not be repeated here.

[0163] Step 604: When the first confidence level is less than the first threshold, determine a new first use case keyword corresponding to the requirement keyword based on the first transfer matrix.

[0164] Among them, the transition probability corresponding to the new first use case keyword is smaller than the transition probability corresponding to the original first use case keyword.

[0165] In the embodiment of the present application, when the first confidence of the first use case keyword is less than the first threshold, it can be determined that the availability of the first use case keyword in the target field corresponding to the field label is not high, and continuing to generate test cases based on the first use case keyword is likely to exceed the test scope of the target field. Therefore, the first use case keyword needs to be replaced, and the use case keyword with the largest corresponding transfer probability other than the first use case keyword can be determined as the new first use case keyword according to the first transfer matrix.

[0166] Step 605 : Determine a second confidence level of a new first use case keyword based on a language model associated with the domain tag.

[0167] In the embodiment of the present application, the process of determining the second confidence of the new first use case keyword is similar to the process of determining the first confidence of the first use case keyword in the above embodiment. Therefore, the detailed description of step 605 can refer to the above embodiment of the present application and will not be repeated here.

[0168] Step 606, when the second confidence level is greater than or equal to the first threshold, based on the new first use case keyword and the second transfer matrix, return to perform the operation of determining the next use case keyword until a test case corresponding to the test requirement keyword is obtained.

[0169] In the embodiment of the present application, the process of generating a test case based on a new first use case keyword is the same as the process of generating a test case based on the first use case keyword in the above embodiment. Therefore, the detailed description of step 606 can refer to the above embodiment of the present application and will not be repeated here.

[0170] It should be noted that when the second confidence of the new first use case keyword is still less than the first threshold, a use case keyword with a smaller transition probability can be determined based on the first transition matrix to replace the new first use case keyword.

[0171] In this embodiment, when the use case keyword with the maximum transfer probability does not meet the requirements of professional domain knowledge, the use case keyword with a lower corresponding transfer probability is obtained for replacement, and the corresponding confidence is determined until the use case keyword that meets the knowledge of the domain is obtained. This ensures that the generated use case meets the scope of the target domain and improves the reliability of the generated test case.

[0172] This embodiment provides another method for generating a test case. Figure 7 A flowchart of another test case generation method provided in an embodiment of the present application.

[0173] like Figure 7 As shown, the test case generation method may include the following steps:

[0174] Step 701: Receive a test case generation request.

[0175] The generation request includes the first requirement text and a domain label.

[0176] In an embodiment of the present application, when a user inputs a first requirement text and a target domain label in a test case generation system and clicks a control for instructing the system to generate a test case, the generation system may receive a test case generation request.

[0177] Step 702: parse the first requirement text to obtain at least one test requirement keyword.

[0178] In the embodiment of the present application, the first requirement text may be parsed using an existing language analysis model to extract at least one requirement keyword associated with the domain tag in the first requirement text.

[0179] Step 703: Determine at least one first use case keyword corresponding to the test requirement keyword based on the first transfer matrix.

[0180] Step 704: Determine a first confidence level of the first use case keyword based on a language model associated with the domain tag.

[0181] Step 705 , when the first confidence level is greater than or equal to the first threshold, determine the next use case keyword adjacent to the first use case keyword based on the first use case keyword and the second transfer matrix.

[0182] Step 706, based on the first use case keyword and the next use case keyword, return to perform the operation of determining the first confidence level until a test case corresponding to the test requirement keyword is obtained.

[0183] For detailed description of the above steps 703 to 706, please refer to the above embodiments of the present disclosure, which will not be repeated here.

[0184] Step 707 , determining a first weight corresponding to each test requirement keyword and a third confidence level of the test case corresponding to the test requirement keyword.

[0185] It should be noted that, since different demand keywords may have different corresponding importance in the target domain corresponding to the domain label, when the language analysis model is used to parse the first demand text, not only at least one test demand keyword can be extracted, but also the importance of each test demand keyword in the target domain (i.e., the first weight) can be obtained. Alternatively, the first weight can also be determined based on the frequency of occurrence and part of speech of each demand keyword in the first demand text, which is not limited in this application.

[0186] Optionally, the first weight corresponding to each test requirement keyword may be determined according to the part of speech of the test requirement keyword, the frequency of occurrence in the first requirement text, and / or the word frequency-inverse document frequency of the test requirement keyword.

[0187] Among them, Term Frequency-Inverse Document Frequency (TF-IDF) can be used to evaluate the importance of demand keywords to demand texts. It consists of two parts: one is the frequency of occurrence of test demand keywords in the first demand text, and the other is the distribution of test demand keywords in historical demand texts. When the test demand keywords appear more frequently in the currently acquired demand text and appear more widely in other demand texts, it means that the importance of the demand text is greater.

[0188] It should be noted that since different parts of speech have different grammatical and semantic functions in language expression, test requirement keywords of specific parts of speech may tend to be more important when they appear in specific fields. Therefore, the first weight corresponding to the test requirement keyword can be determined based on the part of speech of each requirement keyword.

[0189] In an embodiment of the present application, the part of speech of the test requirement keyword, the frequency of occurrence in the first requirement text, and / or at least one of the word frequency-inverse document frequency of the test requirement keyword can be selected to determine the first weight corresponding to the test requirement keyword.

[0190] Then, the third confidence of the test case may be determined according to the confidence and / or transition probability of each use case keyword in the test case.

[0191] In an embodiment of the present application, the third confidence of the test case can be calculated based on the first confidence corresponding to all the use case keywords that construct the test case. For example, the third confidence can be the average of all the first confidences, or it can be the value obtained by weighted summing all the first confidences, etc. Alternatively, the third confidence of the test case can also be calculated based on the transition probabilities corresponding to all the use case keywords that construct the test case. Alternatively, the value based on the weighted sum of all the first confidences and the value based on the weighted sum of all the transition probabilities can also be averaged to obtain the third confidence of the test case, etc., and the present application does not limit this.

[0192] In the embodiment of the present application, the weight of the test requirement keywords and the confidence of the test case are determined through multi-dimensional information, thereby further ensuring the reliability and accuracy of the test case.

[0193] Step 708: Determine the display order of each test case based on the first weight and the third confidence level corresponding to each test case.

[0194] In an embodiment of the present application, the first weight and the third confidence corresponding to each test case can be multiplied, and then the multiplied values ​​can be sorted from large to small, so that the display order corresponding to each test case can be determined.

[0195] Step 709: display multiple test cases in sequence based on the display order.

[0196] In the embodiment of the present application, by sorting and displaying multiple test cases based on their corresponding confidence levels and the weights of the associated requirement keywords, the efficiency of the user in selecting the test cases for target execution is improved, saving the user's time.

[0197] It should be noted that after determining multiple test cases, the test cases previously selected and executed by the user may be referred to to further screen the test cases so that the test cases finally generated better meet the needs of the user.

[0198] Optionally, a first similarity between the first requirement text and a second requirement text in a reference database may be determined first.

[0199] It should be noted that, in addition to the requirement keywords corresponding to the test cases, the reference database may also include a second requirement text from which the requirement keywords are extracted.

[0200] In an embodiment of the present application, the first similarity can be obtained by calculating the cosine similarity between the word vector of the first requirement text and the word vector of the second requirement text. Alternatively, the first similarity can be obtained using a pre-trained text similarity model. Alternatively, the first similarity between the first requirement text and the second requirement text in the reference database can be calculated by other means. This application does not limit this.

[0201] Then, when the first similarity between any second requirement text and the first requirement text is greater than or equal to the second threshold, a reference test case corresponding to any second requirement text in the reference database may be determined.

[0202] The second threshold value may be self-defined according to actual application requirements, etc., and this application does not impose any limitation on this.

[0203] In an embodiment of the present application, when the first similarity between any second requirement text and the first requirement text is greater than or equal to a second threshold, it can be determined that any second requirement text is related to the requirement of the current test case to be generated, and the reference test case corresponding to any second requirement text in the reference database can be used as the true value for accuracy verification of the test case.

[0204] Then, a second similarity value between the test case and the reference test case is determined.

[0205] In an embodiment of the present application, the second similarity can be obtained by determining the number of identical use case keywords in the test case and the reference test case, as well as the semantic similarity between the test case and the reference test case.

[0206] Afterwards, when the second similarity is greater than or equal to the third threshold, the test case may be determined to be a candidate test case for the first requirement text.

[0207] The third threshold may be self-defined according to the reliability requirements of the test case in actual applications, and this application does not impose any limitation on this.

[0208] In the embodiment of the present disclosure, when the second similarity is greater than or equal to the third threshold, it can be determined that the test cases corresponding to the second similarity are more likely to meet the user's needs and have higher usability. These test cases can then be determined as candidate test cases for the first requirement text and displayed to the user.

[0209] For example, after generating 15 test cases based on the requirement keywords in the first requirement text, you can first determine the second requirement text similar to the first requirement text in the reference database, and then calculate the second similarities between the reference test cases corresponding to the second requirement text and the 15 test cases. If only the second similarities corresponding to 10 test cases are greater than or equal to the third threshold, these 10 test cases are determined as candidate cases of the first requirement text and displayed.

[0210] In the embodiment of the present application, the accuracy of the test cases generated based on the demand keywords is verified by taking the demand text in the reference database, that is, the test cases, as the "true value", thereby further improving the accuracy and reliability of the test cases fed back to the user.

[0211] In order to implement the above embodiment, the present application also proposes a test case generation device.

[0212] Figure 8 A schematic diagram of the structure of a test case generation device provided in an embodiment of the present application.

[0213] like Figure 8 As shown, the test case generation device 800 includes:

[0214] The first acquisition module 801 is used to acquire at least one test requirement keyword;

[0215] A first determination module 802 is used to determine a first use case keyword for each test requirement keyword based on a pre-established first transfer matrix;

[0216] A second determination module 803 is used to determine, for a first use case keyword of a test requirement keyword, a second use case keyword sequence that appears after the first use case keyword based on a pre-established second transfer matrix, wherein the second use case keyword sequence includes at least one second use case keyword;

[0217] The first generating module 804 is configured to generate a test case corresponding to the test requirement keyword based on the first use case keyword and the second use case keyword included in the second use case keyword sequence.

[0218] Optionally, the first transfer matrix is ​​pre-constructed based on the test requirement keywords and the use case keywords, and the first transfer matrix records the probability of the test requirement keywords being transformed into the use case keywords;

[0219] The second transfer matrix is ​​pre-constructed based on the use case keywords, and the second transfer matrix records the probability of another use case keyword appearing directly after a use case keyword.

[0220] Optionally, the second determining module 803 may be specifically configured to:

[0221] Based on the second transfer matrix, determining a first second use case keyword that appears after a first use case keyword of a test requirement keyword;

[0222] Based on the second transfer matrix, determine the i+1th second use case keyword that appears after the i-th second use case keyword, where i is a natural number. If i+1 is not equal to a preset threshold value, and the i+1th second use case keyword is not an end keyword, then i=i+1, and return to the step of determining the i+1th second use case keyword that appears after the i-th second use case keyword. If i+1 is equal to a preset threshold value, or the i+1th second use case keyword is an end keyword, then all determined second use case keywords constitute a second use case keyword sequence.

[0223] Optionally, the device further includes a second generating module, which is used to generate a first transfer matrix, and can be specifically used to:

[0224] Obtain a demand keyword library, which includes: test demand keywords obtained based on historical test requirement documents;

[0225] Obtain a use case keyword library, which includes: use case keywords obtained based on historical test cases;

[0226] For each test requirement keyword in the requirement keyword library, calculate the first transition probability of the test requirement keyword transferring to each use case keyword in the use case keyword library, wherein the first transition probability of transferring to a use case keyword is calculated based on the ratio of the first number to the second number; the first number is: the number of times the use case keyword and the test requirement keyword appear at the same time in historical test requirement documents and historical test cases; the second number is: the number of times the test requirement keyword appears in historical test requirement documents and historical test cases;

[0227] Based on the calculated first transition probabilities, a first transition matrix is ​​generated.

[0228] Optionally, the apparatus further includes a third generating module, configured to generate a second transfer matrix, which may be specifically configured to:

[0229] Obtain a use case keyword library, which includes: use case keywords obtained based on historical test cases;

[0230] For any use case keyword in the use case keyword library, calculate the second transition probability of the use case keyword to other use case keywords, wherein the second transition probability of the use case keyword to the next use case keyword is calculated based on the ratio of the third number to the fourth number; the third number is: the number of times the next use case keyword appears in the next state of the use case keyword; the fourth number is: the number of times the use case keyword appears in historical test cases;

[0231] A second transfer matrix is ​​generated based on the calculated second transfer probabilities.

[0232] Optionally, the first determining module 802 may be specifically configured to:

[0233] Determine the maximum transition probability corresponding to the test requirement keyword in the first transition matrix;

[0234] Determine the use case keyword corresponding to the maximum transfer probability as the first use case keyword of the test requirement keyword;

[0235] The second determining module 803 may be specifically used for:

[0236] Determine the maximum transition probability corresponding to the first use case keyword in the second transition matrix;

[0237] The use case keyword corresponding to the maximum transition probability is determined as the first second use case keyword in the second use case keyword sequence that appears after the first use case keyword.

[0238] Optionally, the first acquisition module 801 may be specifically used for:

[0239] Obtain the test requirement document of the software to be tested;

[0240] Segment the content in the test requirement document to obtain at least one test requirement keyword.

[0241] In this embodiment, at least one test requirement keyword is first obtained, and then the first use case keyword of each test requirement keyword is determined based on a pre-established first transfer matrix. Afterwards, for the first use case keyword of each test requirement keyword, a second use case keyword sequence that appears after the first use case keyword is determined using a pre-established second transfer matrix, thereby generating a test case corresponding to the test requirement keyword based on at least one second use case keyword included in the first use case keyword and the second use case keyword sequence. In this way, batch rapid generation of test cases can be achieved without manual writing, thereby improving the generation efficiency of test cases and reducing resource investment.

[0242] In order to implement the above embodiments, the present application also proposes a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the test case generation method provided in the above embodiments.

[0243] In order to implement the above embodiments, the present application also proposes a computer program product, including a computer program, which, when executed by a processor, implements the test case generation method provided by the above embodiments.

[0244] The collection, storage, use, processing, transmission, provision and disclosure of user personal information involved in this application are in compliance with relevant laws and regulations and do not violate public order and good morals.

[0245] It should be noted that personal information from users should be collected for legitimate and reasonable purposes and should not be shared or sold outside of these legitimate uses. In addition, such collection / sharing should be carried out after receiving the user's informed consent, including but not limited to notifying the user to read the user agreement / user notice and sign the agreement / authorization including authorization of relevant user information before the user uses the function. In addition, any necessary steps should be taken to protect and safeguard access to such personal information data and ensure that others who have access to personal information data comply with its privacy policy and procedures.

[0246] The present application is expected to provide an implementation scheme for users to selectively block the use or access of personal information data. That is, the present disclosure is expected to provide hardware and / or software to prevent or block access to such personal information data. Once the personal information data is no longer needed, the risk can be minimized by limiting data collection and deleting the data. In addition, when applicable, such personal information is de-identified to protect the privacy of the user.

[0247] In the description of the aforementioned embodiments, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.

[0248] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0249] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or more executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.

[0250] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute the instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purpose of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.

[0251] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0252] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.

[0253] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.

[0254] The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present application. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present application.

Claims

1. A method for generating a test case, characterized in that: include: Get at least one test requirement keyword; Determine a first use case keyword for each test requirement keyword based on a pre-established first transfer matrix; For a first use case keyword of a test requirement keyword, based on a pre-established second transfer matrix, determining a second use case keyword sequence that appears after the first use case keyword, wherein the second use case keyword sequence includes at least one second use case keyword; A test case corresponding to the test requirement keyword is generated based on the first use case keyword and the second use case keyword included in the second use case keyword sequence.

2. The method according to claim 1, characterized in that The first transfer matrix is ​​pre-constructed based on the test requirement keywords and the use case keywords, and the first transfer matrix records the probability of the test requirement keywords being transformed into the use case keywords; The second transfer matrix is ​​pre-constructed based on the use case keywords, and the second transfer matrix records the probability of another use case keyword appearing directly after a use case keyword.

3. The method according to claim 1 or 2, characterized in that: The determining of a second use case keyword sequence that appears after the first use case keyword for a test requirement keyword based on a pre-established second transfer matrix includes: Based on the second transfer matrix, determining a first second use case keyword that appears after a first use case keyword of a test requirement keyword; Based on the second transfer matrix, determine the i+1th second use case keyword that appears after the i-th second use case keyword, where i is a natural number. If the i+1 is not equal to a preset threshold value, and the i+1th second use case keyword is not an end keyword, then i=i+1, and return to the step of determining the i+1th second use case keyword that appears after the i-th second use case keyword. If the i+1 is equal to the preset threshold value, or the i+1th second use case keyword is an end keyword, then all determined second use case keywords constitute the second use case keyword sequence.

4. The method according to claim 1, characterized in that: The method further comprises generating the first transfer matrix; The generating the first transfer matrix comprises: Acquire a demand keyword library, wherein the demand keyword library includes: test demand keywords acquired based on historical test demand documents; Acquire a use case keyword library, wherein the use case keyword library includes: use case keywords acquired based on historical test cases; For each test requirement keyword in the requirement keyword library, calculate the first transition probability of the test requirement keyword transferring to each use case keyword in the use case keyword library, wherein the first transition probability of transferring to a use case keyword is calculated based on the ratio of the first number to the second number; the first number is: the number of times the use case keyword and the test requirement keyword appear at the same time in the historical test requirement document and the historical test case; the second number is: the number of times the test requirement keyword appears in the historical test requirement document and the historical test case; The first transfer matrix is ​​generated based on the calculated first transfer probability.

5. The method according to claim 1, characterized in that The method further comprises generating the second transfer matrix; The generating the second transfer matrix comprises: Acquire a use case keyword library, wherein the use case keyword library includes: use case keywords acquired based on historical test cases; For any use case keyword in the use case keyword library, calculate the second transition probability of the use case keyword to other use case keywords, wherein the second transition probability of the use case keyword to the next use case keyword is calculated based on the ratio of the third number to the fourth number; the third number is: the number of times the next use case keyword appears in the next state of the use case keyword; the fourth number is: the number of times the use case keyword appears in the historical test cases; The second transfer matrix is ​​generated based on the calculated second transfer probability.

6. The method according to claim 1, characterized in that The step of determining the first use case keyword for each test requirement keyword based on the pre-established first transfer matrix includes: Determine the maximum transition probability corresponding to the test requirement keyword in the first transition matrix; Determine the use case keyword corresponding to the maximum transfer probability as the first use case keyword of the test requirement keyword; The determining, based on a pre-established second transfer matrix, a second use case keyword sequence that appears after the first use case keyword comprises: Determine a maximum transition probability corresponding to the first use case keyword in a second transition matrix; The use case keyword corresponding to the maximum transition probability is determined as the first second use case keyword in the second use case keyword sequence that appears after the first use case keyword.

7. The method according to any one of claims 1 to 6, characterized in that The obtaining of at least one test requirement keyword includes: Obtain the test requirement document of the software to be tested; Segment the content in the test requirement document to obtain at least one test requirement keyword.

8. A test case generation device, characterized in that: include: A first acquisition module, used to acquire at least one test requirement keyword; A first determination module, configured to determine a first use case keyword for each test requirement keyword based on a pre-established first transfer matrix; A second determination module is configured to determine, for a first use case keyword of a test requirement keyword, a second use case keyword sequence that appears after the first use case keyword based on a pre-established second transfer matrix, wherein the second use case keyword sequence includes at least one second use case keyword; The first generating module is used to generate a test case corresponding to the test requirement keyword based on the first use case keyword and the second use case keyword included in the second use case keyword sequence.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are executed by a processor, they are used to implement the test case generation method according to any one of claims 1 to 7.

10. A computer program product, characterized in that The invention comprises a computer program, which, when executed by a processor, implements the method for generating a test case according to any one of claims 1 to 7.