CN116483696A - Test case generation method, device, computer equipment and storage medium - Google Patents

Test case generation method, device, computer equipment and storage medium Download PDF

Info

Publication number
CN116483696A
CN116483696A CN202310318877.4A CN202310318877A CN116483696A CN 116483696 A CN116483696 A CN 116483696A CN 202310318877 A CN202310318877 A CN 202310318877A CN 116483696 A CN116483696 A CN 116483696A
Authority
CN
China
Prior art keywords
test
test case
sentence
black box
case
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310318877.4A
Other languages
Chinese (zh)
Inventor
刘雨瑶
梁琦
杨光前
李翔宇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202310318877.4A priority Critical patent/CN116483696A/en
Publication of CN116483696A publication Critical patent/CN116483696A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3676Test management for coverage analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application relates to a test case generation method, a test case generation device, computer equipment and a storage medium. The method comprises the following steps: acquiring a test requirement document and a natural language test statement set corresponding to a target black box test task; under the condition that the natural language test statement set is not an empty set, analyzing the natural language test statement set according to the test document architecture information, the test statement specification information and the test grammar specification information to obtain a natural statement component set; correspondingly inputting each test case element corresponding to the target black box test task and each sentence component element of the natural sentence component set into a test case construction algorithm to obtain a test case set to be detected; and under the condition that the detection results of the test case set corresponding to the test case set to be detected meet the detection conditions of all functions, taking the test case set to be detected as a black box test task case set. The method can reduce resource waste and improve the generation efficiency of the black box test case.

Description

Test case generation method, device, computer equipment and storage medium
Technical Field
The present invention relates to the field of computer technology, and in particular, to a test case generating method, apparatus, computer device, storage medium, and computer program product.
Background
With the development of computer technology, a black box test technology appears, and the black box test is to design test cases according to software requirement documents, modification points and test points, execute programs according to the test cases after evaluation, and obtain verification results. The test cases are designed by manually analyzing according to new requirements or modification points in the requirement document, and then adopting black box test methods such as equivalence class, scene method and the like to draw up the test cases, and enabling the drawn up test cases to cover all new added functions as much as possible.
In the traditional technology, the method for generating the black box test case adopts a method for manually determining the test case, a large number of repeated steps exist in the process of manually determining the test case, and the method, the process and the result of the test case are often basically consistent for the modification of the same service. Therefore, the adoption of the artificial test case to be determined often causes that under the condition that the scene coverage is not comprehensive enough, the scene needs to be corrected and supplemented in a test case review mode and the like, so that larger human resource waste is caused, and the generation efficiency of the black box test case is low.
Disclosure of Invention
In view of the foregoing, it is desirable to provide a test case generating method, apparatus, computer device, computer-readable storage medium, and computer program product that can reduce resource waste and improve the generation efficiency of a black box test case.
In a first aspect, the present application provides a test case generation method. The method comprises the following steps: acquiring a test requirement document and a natural language test statement set corresponding to a target black box test task; the test requirement document comprises test document architecture information, test statement specification information and test grammar specification information; under the condition that the natural language test statement set is not an empty set, analyzing the natural language test statement set according to the test document architecture information, the test statement specification information and the test grammar specification information to obtain a natural statement component set corresponding to the target black box test task; correspondingly inputting each test case element of the test case element set corresponding to the target black box test task and each sentence component element of the natural sentence component set into a test case construction algorithm to obtain a test case set to be detected corresponding to the target black box test task; each test case element has a mapping relation with sentence component elements in the natural sentence component set; and under the condition that the detection results of the test case set corresponding to the to-be-detected test case set meet the detection conditions of all functions, taking the to-be-detected test case set as a black box test task case set corresponding to the target black box test task.
In a second aspect, the present application further provides a test case generating device. The device comprises: the data acquisition module is used for acquiring a test requirement document and a natural language test statement set corresponding to the target black box test task; the test requirement document comprises test document architecture information, test statement specification information and test grammar specification information; the data analysis module is used for analyzing the natural language test statement set according to the test document architecture information, the test statement specification information and the test grammar specification information under the condition that the natural language test statement set is not an empty set, so as to obtain a natural statement component set corresponding to the target black box test task; the test case generation module is used for correspondingly inputting each test case element of the test case element set corresponding to the target black box test task and each sentence component element of the natural sentence component set into a test case construction algorithm to obtain a to-be-detected test case set corresponding to the target black box test task; each test case element has a mapping relation with sentence component elements in the natural sentence component set; the target case obtaining module is used for taking the to-be-detected test case set as a black box test task case set corresponding to the target black box test task under the condition that the test case set detection results corresponding to the to-be-detected test case set all meet the detection conditions of all functions.
In a third aspect, the present application also provides a computer device. The computer device comprises a memory storing a computer program and a processor which when executing the computer program performs the steps of: acquiring a test requirement document and a natural language test statement set corresponding to a target black box test task; the test requirement document comprises test document architecture information, test statement specification information and test grammar specification information; under the condition that the natural language test statement set is not an empty set, analyzing the natural language test statement set according to the test document architecture information, the test statement specification information and the test grammar specification information to obtain a natural statement component set corresponding to the target black box test task; correspondingly inputting each test case element of the test case element set corresponding to the target black box test task and each sentence component element of the natural sentence component set into a test case construction algorithm to obtain a test case set to be detected corresponding to the target black box test task; each test case element has a mapping relation with sentence component elements in the natural sentence component set; and under the condition that the detection results of the test case set corresponding to the to-be-detected test case set meet the detection conditions of all functions, taking the to-be-detected test case set as a black box test task case set corresponding to the target black box test task.
In a fourth aspect, the present application also provides a computer-readable storage medium. The computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of: acquiring a test requirement document and a natural language test statement set corresponding to a target black box test task; the test requirement document comprises test document architecture information, test statement specification information and test grammar specification information; under the condition that the natural language test statement set is not an empty set, analyzing the natural language test statement set according to the test document architecture information, the test statement specification information and the test grammar specification information to obtain a natural statement component set corresponding to the target black box test task; correspondingly inputting each test case element of the test case element set corresponding to the target black box test task and each sentence component element of the natural sentence component set into a test case construction algorithm to obtain a test case set to be detected corresponding to the target black box test task; each test case element has a mapping relation with sentence component elements in the natural sentence component set; and under the condition that the detection results of the test case set corresponding to the to-be-detected test case set meet the detection conditions of all functions, taking the to-be-detected test case set as a black box test task case set corresponding to the target black box test task.
In a fifth aspect, the present application also provides a computer program product. The computer program product comprises a computer program which, when executed by a processor, implements the steps of: acquiring a test requirement document and a natural language test statement set corresponding to a target black box test task; the test requirement document comprises test document architecture information, test statement specification information and test grammar specification information; under the condition that the natural language test statement set is not an empty set, analyzing the natural language test statement set according to the test document architecture information, the test statement specification information and the test grammar specification information to obtain a natural statement component set corresponding to the target black box test task; correspondingly inputting each test case element of the test case element set corresponding to the target black box test task and each sentence component element of the natural sentence component set into a test case construction algorithm to obtain a test case set to be detected corresponding to the target black box test task; each test case element has a mapping relation with sentence component elements in the natural sentence component set; and under the condition that the detection results of the test case set corresponding to the to-be-detected test case set meet the detection conditions of all functions, taking the to-be-detected test case set as a black box test task case set corresponding to the target black box test task.
According to the test case generation method, the device, the computer equipment, the storage medium and the computer program product, the test requirement document and the natural language test statement set corresponding to the target black box test task are obtained; the test requirement document comprises test document architecture information, test statement specification information and test grammar specification information; under the condition that the natural language test statement set is not an empty set, analyzing the natural language test statement set according to the test document architecture information, the test statement specification information and the test grammar specification information to obtain a natural statement component set corresponding to the target black box test task; inputting each test case element of the test case element set and each sentence element of the natural sentence element set corresponding to the target black box test task into a test case construction algorithm correspondingly to obtain a test case set to be detected corresponding to the target black box test task; each test case element has a mapping relation with sentence component elements in the natural sentence component set; and under the condition that the detection results of the test case set corresponding to the test case set to be detected meet the detection conditions of all functions, taking the test case set to be detected as a black box test task case set corresponding to the target black box test task.
By using a natural language processing method, a document writer is analyzed to write an organization comprising a document architecture according to a specification, and test requirement documents of the specification of sentence grammar are obtained, so that the application range, modification points, modified effects and the like of requirements are obtained, and information such as effective equivalence classes, ineffective equivalence classes, input conditions, boundary values and the like is analyzed from the requirement documents, so that a natural sentence component set is obtained. And respectively and automatically generating test cases according to methods such as an equivalence class method, a boundary value method and a causal graph method, taking a collection of the test cases to perform function detection, and generating a final black box test task case collection. The test case can be generated according to the analysis result, so that the problem caused by logic errors or pen errors is reduced, the test case is automatically generated, the workload of manual testing is reduced, time and manpower resources are saved, and the generation efficiency of the black box test case is improved.
Drawings
FIG. 1 is an application environment diagram of a test case generation method in one embodiment;
FIG. 2 is a flow chart of a method for generating test cases according to one embodiment;
FIG. 3 is a flowchart of a method for obtaining a set of test cases to be detected in one embodiment;
FIG. 4 is a flowchart of a method for obtaining a set of test cases to be detected in another embodiment;
FIG. 5 is a flowchart of a method for obtaining a test case set detection result in one embodiment;
FIG. 6 is a flow chart of a method for obtaining a modified range test result in one embodiment;
FIG. 7 is a flow chart of a method for obtaining a natural language sentence component set in one embodiment;
FIG. 8 is a flow diagram of a method of test case element determination in one embodiment;
FIG. 9 is a flowchart of a mapping relationship determination method in one embodiment;
FIG. 10 is a schematic diagram illustrating logic for implementing a test case generation method in one embodiment;
FIG. 11 is a logic diagram of an implementation of an equivalence class computation method in one embodiment;
FIG. 12 is a logic diagram of an implementation of a boundary value calculation method in one embodiment;
FIG. 13 is a block diagram of a test case generating device in one embodiment;
fig. 14 is an internal structural diagram of a computer device in one embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application will be further described in detail with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the present application.
The test case generation method provided by the embodiment of the application can be applied to an application environment shown in fig. 1. Wherein the terminal 102 communicates with the server 104 via a network. The data storage system may store data that the server 104 needs to process. The data storage system may be integrated on the server 104 or may be located on a cloud or other network server. The server 104 acquires a test requirement document corresponding to the target black box test task and a natural language test statement set from the terminal 102; the test requirement document comprises test document architecture information, test statement specification information and test grammar specification information; under the condition that the natural language test statement set is not an empty set, analyzing the natural language test statement set according to the test document architecture information, the test statement specification information and the test grammar specification information to obtain a natural statement component set corresponding to the target black box test task; inputting each test case element of the test case element set and each sentence element of the natural sentence element set corresponding to the target black box test task into a test case construction algorithm correspondingly to obtain a test case set to be detected corresponding to the target black box test task; each test case element has a mapping relation with sentence component elements in the natural sentence component set; and under the condition that the detection results of the test case set corresponding to the test case set to be detected meet the detection conditions of all functions, taking the test case set to be detected as a black box test task case set corresponding to the target black box test task. The terminal 102 may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, internet of things devices, and portable wearable devices, where the internet of things devices may be smart speakers, smart televisions, smart air conditioners, smart vehicle devices, and the like. The portable wearable device may be a smart watch, smart bracelet, headset, or the like. The server 104 may be implemented as a stand-alone server or as a server cluster of multiple servers.
In one embodiment, as shown in fig. 2, a test case generating method is provided, and the method is applied to the server in fig. 1 for illustration, and includes the following steps:
step 202, obtaining a test requirement document and a natural language test statement set corresponding to a target black box test task.
The target black box test task can be a black box which can not be opened by considering the program, and can be tested at a program interface without considering the internal structure and internal characteristics of the program, and only check whether the program function is normally used according to the specification of the requirement specification, and whether the program can properly receive input data to generate correct output information. Black box testing focuses on the external architecture of the program, irrespective of the internal logic architecture.
The test requirement document may be an analysis rule corresponding to a natural language sentence to be analyzed.
Wherein the natural language test statement set may be a set of test statements that are composed using a language that naturally evolves with culture.
Specifically, the server responds to an instruction of the terminal, targets a test requirement document and a natural language test statement set corresponding to the black box test task at the terminal, and stores the acquired test requirement document and the natural language test statement set into a storage unit, wherein the test requirement document comprises test document architecture information, test statement specification information and test grammar specification information. When the server needs to process the test requirement of any test requirement document and the natural language test statement of the natural language test statement set, the test requirement and the natural language test statement set are called from the storage unit to the volatile storage resource for the CPU to calculate. The data record corresponding to any inherent information can be single data input to the central processing unit, or can be a plurality of data input to the central processing unit at the same time.
For example, the server 104 responds to the instruction of the terminal 102, acquires the test requirement document and the natural language test statement set corresponding to the target black box test task from the terminal 102, and stores the test requirement document and the natural language test statement set in the storage unit in the server 104, wherein 10 natural language test statements of any test requirement document and natural language test statement set acquired by the server 104 can be simultaneously input to the central processor for a plurality of data.
And 204, under the condition that the natural language test statement set is not an empty set, analyzing the natural language test statement set according to the test document architecture information, the test statement specification information and the test grammar specification information to obtain a natural statement component set corresponding to the target black box test task.
The test document architecture information may be an architecture organization component of the test document for parsing the natural language test statement.
The test sentence specification information may be a language specification of the test document regarding parsing of the natural language test sentence.
The test grammar specification information may be a grammar specification of a test document for parsing a natural language test sentence.
The natural sentence component set may be an analysis result obtained by analyzing the test requirement document of the natural language test sentence set.
Specifically, since the test requirement document is an execution document of the calculation and execution program, the test requirement document includes test document architecture information, test sentence specification information and test grammar specification information. Therefore, aiming at word segmentation processing of each natural language test sentence, inputting each natural language test sentence into a computer program, and executing a test requirement document, wherein the word segmentation processing is carried out on each natural language test sentence by using test document architecture information, test sentence specification information and test grammar specification information, so as to obtain a first natural sentence component set; similarly, inputting each natural language test sentence into a computer program for part-of-speech analysis of each natural language test sentence, and executing a test requirement document, wherein part-of-speech analysis is performed on each natural language test sentence by using test document architecture information, test sentence specification information and test grammar specification information to obtain a second natural sentence component set; and similarly, inputting each natural language test sentence into a computer program for grammar analysis of each natural language test sentence, and executing a test requirement document, wherein the grammar analysis is performed on each natural language test sentence by using test document architecture information, test sentence specification information and test grammar specification information to obtain a third natural sentence component set, and finally, integrating according to the first natural sentence component set, the second natural sentence component set and the third natural sentence component set and a preset integration rule to obtain a natural sentence component set. For example, a test requirements document typically contains the following parts: summary, detailed design, risk point analysis, data sheet, etc., content related to test case development, i.e., the content of the detailed design section. Each summary specifying the editing of the detailed design by the modification points is ultimately a specification of the statement dimensions. When a developer or product manager describes a requirement, the business scope to which the requirement relates is first described. For example, the xx function is modified, newly added/modified/deleted on the xx application xx page, or modified on the xx application xx page, so as to optimize the sentence like the xx function.
After the natural sentence component set is obtained, the server responds to the instruction of the terminal again, the corresponding relation between each test case element in the test case element set corresponding to the target black box test task at the terminal and each sentence component element in the natural sentence component set is obtained, and the obtained corresponding relation between each test case element and each sentence component element is stored in the storage unit. When the server needs to process the corresponding relation between each test case element and each sentence component element, the corresponding relation is called from the storage unit to the volatile storage resource for the CPU to calculate. The data record corresponding to any inherent information can be single data input to the central processing unit, or can be a plurality of data input to the central processing unit at the same time.
According to the corresponding relation between each test case element and each sentence component element, correspondingly determining the mapping relation between each subject in the sentence component element and each tested function in the test case element; similarly, according to the corresponding relation between each test case element and each sentence component element, correspondingly determining the mapping relation between each main predicate verb in the sentence component element and each modification point in the test case element; similarly, according to the corresponding relation between each test case element and each sentence component element, correspondingly determining the mapping relation between each object in the sentence component element and each modification point in the test case element; similarly, according to the corresponding relation between each test case element and each sentence component element, the mapping relation of each stationary phrase in the sentence component element and each test case element limiting the tested function range is correspondingly determined. For example: the natural sentence component set grammar structure parses the following table:
Step 206, inputting each test case element of the test case element set corresponding to the target black box test task and each sentence element of the natural sentence element set into the test case construction algorithm correspondingly to obtain the test case set to be detected corresponding to the target black box test task.
The test case element may be an item that needs to be tested for each sentence component element of the natural sentence component set.
The test case construction algorithm may be an algorithm for constructing a test case from test case elements and sentence component elements.
The test case set to be detected can be a test case set obtained through a test case construction algorithm, but functional test is required to be performed so as to meet the requirements of black box test tasks.
Specifically, each test case element in the test case element set is matched with each preset test case construction algorithm, namely each test case element is pre-executed with each test case construction algorithm, execution condition information of each test case element and each test case construction algorithm is obtained, and a matching result of each test case element and each test case construction algorithm is determined according to the execution condition information.
According to the test case matching result, determining that the execution algorithm is an equivalence class test case construction algorithm, calling at least one corresponding test case element and sentence component element from the test case element set and the natural sentence component set, and inputting the at least one corresponding test case element and sentence component element into the equivalence class test case construction algorithm to perform test case combination to obtain an equivalence class test case set, for example, a requirement sentence: "Address entry for shopping applications, address entry column increases from a maximum of 30 bits to a maximum of 50 bits. The test set up according to this statement is, for example, as follows: according to the equivalence class test case construction algorithm, the equivalence classes are divided as follows: effective equivalence class: 0< address length <50, invalid equivalence class: address length < = 0 bits, address length > = 50 bits, according to the above equivalence class, manually formulated test is for example as follows: 1. inputting a 30-bit address, wherein the address can be successfully saved, 2, inputting an 80-bit address, and the address cannot be successfully saved, and 3, inputting the address, and the address cannot be successfully saved; similarly, according to the test case matching result, determining that the execution algorithm is a boundary value test case construction algorithm, calling at least one corresponding test case element and sentence element from the test case element set and the natural sentence element set, and inputting the at least one corresponding test case element and sentence element to the boundary value test case construction algorithm to perform test case combination to obtain the boundary value test case set, for example: according to the boundary value method, the boundary values are extracted as follows: 0 bit and 50 bit, according to the above boundary values, the test case is formulated as follows: 1. the input of 50-bit address can successfully save 2-bit address, input of 51-bit address, failure to successfully save 3-bit address, failure to successfully save 4-bit address, input of 1-bit address, and failure to successfully save; similarly, according to the test case matching result, determining that the execution algorithm is a causal graph test case construction algorithm, calling at least one corresponding test case element and statement element from the test case element set and the natural statement element set, and inputting the test case element and the statement element into the causal graph test case construction algorithm for test case combination to obtain a causal graph test case set; and finally integrating the equivalence class test case set, the boundary value test case set and the causal graph test case set according to a preset sequence to obtain a test case set to be detected, wherein the conditions for assembling the test cases are as follows: the measured function range + the measured function + the measured range is defined.
And step 208, taking the test case set to be detected as a black box test task case set corresponding to the target black box test task under the condition that the test case set detection results corresponding to the test case set to be detected meet the detection conditions of all functions.
The test case set detection result may be a result obtained after each test case to be detected in the test case set to be detected is tested.
The function detection condition may be a detection condition for determining whether the test result corresponding to each test case to be detected meets the service condition.
The set of black box test task cases may be a set of test cases to be detected that conform to the black box test task.
Specifically, full testing of range division related to new modification is respectively carried out on each equivalent class test case of the equivalent class test case set, each boundary value test case of the boundary value test case set and each causal graph test case of the causal graph test case set to obtain a range division test result; similarly, respectively performing full testing on the range boundaries related to new modification on each equivalent class test case of the equivalent class test case set, each boundary value test case of the boundary value test case set and each causal graph test case of the causal graph test case set to obtain a range boundary value test result; and integrating the range division test result and the range boundary value test result according to a preset combination rule to obtain a modified range test result. For example: adopting an equivalence class and boundary value method to draw up the following test cases: use case 1: the address input field 40 bit address of shopping application can be successfully saved. Use case 2: the address input field 80 bit address of shopping application can not be successfully saved. Use case 3: the address of shopping application is input, not input, and can not be successfully stored. Use case 4: the address input field 50-bit address of the shopping application can be successfully saved. Use case 5: the address entry of the shopping application, address entry field 51 bit address, cannot be successfully saved. Use case 6: the address entry of the shopping application, address entry field 41 bit address, cannot be successfully saved. Use case 7: the address of shopping application is input, not input, and can not be successfully stored. Use case 8: the address input of shopping application, 1-bit address of address input column, can be successfully saved.
If the modification range test result represents that each equivalent test case of the equivalent test case set, each boundary value test case of the boundary value test case set and each causal graph test case of the causal graph test case set are all under the condition of meeting the first test conditions based on the range division and the range boundary, further using a field Jing Fa to test the stock functions before modification on each equivalent test case of the equivalent test case set, each boundary value test case of the boundary value test case set and each causal graph test case of the causal graph test case set respectively, and obtaining the test result of the stock functions. If the modification range test result represents each equivalent test case of the equivalent test case set, each boundary value test case of the boundary value test case set and any one test case in each causal graph test case of the causal graph test case set does not meet the first test conditions based on the range division and the range boundary, the test requirement document and the natural language test statement set corresponding to the target black box test task are returned to be executed and acquired.
And if the result stock function test result represents that each equivalent class test case of the equivalent class test case set, each boundary value test case of the boundary value test case set and each causal graph test case of the causal graph test case set are all under the condition that the stock function before modification is satisfied as a second test condition, taking the result stock function test result as a test case set detection result. If the modification range test result represents each equivalent test case of the equivalent test case set, each boundary value test case of the boundary value test case set and any test case in each causal graph test case of the causal graph test case set does not meet the condition that the stock function before modification is a second test condition, returning to execute and acquire a test requirement document and a natural language test statement set corresponding to the target black box test task.
And if the test case set detection result corresponding to the test case set to be detected represents each equivalent test case of the equivalent test case set, each boundary value test case of the boundary value test case set and each causal graph test case of the causal graph test case set can pass the two function detection conditions, taking the test case set to be detected as a black box test task case set corresponding to the target black box test task. FIG. 10 is a logic diagram of an implementation of a test case generation method in one embodiment.
In the test case generation method, a test requirement document and a natural language test statement set corresponding to a target black box test task are obtained; the test requirement document comprises test document architecture information, test statement specification information and test grammar specification information; under the condition that the natural language test statement set is not an empty set, analyzing the natural language test statement set according to the test document architecture information, the test statement specification information and the test grammar specification information to obtain a natural statement component set corresponding to the target black box test task; inputting each test case element of the test case element set and each sentence element of the natural sentence element set corresponding to the target black box test task into a test case construction algorithm correspondingly to obtain a test case set to be detected corresponding to the target black box test task; each test case element has a mapping relation with sentence component elements in the natural sentence component set; and under the condition that the detection results of the test case set corresponding to the test case set to be detected meet the detection conditions of all functions, taking the test case set to be detected as a black box test task case set corresponding to the target black box test task.
By using a natural language processing method, a document writer is analyzed to write an organization comprising a document architecture according to a specification, and test requirement documents of the specification of sentence grammar are obtained, so that the application range, modification points, modified effects and the like of requirements are obtained, and information such as effective equivalence classes, ineffective equivalence classes, input conditions, boundary values and the like is analyzed from the requirement documents, so that a natural sentence component set is obtained. And respectively and automatically generating test cases according to methods such as an equivalence class method, a boundary value method and a causal graph method, taking a collection of the test cases to perform function detection, and generating a final black box test task case collection. The test case can be generated according to the analysis result, so that the problem caused by logic errors or pen errors is reduced, the test case is automatically generated, the workload of manual testing is reduced, time and manpower resources are saved, and the generation efficiency of the black box test case is improved.
In one embodiment, as shown in fig. 3, each test case element of the test case element set corresponding to the target black box test task and each sentence component element of the natural sentence component set are correspondingly input into a test case construction algorithm to obtain a test case set to be detected corresponding to the target black box test task, where the method includes:
Step 302, matching each test case element in the test case element set with each test case construction algorithm to obtain a test case matching result.
The test case matching result may be a matching degree obtained by matching each test case element with each test case construction algorithm.
Specifically, each test case element in the test case element set is matched with each preset test case construction algorithm, namely each test case element is pre-executed with each test case construction algorithm, execution condition information of each test case element and each test case construction algorithm is obtained, and a matching result of each test case element and each test case construction algorithm is determined according to the execution condition information.
And step 304, respectively calling corresponding test case elements and sentence component elements to perform test case combination according to the test case matching result and each test case construction algorithm, and obtaining a test case set to be detected corresponding to the test case element set.
Specifically, according to the test case matching result, determining that the execution algorithm is an equivalence class test case construction algorithm, calling at least one corresponding test case element and sentence element from the test case element set and the natural sentence element set, inputting the at least one corresponding test case element and sentence element to the equivalence class test case construction algorithm for test case combination to obtain an equivalence class test case set, and fig. 11 is a logic diagram of an implementation of an equivalence class calculation method in one embodiment; similarly, according to the test case matching result, determining that the execution algorithm is a boundary value test case construction algorithm, calling at least one corresponding test case element and sentence element from the test case element set and the natural sentence element set, inputting the at least one corresponding test case element and sentence element to the boundary value test case construction algorithm for test case combination to obtain a boundary value test case set, and fig. 12 is a logic diagram of implementation of the boundary value calculation method in one embodiment; similarly, according to the test case matching result, determining that the execution algorithm is a causal graph test case construction algorithm, calling at least one corresponding test case element and statement element from the test case element set and the natural statement element set, and inputting the test case element and the statement element into the causal graph test case construction algorithm for test case combination to obtain a causal graph test case set; and finally integrating the equivalence class test case set, the boundary value test case set and the causal graph test case set according to a preset sequence to obtain a test case set to be detected, wherein the conditions for assembling the test cases are as follows: the measured function range + the measured function + the measured range is defined.
In the embodiment, the test case combination is performed on the corresponding test case elements and the sentence component elements by adopting the matched test case construction algorithm, so that the test case combination can be performed by using the most suitable algorithm for different test case elements and the corresponding sentence component elements, thereby being beneficial to improving the generation quality of the test case and improving the accuracy rate of the black box test task.
In one embodiment, as shown in fig. 4, according to a test case matching result and each test case construction algorithm, respectively calling corresponding test case elements and sentence component elements to perform test case combination, so as to obtain a test case set to be detected corresponding to the test case element set, including:
and step 402, calling corresponding test case elements and statement component elements to perform test case combination according to the test case matching result and an equivalence class test case construction algorithm, and obtaining an equivalence class test case set.
The equivalence class test case construction algorithm is used for dividing all possible input data of the program into a plurality of equivalence classes. And then selecting representative data from each part as a test case. The test cases consist of representative data of valid equivalence classes and invalid equivalence classes, so that the integrity and representativeness of the test cases are ensured.
The equivalence class test case set may be a set of test cases after test case construction by using an equivalence class test case construction algorithm.
Specifically, according to the test case matching result, determining that the execution algorithm is an equivalence class test case construction algorithm, calling at least one corresponding test case element and sentence element from the test case element set and the natural sentence element set, and inputting the at least one corresponding test case element and sentence element to the equivalence class test case construction algorithm for test case combination to obtain the equivalence class test case set.
And step 404, calling corresponding test case elements and statement component elements to perform test case combination according to the test case matching result and the boundary value test case construction algorithm to obtain a boundary value test case set.
The boundary value test case construction algorithm may be a black box test method for testing input or output boundary values, where the test case is from an equivalent boundary.
The boundary value test case set may be a set of test cases after the test case is constructed by using a boundary value test case construction algorithm.
Specifically, according to the test case matching result, determining that the execution algorithm is a boundary value test case construction algorithm, calling at least one corresponding test case element and statement element from the test case element set and the natural statement element set, and inputting the at least one corresponding test case element and statement element to the boundary value test case construction algorithm for test case combination to obtain the boundary value test case set.
And step 406, calling corresponding test case elements and statement component elements to perform test case combination according to the test case matching result and the causal graph test case construction algorithm, and obtaining a causal graph test case set.
The causal graph test case construction algorithm can be an algorithm for designing a corresponding test case by representing various input combination relations and writing out a judgment table.
The causal graph test case set may be a set of test cases after test case construction by using a causal graph test case construction algorithm.
Specifically, according to the test case matching result, determining that the execution algorithm is a causal graph test case construction algorithm, calling at least one corresponding test case element and statement element from the test case element set and the natural statement element set, and inputting the test case elements and statement element into the causal graph test case construction algorithm to perform test case combination to obtain the causal graph test case set.
Step 408, integrating the equivalence class test case set, the boundary value test case set and the causal graph test case set to obtain a test case set to be detected.
Specifically, the class test case set, the boundary value test case set and the causal graph test case set are integrated according to a preset sequence, so that the test case set to be detected can be obtained, wherein the conditions for assembling the test cases are as follows: the measured function range + the measured function + the measured range is defined.
In the embodiment, the test case combination is performed on the corresponding test case elements and sentence component elements by using the equivalence class method, the boundary value method and the causal graph method, so that different types of test cases can be automatically generated according to different generation methods, the workload of manually designing the test cases is reduced, and the efficiency of generating the test cases is improved.
In one embodiment, as shown in fig. 5, before the step of taking the to-be-detected test case set as the black box test task case set corresponding to the target black box test task, if the test case set detection results corresponding to the to-be-detected test case set all meet the detection conditions of each function, the method further includes:
step 502, performing modification range test on the equivalence class test case set, the boundary value test case set and the causal graph test case set respectively to obtain a modification range test result.
The modification range test result may be a result obtained by fully testing the range division involved in performing new modification on each equivalence class test case of the equivalence class test case set.
Specifically, full testing of range division related to new modification is respectively carried out on each equivalent class test case of the equivalent class test case set, each boundary value test case of the boundary value test case set and each causal graph test case of the causal graph test case set to obtain a range division test result; similarly, respectively performing full testing on the range boundaries related to new modification on each equivalent class test case of the equivalent class test case set, each boundary value test case of the boundary value test case set and each causal graph test case of the causal graph test case set to obtain a range boundary value test result; and integrating the range division test result and the range boundary value test result according to a preset combination rule to obtain a modified range test result.
Step 504, under the condition that the modification range test result represents the equivalence class test case set, the boundary value test case set and the causal graph test case set and all satisfy the first test condition, respectively performing the stock function test on the equivalence class test case set, the boundary value test case set and the causal graph test case set to obtain a stock function test result.
The first test condition may be a condition for determining whether the range division and the range boundary of each test case can meet the service requirement.
The test result of the stock function may be a result obtained by testing the stock function before each test case is changed.
Specifically, if the modification range test result represents that each equivalent test case of the equivalent test case set, each boundary value test case of the boundary value test case set, and each causal graph test case of the causal graph test case set are all under the condition of meeting the first test conditions based on the range division and the range boundary, further using the field Jing Fa to test the stock functions before modification respectively for each equivalent test case of the equivalent test case set, each boundary value test case of the boundary value test case set, and each causal graph test case of the causal graph test case set, thereby obtaining the test result of the stock function.
And step 506, taking the stock function test result as a test case set detection result when the stock function test result represents that each to-be-detected test case meets the second test condition.
The second test condition may be a determination condition for determining whether each test case satisfies the stock function before modification.
Specifically, if the result stock function test result represents each equivalent class test case of the equivalent class test case set, each boundary value test case of the boundary value test case set and each causal graph test case of the causal graph test case set, under the condition that the second test condition of the stock function before modification is satisfied, the result stock function test result is used as a test case set detection result.
In the embodiment, the modification range and the stock function of the equivalence class test case set, the boundary value test case set and the causal graph test case set are tested, so that the tested range of the generated test case can be ensured to meet the test of the new modification function and the principle of not influencing the stock function, the correctness of the generated test case is ensured, and the probability of failure of the black box test is reduced.
In one embodiment, as shown in fig. 6, the modification range test is performed on the equivalence class test case set, the boundary value test case set, and the causal graph test case set, to obtain a modification range test result, including:
step 602, performing range division equivalence test on the equivalence class test case set, the boundary value test case set and the causal graph test case set respectively to obtain a range division test result.
The range division test result may be a result obtained by a full test of the range division involved in performing new modification on each test case.
Specifically, full testing of range division related to new modification is respectively carried out on each equivalence class test case of the equivalence class test case set, each boundary value test case of the boundary value test case set and each causal graph test case of the causal graph test case set, so as to obtain a range division test result.
Step 604, performing range boundary value test on the equivalence class test case set, the boundary value test case set and the causal graph test case set respectively to obtain a range boundary value test result.
The range boundary value test result may be a test result obtained by fully testing a range boundary involved in performing new modification on each test case.
Specifically, full testing of the range boundary related to new modification is respectively carried out on each equivalence class test case of the equivalence class test case set, each boundary value test case of the boundary value test case set and each causal graph test case of the causal graph test case set, so as to obtain a range boundary value test result.
Step 606, integrating the range division test result and the range boundary value test result to obtain a modified range test result.
Specifically, integrating the range division test result and the range boundary value test result according to a preset combination rule to obtain a modified range test result.
In this embodiment, by performing a range division equivalence test and a range boundary value test on the equivalence class test case set, the boundary value test case set, and the causal graph test case set, it can be determined that the newly generated test case meets the range division equivalence condition range boundary value within the tested range, so as to ensure that the generated test case is executed within the tested range, and reduce the failure possibility of executing the black box test task.
In one embodiment, as shown in fig. 7, according to the test document architecture information, the test sentence specification information and the test grammar specification information, the analysis is performed on the natural language test sentence set to obtain a natural sentence component set corresponding to the target black box test task, including:
Step 702, performing word segmentation processing on the natural language test sentence set according to the test document architecture information, the test sentence specification information and the test grammar specification information to obtain a first natural sentence component set.
The first natural sentence component set may be a word segmentation result obtained by segmenting each natural language test sentence in the natural language test sentence set.
Specifically, for word segmentation processing of each natural language test sentence, each natural language test sentence is input into a computer program, a test requirement document is executed, wherein the word segmentation processing is performed on each natural language test sentence by using test document architecture information, test sentence specification information and test grammar specification information, and a first natural sentence component set is obtained.
Step 704, performing part-of-speech analysis on the natural language test sentence set according to the test document architecture information, the test sentence specification information and the test grammar specification information to obtain a second natural sentence component set.
The second natural sentence component set may be an analysis result obtained by performing part-of-speech analysis on each natural language test sentence in the natural language test sentence set.
Specifically, for part-of-speech analysis of each natural language test sentence, each natural language test sentence is input into a computer program, a test requirement document is executed, and part-of-speech analysis is performed on each natural language test sentence by using test document architecture information, test sentence specification information and test grammar specification information, so as to obtain a second natural sentence component set.
Step 706, performing syntax analysis on the natural language test sentence set according to the test document architecture information, the test sentence specification information and the test grammar specification information to obtain a third natural sentence component set.
The third natural sentence component set may be an analysis result obtained by performing a grammar analysis on each natural language test sentence in the natural language test sentence set.
Specifically, for the grammar analysis of each natural language test sentence, each natural language test sentence is input into a computer program, a test requirement document is executed, wherein the grammar analysis is performed on each natural language test sentence by using test document architecture information, test sentence specification information and test grammar specification information, and a third natural sentence component set is obtained.
Step 708, integrating the first natural sentence component set, the second natural sentence component set and the third natural sentence component set to obtain a natural sentence component set.
And finally, integrating according to a preset integration rule and a preset integration rule to obtain a natural sentence component set.
In this embodiment, the natural language test sentence set is respectively subjected to word segmentation, part-of-speech analysis and grammar analysis according to the test document architecture information, the test sentence specification information and the test grammar specification information, so that sentence components such as a subject and a predicate verb in the natural language test sentence set can be extracted, and the accuracy of generating the test case by the computer is improved.
In one embodiment, as shown in fig. 8, after the step of integrating the first natural sentence component set, the second natural sentence component set, and the third natural sentence component set to obtain the natural sentence component set, the method further includes:
step 802, obtaining a preset mapping relation corresponding to a target black box test task.
The preset mapping relationship may be a correspondence relationship between each test case element in the test case element set and each sentence component element in the natural sentence component set.
Specifically, after the natural sentence component set is obtained, the server responds to the instruction of the terminal again, the corresponding relation between each test case element in the test case element set corresponding to the target black box test task at the terminal and each sentence component element in the natural sentence component set is obtained, and the obtained corresponding relation between each test case element and each sentence component element is stored in the storage unit. When the server needs to process the corresponding relation between each test case element and each sentence component element, the corresponding relation is called from the storage unit to the volatile storage resource for the CPU to calculate. The data record corresponding to any inherent information can be single data input to the central processing unit, or can be a plurality of data input to the central processing unit at the same time.
Step 804, determining the test case elements corresponding to the sentence component elements according to the sentence component elements of the natural sentence component set and the preset mapping relation.
Specifically, according to the corresponding relation between each test case element and each sentence component element, the mapping relation between each subject in the sentence component element and each tested function in the test case element is correspondingly determined; similarly, according to the corresponding relation between each test case element and each sentence component element, correspondingly determining the mapping relation between each main predicate verb in the sentence component element and each modification point in the test case element; similarly, according to the corresponding relation between each test case element and each sentence component element, correspondingly determining the mapping relation between each object in the sentence component element and each modification point in the test case element; similarly, according to the corresponding relation between each test case element and each sentence component element, the mapping relation of each stationary phrase in the sentence component element and each test case element limiting the tested function range is correspondingly determined.
In this embodiment, by determining the test case elements corresponding to each sentence component element according to each sentence component element and the preset mapping relation, the connection between the natural language test sentence and each preset test can be determined, a foundation is provided for generating the test case, and it is ensured that the computer can automatically generate the test case for the natural language.
In one embodiment, as shown in fig. 9, the test case elements are the function under test, the modification point, the range under test, and the range defining the function under test, respectively; according to each sentence component element of the natural sentence component set and a preset mapping relation, determining a test case element corresponding to each sentence component element, including:
step 902, determining a mapping relation between the subject and the tested function according to a preset mapping relation.
The tested function may be a function that the black box test task needs to be tested.
Specifically, according to the corresponding relation between each test case element and each sentence component element, the mapping relation between each subject in the sentence component element and each tested function in the test case element is correspondingly determined.
Step 904, determining the mapping relation between the main predicate verb and the modification point according to the preset mapping relation.
Wherein the modification point may be a location where the black box test task needs to be modified.
Specifically, the mapping relation between each main predicate verb in the sentence component element and each modification point in the test case element is determined correspondingly according to the corresponding relation between each test case element and each sentence component element.
Step 906, determining the mapping relation between the object and the measured range according to the preset mapping relation.
The tested range may be a range that the black box test task needs to be tested.
Specifically, according to the corresponding relation between each test case element and each sentence component element, the mapping relation between each object in the sentence component element and each modification point in the test case element is correspondingly determined.
Step 908, determining the mapping relation between the stationary language and the limited tested function range according to the preset mapping relation.
The limiting of the tested function may be limiting of a range corresponding to the tested function in the black box test task.
Specifically, according to the corresponding relation between each test case element and each sentence component element, the mapping relation of each stationary phrase in the sentence component element and each test case element limiting the tested function range is correspondingly determined.
In this embodiment, the correspondence between each component in the natural language and the test case element is determined by the preset mapping relationship, so that the computer can automatically generate the test case according to the correspondence between the components when the test case is built, and the efficiency of generating the test case is improved.
It should be understood that, although the steps in the flowcharts related to the above embodiments are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
Based on the same inventive concept, the embodiment of the application also provides a test case generating device for realizing the test case generating method. The implementation scheme of the solution provided by the device is similar to the implementation scheme recorded in the method, so the specific limitation in the embodiment of the one or more test case generating devices provided below can be referred to the limitation of the method for generating test cases in the above, and will not be repeated here
In one embodiment, as shown in fig. 13, there is provided a test case generating apparatus including: a data acquisition module 1302, a data parsing module 1304, a test case generation module 1306, and a target case derivation module 1308, wherein:
the data obtaining module 1302 is configured to obtain a test requirement document and a natural language test statement set corresponding to the target black box test task; the test requirement document comprises test document architecture information, test statement specification information and test grammar specification information;
the data parsing module 1304 is configured to parse the set of natural language test sentences according to the test document architecture information, the test sentence specification information, and the test grammar specification information to obtain a set of natural sentence components corresponding to the target black box test task when the set of natural language test sentences is not an empty set;
the test case generation module 1306 is configured to correspondingly input each test case element of the test case element set and each sentence element of the natural sentence element set corresponding to the target black box test task into a test case construction algorithm, so as to obtain a test case set to be detected corresponding to the target black box test task; each test case element has a mapping relation with sentence component elements in the natural sentence component set;
The target case obtaining module 1308 is configured to use the to-be-detected test case set as a black box test task case set corresponding to the target black box test task when the test case set detection results corresponding to the to-be-detected test case set all meet the detection conditions of each function.
In one embodiment, the test case generating module 1306 is further configured to match each test case element in the test case element set with each test case construction algorithm, so as to obtain a test case matching result; and respectively calling corresponding test case elements and sentence component elements according to the test case matching result and each test case construction algorithm to perform test case combination, so as to obtain a test case set to be detected corresponding to the test case element set.
In one embodiment, the test case generating module 1306 is further configured to call corresponding test case elements and sentence component elements to perform test case combination according to the test case matching result and the equivalence class test case construction algorithm, so as to obtain an equivalence class test case set; according to the test case matching result and the boundary value test case construction algorithm, calling corresponding test case elements and statement component elements to carry out test case combination, and obtaining a boundary value test case set; according to the test case matching result and the causal graph test case construction algorithm, calling corresponding test case elements and statement component elements to perform test case combination, and obtaining a causal graph test case set; and integrating the equivalence class test case set, the boundary value test case set and the causal graph test case set to obtain a test case set to be detected.
In one embodiment, the test case generating module 1306 is further configured to perform modification range test on the equivalence class test case set, the boundary value test case set, and the causal graph test case set, to obtain a modification range test result; under the condition that the modification range test result represents the equivalence class test case set, the boundary value test case set and the causal graph test case set and meets the first test condition, respectively performing the stock function test on the equivalence class test case set, the boundary value test case set and the causal graph test case set to obtain a stock function test result; and under the condition that the storage function test result represents that each to-be-detected test case meets the second test condition, taking the storage function test result as a test case set detection result.
In one embodiment, the test case generating module 1306 is further configured to perform a range division equivalence test on the equivalence class test case set, the boundary value test case set, and the causal graph test case set, to obtain a range division test result; respectively carrying out range boundary value test on the equivalence class test case set, the boundary value test case set and the causal graph test case set to obtain a range boundary value test result; and integrating the range division test result and the range boundary value test result to obtain a modified range test result.
In one embodiment, the data parsing module 1304 is further configured to perform word segmentation processing on the natural language test sentence set according to the test document architecture information, the test sentence specification information and the test grammar specification information, so as to obtain a first natural sentence component set; performing part-of-speech analysis on the natural language test sentence set according to the test document architecture information, the test sentence specification information and the test grammar specification information to obtain a second natural sentence component set; according to the test document architecture information, the test sentence specification information and the test grammar specification information, carrying out grammar analysis on the natural language test sentence set to obtain a third natural sentence component set; and integrating the first natural sentence component set, the second natural sentence component set and the third natural sentence component set to obtain a natural sentence component set.
In one embodiment, the data parsing module 1304 is further configured to obtain a preset mapping relationship corresponding to the target black box test task; the preset mapping relation is a corresponding relation between each test case element in the test case element set and each sentence component element in the natural sentence component set according to the target black box test task; and determining test case elements corresponding to the sentence component elements according to the sentence component elements of the natural sentence component set and a preset mapping relation.
In one embodiment, the data parsing module 1304 is further configured to determine a mapping relationship between the subject and the function under test according to a preset mapping relationship; determining the mapping relation between the main predicate verb and the modification point according to the preset mapping relation; determining the mapping relation between the object and the measured range according to the preset mapping relation; and determining the mapping relation between the fixed language and the limited tested function range according to the preset mapping relation.
Each module in the test case generating device may be implemented in whole or in part by software, hardware, or a combination thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, which may be a server, and the internal structure of which may be as shown in fig. 14. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is for storing server data. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program, when executed by a processor, implements a test case generation method.
It will be appreciated by those skilled in the art that the structure shown in fig. 14 is merely a block diagram of a portion of the structure associated with the present application and is not limiting of the computer device to which the present application applies, and that a particular computer device may include more or fewer components than shown, or may combine certain components, or have a different arrangement of components.
In an embodiment, there is also provided a computer device comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the steps of the method embodiments described above when the computer program is executed.
In one embodiment, a computer-readable storage medium is provided, storing a computer program which, when executed by a processor, implements the steps of the method embodiments described above.
In one embodiment, a computer program product or computer program is provided that includes computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the steps in the above-described method embodiments.
It should be noted that, user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, presented data, etc.) referred to in the present application are information and data authorized by the user or sufficiently authorized by each party.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in the various embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magnetic random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (Phase Change Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in the form of a variety of forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), and the like. The databases referred to in the various embodiments provided herein may include at least one of relational databases and non-relational databases. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processors referred to in the embodiments provided herein may be general purpose processors, central processing units, graphics processors, digital signal processors, programmable logic units, quantum computing-based data processing logic units, etc., without being limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The above examples only represent a few embodiments of the present application, which are described in more detail and are not to be construed as limiting the scope of the present application. It should be noted that it would be apparent to those skilled in the art that various modifications and improvements could be made without departing from the spirit of the present application, which would be within the scope of the present application. Accordingly, the scope of protection of the present application shall be subject to the appended claims.

Claims (12)

1. A method for generating test cases, the method comprising:
acquiring a test requirement document and a natural language test statement set corresponding to a target black box test task; the test requirement document comprises test document architecture information, test statement specification information and test grammar specification information;
under the condition that the natural language test statement set is not an empty set, analyzing the natural language test statement set according to the test document architecture information, the test statement specification information and the test grammar specification information to obtain a natural statement component set corresponding to the target black box test task;
Correspondingly inputting each test case element of the test case element set corresponding to the target black box test task and each sentence component element of the natural sentence component set into a test case construction algorithm to obtain a test case set to be detected corresponding to the target black box test task; each test case element has a mapping relation with sentence component elements in the natural sentence component set;
and under the condition that the detection results of the test case set corresponding to the to-be-detected test case set meet the detection conditions of all functions, taking the to-be-detected test case set as a black box test task case set corresponding to the target black box test task.
2. The method according to claim 1, wherein the inputting each test case element of the test case element set corresponding to the target black box test task and each sentence component element of the natural sentence component set into the test case construction algorithm correspondingly, to obtain a to-be-detected test case set corresponding to the target black box test task includes:
matching each test case element in the test case element set with each test case construction algorithm to obtain a test case matching result;
And respectively calling corresponding test case elements and statement component elements to perform test case combination according to the test case matching result and each test case construction algorithm to obtain a test case set to be detected corresponding to the test case element set.
3. The method of claim 2, wherein the test case construction algorithm comprises an equivalence class test case construction algorithm, a boundary value test case construction algorithm, and a causal graph test case construction algorithm; according to the test case matching result and each test case construction algorithm, respectively calling corresponding test case elements and statement component elements to perform test case combination to obtain a test case set to be detected corresponding to the test case element set, wherein the test case set to be detected comprises the following components:
according to the test case matching result and the equivalence class test case construction algorithm, calling corresponding test case elements and the statement component elements to perform test case combination to obtain an equivalence class test case set;
according to the test case matching result and the boundary value test case construction algorithm, calling corresponding test case elements and statement component elements to perform test case combination to obtain a boundary value test case set;
According to the test case matching result and the causal graph test case construction algorithm, calling corresponding test case elements and statement component elements to perform test case combination, and obtaining a causal graph test case set;
and integrating the equivalence class test case set, the boundary value test case set and the causal graph test case set to obtain the test case set to be detected.
4. The method according to claim 3, wherein, before the step of taking the set of test cases to be detected as the set of black box test task cases corresponding to the target black box test task, if the test case set detection results corresponding to the set of test cases to be detected all meet the functional detection conditions, the method further comprises:
performing modification range test on the equivalence class test case set, the boundary value test case set and the causal graph test case set respectively to obtain a modification range test result;
under the condition that the modification range test result represents that the equivalence class test case set, the boundary value test case set and the causal graph test case set all meet a first test condition, respectively performing stock function test on the equivalence class test case set, the boundary value test case set and the causal graph test case set to obtain a stock function test result;
And under the condition that the storage function test result represents that each to-be-detected test case to be determined meets a second test condition, taking the storage function test result as the test case set detection result.
5. The method of claim 4, wherein the performing a modification range test on the set of equivalence class test cases, the set of boundary value test cases, and the set of causal graph test cases, respectively, to obtain a modification range test result comprises:
performing range division equivalence test on the equivalence class test case set, the boundary value test case set and the causal graph test case set respectively to obtain a range division test result;
performing range boundary value test on the equivalence class test case set, the boundary value test case set and the causal graph test case set respectively to obtain a range boundary value test result;
and integrating the range division test result and the range boundary value test result to obtain the modified range test result.
6. The method of claim 1, wherein the parsing the natural language test sentence set according to the test document architecture information, the test sentence specification information and the test grammar specification information to obtain a natural sentence component set corresponding to the target black box test task includes:
According to the test document architecture information, the test sentence specification information and the test grammar specification information, word segmentation processing is carried out on the natural language test sentence set to obtain a first natural sentence component set;
according to the test document architecture information, the test sentence specification information and the test grammar specification information, performing part-of-speech analysis on the natural language test sentence set to obtain a second natural sentence component set;
according to the test document architecture information, the test sentence specification information and the test grammar specification information, carrying out grammar analysis on the natural language test sentence set to obtain a third natural sentence component set;
and integrating the first natural sentence component set, the second natural sentence component set and the third natural sentence component set to obtain the natural sentence component set.
7. The method of claim 6, further comprising, after the step of integrating the first set of natural sentence components, the second set of natural sentence components, and the third set of natural sentence components, the step of:
Acquiring a preset mapping relation corresponding to the target black box test task; the preset mapping relation is to preset the corresponding relation between each test case element in the test case element set and each sentence component element in the natural sentence component set according to the target black box test task;
and determining test case elements corresponding to the sentence component elements according to the sentence component elements of the natural sentence component set and the preset mapping relation.
8. The method of claim 7, wherein the sentence component elements are subject, subject predicate verb, object, and subject, respectively; the test case elements are a tested function, a modified point, a tested range and a limited tested function range respectively; the determining test case elements corresponding to the sentence component elements according to the sentence component elements of the natural sentence component set and the preset mapping relation includes:
determining the mapping relation between the subject and the tested function according to the preset mapping relation;
determining the mapping relation between the main predicate verb and the modification point according to the preset mapping relation;
Determining the mapping relation between the object and the measured range according to the preset mapping relation;
and determining the mapping relation between the fixed language and the limited tested function range according to the preset mapping relation.
9. A test case generating device, the device comprising:
the data acquisition module is used for acquiring a test requirement document and a natural language test statement set corresponding to the target black box test task; the test requirement document comprises test document architecture information, test statement specification information and test grammar specification information;
the data analysis module is used for analyzing the natural language test statement set according to the test document architecture information, the test statement specification information and the test grammar specification information under the condition that the natural language test statement set is not an empty set, so as to obtain a natural statement component set corresponding to the target black box test task;
the test case generation module is used for correspondingly inputting each test case element of the test case element set corresponding to the target black box test task and each sentence component element of the natural sentence component set into a test case construction algorithm to obtain a to-be-detected test case set corresponding to the target black box test task; each test case element has a mapping relation with sentence component elements in the natural sentence component set;
The target case obtaining module is used for taking the to-be-detected test case set as a black box test task case set corresponding to the target black box test task under the condition that the test case set detection results corresponding to the to-be-detected test case set all meet the detection conditions of all functions.
10. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any one of claims 1 to 8 when the computer program is executed.
11. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 8.
12. A computer program product comprising a computer program, characterized in that the computer program, when executed by a processor, implements the steps of the method of any one of claims 1 to 8.
CN202310318877.4A 2023-03-29 2023-03-29 Test case generation method, device, computer equipment and storage medium Pending CN116483696A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310318877.4A CN116483696A (en) 2023-03-29 2023-03-29 Test case generation method, device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310318877.4A CN116483696A (en) 2023-03-29 2023-03-29 Test case generation method, device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116483696A true CN116483696A (en) 2023-07-25

Family

ID=87220420

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310318877.4A Pending CN116483696A (en) 2023-03-29 2023-03-29 Test case generation method, device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116483696A (en)

Similar Documents

Publication Publication Date Title
CN111258966A (en) Data deduplication method, device, equipment and storage medium
US20210110111A1 (en) Methods and systems for providing universal portability in machine learning
CN106648569B (en) Target serialization realization method and device
US10911379B1 (en) Message schema management service for heterogeneous event-driven computing environments
CN115827895A (en) Vulnerability knowledge graph processing method, device, equipment and medium
CN112199344B (en) Log classification method and device
JP2017174418A (en) Data structure abstraction for model checking
CN114547257B (en) Class matching method and device, computer equipment and storage medium
CN113010550B (en) Batch object generation and batch processing method and device for structured data
US9201936B2 (en) Rapid provisioning of information for business analytics
CN116483696A (en) Test case generation method, device, computer equipment and storage medium
CN117828025A (en) File content examination method and device based on artificial intelligence and computer equipment
CN116882396A (en) Function point analysis method, device, computer equipment, storage medium and product
CN117610557A (en) Text detection method, device, equipment and storage medium
CN117370339A (en) Report blood edge relationship processing method and device, computer equipment and storage medium
CN116894195A (en) Text similarity calculation method, device, computer equipment and storage medium
CN115907442A (en) Business demand modeling method, device, electronic equipment and medium
CN117435700A (en) Data searching method, device, computer equipment and storage medium
CN115827574A (en) Method and device for reading video playback data and storage medium
CN118092921A (en) File generation method, apparatus, device, storage medium and computer program product
CN117251777A (en) Data processing method, device, computer equipment and storage medium
CN117094292A (en) Form file processing method, form file processing device, form file processing equipment, storage medium and program product
CN117521667A (en) Semantic information processing method, semantic information processing device, computer equipment, storage medium and product
CN116795866A (en) File processing method, device, equipment and storage medium
CN112597058A (en) Web page testing method, device, equipment and storage medium based on volume creation

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination