Test case generation method, device, electronic device and computer program product
Through the deep search algorithm and the breadth search algorithm, the cases to be tested are integrated and the scene tree is built, and the serialized test case library is finally generated through the minimum repetition algorithm, which solves the problem of single test case scenarios in the existing technology, and achieves wide coverage of test cases and efficient automated testing.
Patent Information
- Application Number
- CN202111341165.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-12
- Publication Date
- 2025-05-02
- Estimated Expiration
- 2041-11-12
AI Technical Summary
It is difficult for the existing technology to integrate all relevant test scenarios, resulting in a single test scenario for test cases and cannot cover all test scenarios widely.
Through the deep search algorithm and the breadth search algorithm combined with the test conditions of each test case to be tested, the test cases are integrated to generate the target test case library; then the scene tree is built based on the test process in the target test case library, and finally the scene tree is integrated through the minimum repetition algorithm to generate a serialized test case library.
It realizes that test cases can cover all test scenarios widely, improve the scope and depth of test cases, and improve the efficiency and accuracy of automated testing.
Smart Images

Figure CN113986756B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of automated testing technology, and in particular to a test case generation method, device, electronic device and computer program product. Background Art
[0002] At present, most of the indoor test tasks of rail transit are tested one by one by testers according to the test case instructions. Each test case has a single observation point, so all related test scenarios cannot be integrated for testing, resulting in a single test scenario for the test case, that is, the test case cannot cover a wide range of test scenarios. Summary of the invention
[0003] The present application provides a test case generation method, device, electronic device and computer program product, aiming to enable test cases to cover a wide range of test scenarios.
[0004] In a first aspect, the present application provides a test case generation method, comprising:
[0005] According to the depth search algorithm and the breadth search algorithm and in combination with the test conditions of each test case, each of the test cases is integrated to obtain each target test case library;
[0006] Constructing each scenario tree according to the test process of each test case to be tested in each target test case library;
[0007] According to the minimum repetition algorithm and in combination with the generation scenarios of each of the scenario trees, each of the scenario trees is integrated to generate each serialized test case library.
[0008] In one embodiment, the step of integrating the test cases to be tested according to the depth search algorithm and the breadth search algorithm and combining the test conditions of the test cases to be tested to obtain the target test case libraries includes:
[0009] Each test case set in the data to be used is traversed by the depth search algorithm and the breadth search algorithm to obtain each test case to be tested;
[0010] Determining the test conditions of each of the test cases to be tested according to the test case structure and the test case function of each of the test cases to be tested;
[0011] The test cases under the same test condition are integrated into the same test case library to obtain the target test case libraries.
[0012] The step of constructing each scenario tree according to the test process of each test case in each target test case library comprises:
[0013] Determine the test process of each to-be-tested case in each of the target test case libraries, wherein the test process includes test conditions, test items, test results, and recovery environment;
[0014] Each of the scenario trees is constructed according to the test conditions, test items, test results and recovery environment of each test case to be tested in each of the target test case libraries.
[0015] Before the step of integrating the test cases to be tested according to the depth search algorithm and the breadth search algorithm and combining the test conditions of the test cases to be tested to obtain the target test case libraries, the step further includes:
[0016] Build each test case set according to the test case ID, test case input conditions, test case detection items and expected output of each test case;
[0017] The communication interface data and each of the test case sets are packaged to construct the data to be used.
[0018] Before the step of integrating the test cases to be tested according to the depth search algorithm and the breadth search algorithm and combining the test conditions of the test cases to be tested to obtain the target test case libraries, the step further includes:
[0019] Establishing communication connections with various devices to be operated according to the communication interface data in the data to be used;
[0020] Sending the data to be sent to each of the devices to be operated via the communication connection; or
[0021] The return data sent by each of the devices to be operated is received through the communication connection.
[0022] After the step of integrating the scene trees according to the minimum repetition algorithm and combining the generation scenes of the scene trees to generate the sequenced test case libraries, the method further includes:
[0023] Sending execution instructions to each device to be operated according to each serialized test case library, so that each device to be operated performs a corresponding operation according to the execution instruction;
[0024] Collect feedback information returned by each of the devices to be operated during the operation.
[0025] After the step of collecting feedback information returned by each of the devices to be operated during the operation, the method further includes:
[0026] Generate a test report for each of the devices to be operated according to the device information of each of the devices to be operated and the corresponding feedback information;
[0027] According to the test report of each of the devices to be operated, the operating status and execution result of each of the devices to be operated are determined.
[0028] In a second aspect, the present application also provides a test case generation device, comprising:
[0029] An integration module, used to integrate each of the test cases according to the depth search algorithm and the breadth search algorithm and in combination with the test conditions of each of the test cases to obtain each target test case library;
[0030] A construction module, used to construct each scenario tree according to the test process of each test case to be tested in each target test case library;
[0031] The generation module is used to integrate each of the scenario trees according to the minimum repetition algorithm and in combination with the generation scenarios of each of the scenario trees to generate each serialized test case library.
[0032] In a third aspect, the present application also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the test case generation method described in the first aspect are implemented.
[0033] In a fourth aspect, the present application further provides a computer program product, which includes a computer program, and when the computer program is executed by the processor, the steps of the test case generation method described in the first aspect are implemented.
[0034] The test case generation method, device, electronic device and computer program product provided in the present application generate various serialized test case libraries through a depth search algorithm, a breadth search algorithm and a minimum repetition algorithm. Since the depth search algorithm and the breadth search algorithm can traverse each case to be tested in each node, a wider range and a deeper acquisition of each case to be tested is achieved, so that the application scope of each serialized test case library generated according to each case to be tested is wider, thereby achieving that each generated serialized test case library can widely cover various test scenarios. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] In order to more clearly illustrate the technical solutions in the present application or the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0036] Figure 1 This is one of the flow charts of the test case generation method provided by this application;
[0037] Figure 2 It is a functional module connection diagram of the test case generation method provided by this application;
[0038] Figure 3 It is an application scenario diagram of the scenario tree of the test case generation method provided by this application;
[0039] Figure 4 This is the second flowchart of the test case generation method provided by this application;
[0040] Figure 5 This is the third flowchart of the test case generation method provided by this application;
[0041] Figure 6 It is a structural schematic diagram of the test case generation device provided by the present application;
[0042] Figure 7 It is a structural schematic diagram of the electronic device provided by this application. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solutions and advantages of this application clearer, the technical solutions in this application will be clearly and completely described below in conjunction with the drawings in this application. Obviously, the described embodiments are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0044] Combine the following Figures 1 to 7 Describe the test case generation method, device, electronic device and computer program product provided in this application.
[0045] Specifically, the present application provides a test case generation method, referring to Figures 1 to 5 , Figure 1 This is one of the flow charts of the test case generation method provided by this application; Figure 2 It is a functional module connection diagram of the test case generation method provided by this application; Figure 3 It is an application scenario diagram of the scenario tree of the test case generation method provided by this application; Figure 4 This is the second flowchart of the test case generation method provided by this application; Figure 5 This is the third flow chart of the test case generation method provided in this application.
[0046] The embodiments of the present application provide embodiments of a test case generation method. It should be noted that, although a logical order is shown in the flowchart, under certain data, the steps shown or described may be completed in an order different from that shown here.
[0047] The embodiments of the present application take an electronic device as an execution subject for example. The embodiments of the present application take a test case generation system as one of the forms of the electronic device, but do not limit the electronic device.
[0048] The test case generation method provided in the embodiment of the present application includes:
[0049] Step S10, integrating the test cases to be tested according to the depth search algorithm and the breadth search algorithm and in combination with the test conditions of the test cases to be tested, to obtain target test case libraries.
[0050] It should be noted that the process of comprehensive collaborative automated testing requires the generation of a serialized test case library, and then automated testing is performed based on the generated serialized test case library. The comprehensive collaborative automated testing of the embodiment of the present application is mainly implemented by a test case generation system. The test case generation system of the embodiment of the present application mainly includes but is not limited to 5 functional modules, and the above 5 functional modules are respectively a data loading module, a test case serialization module, a test sequence execution module, a communication module and a test report generation module, that is, the comprehensive collaborative automated testing is jointly implemented by the above 5 functional modules.
[0051] The main functions of the above five functional modules are as follows: the main function of the data loading module is to read the line configuration data, test case set and communication interface protocol, package the line configuration data, test case set and communication interface protocol, and send the packaged data to be used to the test sequence execution module; the main function of the test case serialization module is to receive the data to be used sent by the data loading module, generate a serialized test case library according to the data to be used, and send the serialized test case library to the test sequence execution module; the test sequence execution module is a functional logic processing module for comprehensive collaborative automated testing, and its main function is to receive the serialized test case library sent by the test case serialization module, send drive instructions to the rail transit equipment according to the serialized test case library, and collect feedback information returned during the execution of the rail transit equipment; the main function of the communication module is to establish a communication connection between the test case generation system and each rail transit equipment; the main function of the test report generation module is to generate a test report of each rail transit equipment during execution according to the equipment information of each rail transit equipment and its corresponding feedback information. The communication connection relationship between the above five functional modules is shown in 2. Figure 2 It is a functional module connection diagram of the test case generation method provided in this application.
[0052] Therefore, before obtaining the target test case library according to the depth search algorithm and the breadth search algorithm and integrating the test conditions of each test case to be tested, the test case generation system of this embodiment needs to build the required test case set and the required data to be used through the data loading module, and build the communication connection between the test case generation system and each rail transit equipment. The specific steps are described in steps A to E.
[0053] Further, the description of step A to step B is as follows:
[0054] Step A, constructing each test case set according to the test case ID, test case input condition, test case detection item and test case expected output of each test case;
[0055] Step B: Pack the communication interface data and each of the test case sets to construct the data to be used.
[0056] Specifically, the test case generation system reads the communication interface data and the test case script set of each test case, wherein the test case script set includes the test case ID (Identity Document, ID card identification number), the test case input condition, the test case detection item and the test case expected output of the test case. Then, the test case generation system can use the test case ID as a construction condition, and the test cases corresponding to the associated use case ID are classified into the same test case set, and the corresponding test case sets are constructed. Furthermore, the test case generation system can use the use case input condition as a construction condition, and the test cases with the same use case input condition are classified into the same test case set, and the corresponding test case sets are constructed. Furthermore, the test case generation system can use the use case detection item as a construction condition, and the test cases corresponding to similar use case detection items are classified into the same test case set, and the corresponding test case sets are constructed. Furthermore, the test case generation system can use the use case expected output as a construction condition, and the test cases with the same use case expected output are classified into the same test case set, and the corresponding test case sets are constructed. At the same time, the test case generation system packages each test case set and communication interface data to obtain the data to be used required by the test case serialization module in the test case generation system.
[0057] The embodiment of the present application builds each test case set in advance according to the use case ID, use case input conditions, use case detection items and use case expected output of each test case, so it can be used directly when needed without consuming time to build a test case set, so that each target test case library can be quickly determined, providing the premise and guarantee for the subsequent rapid generation of each serialized test case library. At the same time, the embodiment of the present application builds a diverse test case set according to the use case ID, use case input conditions, use case detection items and use case expected output of each test case, so that the test cases traversed by the depth search algorithm and the breadth search algorithm are diverse, so that the scope of application of each serialized test case library generated according to each test case is wider, thereby achieving that each generated serialized test case library can be widely covered in various test scenarios.
[0058] Further, step C to step E are described as follows:
[0059] Step C, establishing a communication connection with each device to be operated according to the communication interface data in the data to be used;
[0060] Step D, sending the data to be sent to each of the devices to be operated via the communication connection;
[0061] Step E: receiving return data sent by each of the devices to be operated through the communication connection.
[0062] Specifically, the test case generation system standardizes the transmission protocol between the test case serialization module in the test case generation system and each device to be operated (rail transit equipment) according to the transmission protocol carried by the communication interface data in the data to be used, and establishes a communication connection between the test case serialization module and each rail transit equipment. The test case generation system determines the packet assembly rules provided by the communication protocol in the communication connection, and sends the data to be sent to each rail transit equipment through the packet assembly rules. Furthermore, the test case generation system receives the return data sent by each rail transit equipment through the communication connection, and determines the deframing format provided by the communication protocol in the communication connection, and parses the return data through the deframing format to obtain the parsed data content.
[0063] The embodiment of the present application standardizes the transmission protocol between the test case generation system and each rail transit equipment through communication interface data, thereby enabling rapid communication between the test case generation system and each rail transit equipment through its own standardized transmission protocol.
[0064] Furthermore, after constructing the data to be used and establishing the communication connection, the test case generation system determines each test case set in the data to be used, and traverses each test case set through the depth search algorithm and the breadth search algorithm to obtain the corresponding test cases to be tested. Next, the test case generation system determines the test conditions of each test case to be tested, integrates each test case to be tested according to the test conditions of each test case to be tested, and obtains each target test case library, as described in steps S101 to S103.
[0065] Compared with the traditional method that different test cases need to be tested separately, this embodiment integrates various test cases according to various test conditions, thereby reducing the test time and improving the test efficiency of the comprehensive collaborative automated test.
[0066] Step S20, constructing each scenario tree according to the test process of each test case to be tested in each of the target test case libraries.
[0067] The test case generation system determines the test flow of each case to be tested in each target test case library, and the test flow of each case to be tested includes the test conditions and test content of each case to be tested. Then, the test case generation system determines the test conditions and test content of each case to be tested, and constructs each scenario tree, as described in steps S201 to S202.
[0068] Step S201, determining the test process of each to-be-tested case in each of the target test case libraries, wherein the test process includes test conditions, test items, test results and recovery environment;
[0069] Step S202, constructing each of the scenario trees according to the test conditions, test items, test results and recovery environment of each test case to be tested in each of the target test case libraries.
[0070] Specifically, the test case generation system determines the test conditions, test items, test results, and recovery environments of each test case to be tested in each target test case library. Then, the test case generation system merges the test conditions of each test case to be tested, uses the test items of each test case to be tested as branches of the test conditions, and uses the test results of each test case to be tested as branches of its corresponding test conditions. Finally, the test case generation system merges branches with the same recovery environment to obtain each scenario tree.
[0071] In this embodiment, for example, the two test cases in the target test case library 1 are test case 1 and test case 2. Test case 1 is: whether the code sent by the interlock to the dispatcher in the point-to-point test is correct; test case 2 is: whether the signal lights between the devices are displayed consistently in the VOBC test. Therefore, the test flow of test case 1 is: process the route (test condition) - whether the code sent by the interlock to the dispatcher is correct (test item) - the code is correct or wrong (test result) - cancel the route (restore environment); the test flow of test case 2 is: process the route (test condition) - whether the signal lights between the devices are displayed consistently (test item) - consistent or inconsistent (test result) - cancel the route (restore environment). Therefore, the scenario tree obtained according to the test conditions, test items, test results and recovery environment of test case 1 and test case 2 is as follows. Figure 3 As shown, Figure 3 It is an application scenario diagram of the scenario tree of the test case generation method provided in this application.
[0072] The embodiment of the present application constructs each scenario tree according to the test conditions, test items, test results and recovery environment of each test case to be tested, so that there are multiple test cases in each scenario tree, and each scenario tree can execute more test cases simultaneously during execution, thereby improving the test efficiency of comprehensive collaborative automated testing.
[0073] Step S30, integrating the scenario trees according to the minimum repetition algorithm and combining the generation scenarios of the scenario trees to generate various serialized test case libraries.
[0074] The test case generation system determines the generation scenario of each scenario tree, and integrates the scenario trees of the same generation scenario through a minimum repetition algorithm to obtain each integrated scenario tree, and each integrated scenario tree is each serialized test case library.
[0075] This embodiment integrates each scenario tree through the minimum repetition algorithm, so that the test cases of the same scenario in each generated serialized test case library are richer, so that more test cases can be executed in the same scenario, while improving the test efficiency of the comprehensive collaborative automated test and the test accuracy of the comprehensive collaborative automated test.
[0076] This embodiment provides a test case generation method, which generates various serialized test case libraries through a depth search algorithm, a breadth search algorithm and a minimum repetition algorithm. Since the depth search algorithm and the breadth search algorithm can traverse each case to be tested in each node, a wider range and deeper acquisition of each case to be tested is achieved, so that the application scope of each serialized test case library generated according to each case to be tested is wider, thereby achieving that each generated serialized test case library can widely cover various test scenarios.
[0077] Further, refer to Figure 4 , Figure 4 This is the second flow chart of the test case generation method provided by the present application, wherein step S10 comprises:
[0078] Step S101, traversing each test case set in the data to be used by using the depth search algorithm and the breadth search algorithm to obtain each test case to be tested;
[0079] Step S102, determining the test conditions of each of the test cases to be tested according to the test case structure and the test case function of each of the test cases to be tested;
[0080] Step S103, integrating the test cases under the same test condition into the same test case library to obtain the target test case libraries.
[0081] The test case generation system traverses each test case set in the data to be used through a depth search algorithm and a breadth search algorithm to obtain each test case to be tested, wherein each test case to be tested includes a test case table, a test case structure, and a test case function. Then, the test case generation system determines the test conditions of each test case to be tested based on the test case structure and test case function of each test case to be tested. It should be noted that the test case structure and the test case function are different, but the test conditions may be the same. Finally, the test case generation system integrates the test cases to be tested with the same test conditions into the same test case library to obtain each target test case library.
[0082] In this embodiment, for example, case 1 to be tested is: whether the code position sent by the interlock to the dispatcher in the point-to-point test is correct; case 2 to be tested is: whether the signal lights between the devices in the VOBC test are displayed consistently. The test case function of case 1 to be tested is: whether the code position sent by the interlock to the dispatcher is correct, and the test case function of case 2 to be tested is: determine whether the signal lights between the devices are displayed consistently. The process of case 1 to be tested is: first handle the route, then detect the code position change, and finally cancel the route; the process of case 1 to be tested is: first handle the route, then observe the signal light change, and finally cancel the route. The test case functions of case 1 to be tested and case 2 to be tested are different, but the test conditions of case 1 to be tested and case 2 to be tested are the same, so case 1 to be tested and case 2 to be tested are integrated into the same test case library, that is, case 1 to be tested and case 2 to be tested are tested in the same scenario.
[0083] It should be noted that after testing a test case, it is necessary to restore the test case to its initial state, that is, restore the environment of the test case, as described above to cancel the route.
[0084] The embodiment of the present application generates each serialized test case library through a depth search algorithm, a breadth search algorithm and a minimum repetition algorithm. Since the depth search algorithm and the breadth search algorithm can traverse each test case to be tested in each node, a wider range and more in-depth acquisition of each test case to be tested are achieved, so that the scope of application of each serialized test case library generated according to each test case to be tested is wider, thereby achieving that each serialized test case library generated can be widely covered in each test scenario. Furthermore, the embodiment of the present application automatically determines the test conditions of each test case to be tested through the test case structure and test case function of each test case to be tested, without the need for manual observation of test items, and then determines the test conditions of each test case to be tested according to the observation results, so as to accurately determine the test conditions of each test case to be tested. Furthermore, manual observation of test items requires too long a time consumption, making the test efficiency low. The present embodiment is completed by the collaborative automation between each functional module, thereby improving the test efficiency of the comprehensive collaborative automation test. Furthermore, compared to the traditional method in which different test cases need to be tested separately, this embodiment integrates various test cases according to various test conditions, thereby reducing the test time and improving the test efficiency of the comprehensive collaborative automated test.
[0085] Further, refer to Figure 5 , Figure 5 This is the third flow chart of the test case generation method provided by the present application. After step S30, it also includes:
[0086] Step S40, sending execution instructions to each device to be operated according to each serialized test case library, so that each device to be operated performs a corresponding operation according to the execution instruction;
[0087] Step S50: collecting feedback information returned by each of the devices to be operated during the operation.
[0088] Specifically, the test case generation system generates execution instructions for each device to be operated (railway transportation equipment) according to each serialized test case library, and sends each execution instruction to each rail transportation equipment through a communication connection. Each rail transportation equipment receives the execution instruction sent by the test case generation system, performs the corresponding operation according to the execution instruction, and returns the feedback information during the execution process to the test case generation system in real time. Finally, the test case generation system collects the feedback information returned by each device to be operated during the execution process in real time.
[0089] This embodiment provides a test case generation method, which automatically generates execution instructions according to each serialized test case library, and automatically drives each rail transit equipment to perform operations according to the execution instructions without human intervention, thereby reducing execution time and improving the test efficiency of comprehensive collaborative automated testing.
[0090] Step S60, generating a test report for each of the devices to be operated according to the device information of each of the devices to be operated and the corresponding feedback information;
[0091] Step S70: determining the operating status and execution result of each of the devices to be operated according to the test report of each of the devices to be operated.
[0092] The test case generation system determines the equipment information of each rail transit equipment, binds the equipment information of each rail transit equipment and its corresponding feedback information, and generates a test report for each rail transit equipment. Then, the test case generation system determines the operating status and execution results of each rail transit equipment based on the test report of each rail transit equipment. Furthermore, the test case generation system can send the test report to the user terminal of the tester, and the tester can understand the operating status and execution results of each rail transit equipment based on the test report in the user terminal.
[0093] This embodiment provides a test case generation method, which generates a test report according to the equipment information of each rail transit equipment and its corresponding feedback information, so that the operation status and execution results of each rail transit equipment can be viewed intuitively and clearly according to the test report.
[0094] Furthermore, the test case generation device provided in the present application is described below. The test case generation device described below and the test case generation method described above can be referenced to each other.
[0095] like Figure 6 As shown, Figure 6 It is a structural diagram of a test case generation device provided by the present application, and the test case generation device comprises:
[0096] An integration module 601 is used to integrate each of the test cases according to the depth search algorithm and the breadth search algorithm and in combination with the test conditions of each of the test cases to obtain each target test case library;
[0097] A construction module 602 is used to construct each scenario tree according to the test process of each test case to be tested in each target test case library;
[0098] The generation module 603 is used to integrate the scenario trees according to the minimum repetition algorithm and in combination with the generation scenarios of the scenario trees to generate various serialized test case libraries.
[0099] Furthermore, the integration module 601 is also used for:
[0100] Each test case set in the data to be used is traversed by the depth search algorithm and the breadth search algorithm to obtain each test case to be tested;
[0101] Determining the test conditions of each of the test cases to be tested according to the test case structure and the test case function of each of the test cases to be tested;
[0102] The test cases under the same test condition are integrated into the same test case library to obtain the target test case libraries.
[0103] Furthermore, the construction module 602 is also used for:
[0104] Determine the test process of each to-be-tested case in each of the target test case libraries, wherein the test process includes test conditions, test items, test results, and recovery environment;
[0105] Each of the scenario trees is constructed according to the test conditions, test items, test results and recovery environment of each test case to be tested in each of the target test case libraries.
[0106] Furthermore, the construction module 602 is also used for:
[0107] Build each test case set according to the test case ID, test case input conditions, test case detection items and expected output of each test case;
[0108] The communication interface data and each of the test case sets are packaged to construct the data to be used.
[0109] Furthermore, the test case generating device further comprises: a communication module, configured to:
[0110] Establishing communication connections with various devices to be operated according to the communication interface data in the data to be used;
[0111] Sending the data to be sent to each of the devices to be operated via the communication connection; or
[0112] The return data sent by each of the devices to be operated is received through the communication connection.
[0113] Furthermore, the test case generating device further comprises: a collection module, which is used to:
[0114] Sending execution instructions to each device to be operated according to each serialized test case library, so that each device to be operated performs a corresponding operation according to the execution instruction;
[0115] Collect feedback information returned by each of the devices to be operated during the operation.
[0116] Furthermore, the test case generating device further comprises: a determination module, configured to:
[0117] Generate a test report for each of the devices to be operated according to the device information of each of the devices to be operated and the corresponding feedback information;
[0118] According to the test report of each of the devices to be operated, the operating status and execution result of each of the devices to be operated are determined.
[0119] The specific embodiments of the test case generation device provided in this application are basically the same as the embodiments of the above-mentioned test case generation method, and will not be repeated here.
[0120] Figure 7 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 7 As shown, the electronic device may include: a processor 710, a communication interface 720, a memory 730 and a communication bus 740, wherein the processor 710, the communication interface 720, and the memory 730 communicate with each other through the communication bus 740. The processor 710 may call the logic instructions in the memory 730 to execute the test case generation method, which includes:
[0121] According to the depth search algorithm and the breadth search algorithm and in combination with the test conditions of each test case, each of the test cases is integrated to obtain each target test case library;
[0122] Constructing each scenario tree according to the test process of each test case to be tested in each target test case library;
[0123] According to the minimum repetition algorithm and in combination with the generation scenarios of each of the scenario trees, each of the scenario trees is integrated to generate each serialized test case library.
[0124] In addition, the logic instructions in the above-mentioned memory 730 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art, and the computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk.
[0125] On the other hand, the present application also provides a computer program product, the computer program product comprising a computer program stored on a non-transitory computer-readable storage medium, the computer program comprising program instructions, when the program instructions are executed by a computer, the computer can execute the test case generation method provided by the above methods, the method comprising:
[0126] According to the depth search algorithm and the breadth search algorithm and in combination with the test conditions of each test case, each of the test cases is integrated to obtain each target test case library;
[0127] Constructing each scenario tree according to the test process of each test case to be tested in each target test case library;
[0128] According to the minimum repetition algorithm and in combination with the generation scenarios of each of the scenario trees, each of the scenario trees is integrated to generate each serialized test case library.
[0129] On the other hand, the present application also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the computer program is executed by a processor to perform the test case generation method provided above, the method comprising:
[0130] According to the depth search algorithm and the breadth search algorithm and in combination with the test conditions of each test case, each of the test cases is integrated to obtain each target test case library;
[0131] Constructing each scenario tree according to the test process of each test case to be tested in each target test case library;
[0132] According to the minimum repetition algorithm and in combination with the generation scenarios of each of the scenario trees, each of the scenario trees is integrated to generate each serialized test case library.
[0133] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0134] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0135] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A test case generation method, characterized in that: include: According to the depth search algorithm and the breadth search algorithm and in combination with the test conditions of each test case, each of the test cases is integrated to obtain each target test case library; Constructing each scenario tree according to the test process of each test case to be tested in each target test case library; Integrate each of the scenario trees according to a minimum repetition algorithm and in combination with the generation scenarios of each of the scenario trees to generate each serialized test case library; The step of integrating the test cases to be tested according to the depth search algorithm and the breadth search algorithm and combining the test conditions of the test cases to be tested to obtain the target test case libraries includes: Each test case set in the data to be used is traversed by the depth search algorithm and the breadth search algorithm to obtain each test case to be tested; Determining the test conditions of each of the test cases to be tested according to the test case structure and the test case function of each of the test cases to be tested; Integrate the test cases under the same test condition into the same test case library to obtain the target test case libraries; The step of constructing each scenario tree according to the test process of each test case to be tested in each target test case library includes: Determine the test process of each to-be-tested case in each of the target test case libraries, wherein the test process includes test conditions, test items, test results, and recovery environment; Constructing each of the scenario trees according to the test conditions, test items, test results and recovery environment of each test case to be tested in each of the target test case libraries; Before the step of integrating the test cases to be tested according to the depth search algorithm and the breadth search algorithm and combining the test conditions of the test cases to be tested to obtain the target test case libraries, the method further includes: Build each test case set according to the test case ID, test case input conditions, test case detection items and expected output of each test case; Packing the communication interface data and each of the test case sets to construct data to be used; Before the step of integrating the test cases to be tested according to the depth search algorithm and the breadth search algorithm and combining the test conditions of the test cases to be tested to obtain the target test case libraries, the method further includes: Establishing communication connections with various devices to be operated according to the communication interface data in the data to be used; Sending the data to be sent to each of the devices to be operated via the communication connection; or The return data sent by each of the devices to be operated is received through the communication connection.
2. The test case generation method according to claim 1, characterized in that: After the step of integrating the scene trees according to the minimum repetition algorithm and combining the generation scenes of the scene trees to generate the sequenced test case libraries, the method further includes: Sending execution instructions to each device to be operated according to each serialized test case library, so that each device to be operated performs a corresponding operation according to the execution instruction; Collect feedback information returned by each of the devices to be operated during the operation.
3. The test case generation method according to claim 2, characterized in that: After the step of collecting feedback information returned by each of the devices to be operated during the operation, the method further includes: Generate a test report for each of the devices to be operated according to the device information of each of the devices to be operated and the corresponding feedback information; According to the test report of each of the devices to be operated, the operating status and execution result of each of the devices to be operated are determined.
4. A test case generating device, characterized in that: include: An integration module, used to integrate each of the test cases according to the depth search algorithm and the breadth search algorithm and in combination with the test conditions of each of the test cases to obtain each target test case library; A construction module, used to construct each scenario tree according to the test process of each test case to be tested in each target test case library; A generation module, used to integrate each of the scenario trees according to a minimum repetition algorithm and in combination with the generation scenarios of each of the scenario trees, to generate each serialized test case library; Wherein, the device is also used for: Each test case set in the data to be used is traversed by the depth search algorithm and the breadth search algorithm to obtain each test case to be tested; Determining the test conditions of each of the test cases to be tested according to the test case structure and the test case function of each of the test cases to be tested; Integrate the test cases under the same test condition into the same test case library to obtain the target test case libraries; Wherein, the device is also used for: Determine the test process of each to-be-tested case in each of the target test case libraries, wherein the test process includes test conditions, test items, test results, and recovery environment; Constructing each of the scenario trees according to the test conditions, test items, test results and recovery environment of each test case to be tested in each of the target test case libraries; Wherein, the device is also used for: Build each test case set according to the test case ID, test case input conditions, test case detection items and expected output of each test case; Packing the communication interface data and each of the test case sets to construct data to be used; Wherein, the device is also used for: Establishing communication connections with various devices to be operated according to the communication interface data in the data to be used; Sending the data to be sent to each of the devices to be operated via the communication connection; or The return data sent by each of the devices to be operated is received through the communication connection.
5. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the test case generation method according to any one of claims 1 to 3 are implemented.
6. A computer program product, comprising a computer program, characterized in that: When the computer program is executed by a processor, the steps of the test case generation method according to any one of claims 1 to 3 are implemented.
Citation Information
Patent Citations
Automatic test system based on scene description and implementation method thereof
CN107783893A
Software testing method and device and computer readable storage medium
CN110874318A