Test case verification method, device, electronic device and storage medium

By initializing the test data of test cases, the problem that existing test cases require frequent changes and maintenance when the test environment changes is changed, the independence and reusability of test cases are achieved, and maintenance costs and debugging difficulties are reduced.

CN114253827BActive Publication Date: 2025-02-14WINNING HEALTH TECHNOLOGY GROUP CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202011017291.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-24
Publication Date
2025-02-14
Estimated Expiration
2040-09-24

AI Technical Summary

Technical Problem

Existing test cases require frequent changes and maintenance when the test environment changes, resulting in a lot of time and a lot of manpower.

Method used

By obtaining test data of test cases and initializing them, the test case operation is reduced by the impact of environment and function changes, and the independence and reusability of test cases are ensured.

Benefits of technology

It reduces the debugging frequency and difficulty of test cases during the testing process, reduces the maintenance costs of personnel, and ensures the correctness of verification results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114253827B_ABST
    Figure CN114253827B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses a test case verification method, device, electronic device and storage medium. The method comprises: when verifying the execution result of at least one test case, obtaining the test data of the at least one test case; initializing the test data; and verifying the execution result based on the initialized test data. In this way, the independence and reusability of the test case are achieved, and the maintenance cost of personnel is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to computer technology, and in particular to a test case verification method, device, electronic device and storage medium. Background Art

[0002] Currently, it is often necessary to use test cases to perform automated testing on data in order to solve the problem that the use case design and use case execution processes are time-consuming and require a lot of manpower.

[0003] At present, the existing test cases are mainly combined with Robot framework and Remote to solve the problem of non-standardized control positioning and solve the requirements for personnel writing capabilities through a three-tier architecture. However, when the currently written test cases are repeatedly executed, the test results will continue to change due to changes in the test environment, which in turn requires repeated changes to the test cases, requiring the test writers to repeatedly maintain the test cases. Summary of the invention

[0004] The embodiments of the present invention provide a test case verification method, device, electronic device and storage medium to achieve the independence and reusability of the test case and reduce the maintenance cost of personnel.

[0005] In a first aspect, an embodiment of the present invention provides a method for verifying a test case, the method comprising:

[0006] When verification of the execution result of at least one test case is detected, obtaining test data of the at least one test case;

[0007] Initializing the test data;

[0008] The execution result is verified based on the initialized test data.

[0009] In a second aspect, an embodiment of the present invention further provides a test case verification device, the device comprising:

[0010] A test data acquisition module, configured to acquire test data of at least one test case when verification of the execution result of at least one test case is detected;

[0011] An initialization module, used for initializing the test data;

[0012] The verification module is used to verify the execution result based on the initialized test data.

[0013] In a third aspect, an embodiment of the present invention further provides an electronic device, the electronic device comprising:

[0014] one or more processors;

[0015] A storage device for storing one or more programs;

[0016] When the one or more programs are executed by the one or more processors, the one or more processors implement the verification method of any test case described in the embodiments of the present invention.

[0017] In a fourth aspect, an embodiment of the present invention further provides a storage medium comprising computer executable instructions, which, when executed by a computer processor, are used to execute the verification method of any test case described in the embodiments of the present invention.

[0018] The technical solution of the embodiment of the present invention obtains the test data of at least one test case and initializes the test data when the execution result of at least one test case is detected to be verified. In this way, the test data in the test case is initialized before the test case is re-executed, which can reduce the impact of the test case operation on the environment and function changes, and ensure the independence and reusability of the test case. Thereby reducing the debugging frequency and difficulty of the test case during the test process, and reducing the maintenance cost of personnel. The execution result is verified using the initialized test data, so as to ensure the correctness of the verification result. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 is a flow chart of a method for verifying a test case in Embodiment 1 of the present invention;

[0020] Figure 2 is a flow chart of a method for verifying a test case in Embodiment 2 of the present invention;

[0021] Figure 3 is a schematic diagram of the structure of a verification device for a test case in Embodiment 3 of the present invention;

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

[0023] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.

[0024] Embodiment 1

[0025] Figure 1This is a flow chart of a test case verification method provided in Embodiment 1 of the present invention. This embodiment is applicable to the case of verifying the execution result of a test case. The method can be executed by a test case verification device. The test case verification device can be implemented by software and / or hardware. The test case verification device can be configured on an electronic computing device, and specifically includes the following steps:

[0026] S110: When it is detected that the execution result of at least one test case is to be verified, obtain test data of the at least one test case.

[0027] Exemplarily, when the system detects that the execution result of the test case needs to be verified, the test data of at least one test case is obtained.

[0028] Specifically, for example, the test case is that Xiao Ming wants to go shopping in a store and buy an item, such as a towel. The execution condition of the test case is: buy a towel. After the test case is executed, the execution result of the test case is: buy a towel. When it is detected that the execution result needs to be verified, the test data of the test case is obtained. The test data here can be, for example, the number of towels purchased.

[0029] S120: Initialize test data.

[0030] Exemplarily, after the test data is acquired, the test data is initialized.

[0031] Optionally, the initializing the test data may specifically include: determining initial environment configuration information of the test case; and initializing the test data based on the initial environment configuration information.

[0032] Exemplarily, the initial environment configuration information may be the environment information when the test case is executed. For example, taking the above example, before Xiao Ming went to the mall to buy towels, he did not buy any other items, so the initial environment configuration information of the test case is that Xiao Ming has no towels in his hand. That is, the number of towels is 0.

[0033] After the initial environment configuration information is obtained, the test data is initialized according to the initial environment configuration information, and specifically, the initial environment configuration information may be configured as the test data. For example, the test data may be initialized to 0.

[0034] S130: Verify the execution result based on the initialized test data.

[0035] Exemplarily, after the test data is initialized, the test case is run again using the initialized test data to verify the above execution result.

[0036] Specifically, continuing the above example, after the test data is initialized to 0, since the execution condition of the test case is: buy a towel, the test case is re-executed using the initialized test data, and the verification result is: buy a towel, which is consistent with the above execution result. This proves that the above test case is correct.

[0037] When verifying the execution result of the test case, the test data in the test case is initialized before re-executing the test case. In this way, there is no need to rewrite the test case to verify the execution result of the test case. It is only necessary to initialize the test data of the test case, which reduces the impact of the test case operation on the environment and function changes, and ensures the independence and reusability of the test case. This reduces the debugging frequency and difficulty of the test case during the test process, and reduces the maintenance cost of personnel.

[0038] Because in the prior art, when verifying the execution result of the test case, if the test data of the test case is not initialized, the verification result of the test case will be affected by the environment, and the verification result obtained will change. For example, taking the above example, when the test case is executed for the first time, the execution result is: bought a towel. To verify the execution result, if the test data is not initialized, the test case is directly re-executed. Since the execution result of the previous test case is: bought a towel, the execution condition is: bought a towel, then when the test case is re-executed, the execution condition will be executed on the basis of the above execution result, so that when the test case is executed again, the verification result is: bought two towels. When the execution result is verified for the second time, the execution condition will be executed again on the basis of the first verification result, and the second verification result is: bought three towels, and so on. In this way, the verification result will be affected by the environment, and an incorrect verification result will be obtained, and the maintenance personnel need to rewrite the test case before verification, resulting in low verification efficiency and increased maintenance costs for personnel.

[0039] It should be noted that when multiple test cases need to be executed, the initial environment configuration information of each test case can be obtained, and the test data can be initialized using the initial environment configuration information. In this way, whether verifying a single or multiple test cases, the unified environment of the test case can be guaranteed when verifying each test case.

[0040] Specifically, for example, Xiao Ming wants to go shopping in a store and buy multiple items. There are 3 test cases. The first test case is to buy a towel, the second test case is to buy a toothbrush based on the first test case, and the third test case is to buy a snack based on the second test case. The execution conditions of the 3 test cases are: buy a towel, buy a toothbrush, buy a snack. After the test cases are executed, the execution results of the test cases are: buy a towel, buy a toothbrush, buy a snack.

[0041] When it is detected that the execution result needs to be verified, it can be verified out of order, and the verification order can be set according to user needs. For example, during verification, the verification order is: the second test case - the first test case - the third test case. Then the test data of the second test case is digitized, for example, initialized to 0, and after executing the second test case again, the execution result is: bought a toothbrush. The verification of the first test case and the third test case is the same as the second test case, and will not be explained here. In this way, when verifying the test case, whether a single or multiple test cases are checked, the test case environment can be unified when verifying each test case. At the same time, the independence of each test case is also guaranteed.

[0042] The technical solution of the embodiment of the present invention obtains the test data of at least one test case and initializes the test data when the execution result of at least one test case is detected to be verified. In this way, the test data in the test case is initialized before the test case is re-executed, which can reduce the impact of the test case operation on the environment and function changes, and ensure the independence and reusability of the test case. Thereby reducing the debugging frequency and difficulty of the test case during the test process, and reducing the maintenance cost of personnel. The execution result is verified using the initialized test data, so as to ensure the correctness of the verification result.

[0043] Embodiment 2

[0044] Figure 2The flowchart of the test case verification method provided in the second embodiment of the present invention can be combined with the various optional schemes in the above embodiments. In the embodiment of the present invention, optionally, before the verification of the execution result of at least one test case is detected, the method further includes: extracting at least one keyword information of the test task according to the acquired test task, and encapsulating the at least one keyword information; splicing the at least one keyword information based on the business logic of the test task to form a business module, and encapsulating the business template; acquiring the data information of the test task, and forming a test case based on the data information and the business module; testing the test case based on the test task to obtain the execution result of the test case. The verification of the execution result based on the initialized test data includes: executing the test case containing the initialized test data to obtain the verification result of the execution result. After the verification of the execution result, the method further includes: comparing the verification result with the execution result, and generating an alarm message when the verification result is inconsistent with the execution result.

[0045] like Figure 2 As shown, the method of the embodiment of the present invention specifically includes the following steps:

[0046] S210. Extract at least one keyword information of the test task according to the acquired test task, and encapsulate the at least one keyword information.

[0047] Exemplarily, the test task may be a task that needs to be tested. For example, the test task is that Xiao Ming wants to go to Sunshine Mall to buy a towel. The test task may be input by a user or obtained from a server or database, which is not limited here.

[0048] The keyword information may be a keyword of a test task. For example, taking the test task that Xiao Ming wants to go to Sunshine Mall to buy a towel as an example, the keywords here are: Xiao Ming, mall, buy, things.

[0049] After obtaining at least one keyword information of the test task, the at least one keyword information of the test task may be packaged.

[0050] S220: Based on the business logic of the test task, at least one keyword information is spliced ​​to form a business module, and the business template is encapsulated.

[0051] Exemplarily, the business logic of the test task can be the processing logic of the test task, that is, the sequence of the test tasks. For example, taking the test task that Xiao Ming wants to go to Sunshine Mall to buy a towel as an example, the business logic of the test task here can be that Xiao Ming first goes to Sunshine Mall and then buys a towel in the mall.

[0052] According to the business logic of the test task, at least one keyword information is spliced ​​to form the business module of the test task. For example, continuing the above example, according to the business logic of the test task, after splicing the keywords: Xiao Ming, shopping mall, buy, and things, the business module formed is: Xiao Ming goes to the shopping mall to buy things. After obtaining the business module of the test task, the business module is encapsulated.

[0053] S230: Acquire data information of the test task, and form a test case based on the data information and the business module.

[0054] Exemplarily, the data information of the test task may be the data of the test task. For example, taking the test task as Xiao Ming going to Sunshine Mall to buy a towel as an example, the data information here is Sunshine Mall and a towel.

[0055] A test case can be formed based on the data information of the test task and the business module obtained above. Specifically, the data information of the test task and the business module obtained above can be combined. For example, continuing the above example, the business module obtained above is Xiao Ming going to the mall to buy something, and the data information is Sunshine Mall, and a towel. The business module and the data information are combined, and the test case obtained is: Xiao Ming goes to Sunshine Mall to buy a towel.

[0056] According to the above steps, accurate test cases can be obtained efficiently.

[0057] S240: Based on the test task, test the test case to obtain the execution result of the test case.

[0058] Exemplarily, according to the test task, the test case is tested, specifically, the test case is run to obtain the execution result of the test case.

[0059] S250: When it is detected that the execution result of at least one test case is to be verified, obtain test data of the at least one test case.

[0060] S260: Initialize the test data.

[0061] S270, executing the test case containing the initialized test data, and obtaining a verification result of the execution result.

[0062] Exemplarily, after the test data is initialized, the test case containing the initialized test data is executed again to obtain a verification result of the execution result.

[0063] In this way, there is no need to rewrite the test cases to verify the execution results of the test cases. It is only necessary to initialize the test data of the test cases, which reduces the impact of the test case operation on the environment and function changes, and ensures the independence and reusability of the test cases. This reduces the debugging frequency and difficulty of the test cases during the test process, and reduces the maintenance cost of personnel.

[0064] S280, comparing the verification result and the execution result, and generating an alarm message when the verification result is inconsistent with the execution result.

[0065] For example, when the execution result is verified and the verification result is obtained, the verification result is compared with the execution result. If the two are consistent, it proves that the execution result is correct; if the two are inconsistent, an alarm message is generated. This can be a very intuitive and clear reminder to the user, so that the user can check the alarm message in time and take corresponding measures for the alarm message.

[0066] Specifically, the alarm information here can be a pop-up dialog box, which displays the alarm content, for example, the verification result is inconsistent with the execution result, please check the test case. In addition, an alarm sound can be generated while the pop-up dialog box is popped up, so as to prompt the user to check the alarm information.

[0067] It should be noted that if the verification result and the execution result are consistent, a corresponding prompt message may also be generated to inform the user that the comparison results of the two are consistent.

[0068] The specific representation form of the specific alarm information and / or the representation form of the prompt information of the consistent comparison result can be set according to the user's needs, and is not limited here. Any form that can be used to prompt the user that the verification result is inconsistent with the execution result and / or the representation form of the prompt information of the consistent comparison result belongs to the protection scope of the present invention.

[0069] The technical solution of the embodiment of the present invention is to extract at least one keyword information of the test task according to the acquired test task, and encapsulate the at least one keyword information; splice the at least one keyword information based on the business logic of the test task to form a business module, and encapsulate the business template; obtain the data information of the test task, and form a test case based on the data information and the business module, so as to efficiently obtain a test case that accurately reflects the test task. After the test data is initialized, the test case containing the initialized test data is executed to obtain the verification result of the execution result. In this way, there is no need to rewrite the test case for verifying the execution result of the test case, and only the test data of the test case needs to be initialized, which reduces the impact of the test case operation on the environment and function changes, ensures the independence of the test case and the reusability of the test case, thereby reducing the debugging frequency and difficulty of the test case during the test process, and reducing the maintenance cost of personnel. Compare the verification result and the execution result, and when the verification result is inconsistent with the execution result, an alarm message is generated, which can be very intuitive and clear to prompt the user, so that the user can check the alarm message in time and take corresponding measures for the alarm message.

[0070] Embodiment 3

[0071] Figure 3 A schematic diagram of the structure of a verification device for a test case provided in Embodiment 3 of the present invention, such as Figure 3 As shown, the device includes: a test data acquisition module 31, an initialization module 32 and a verification module 33.

[0072] The test data acquisition module 31 is used to acquire the test data of the at least one test case when it is detected that the execution result of the at least one test case is verified;

[0073] An initialization module 32, used to initialize the test data;

[0074] The verification module 33 is used to verify the execution result based on the initialized test data.

[0075] Based on the technical solution of the above embodiment, the initialization module 32 includes:

[0076] An initial environment configuration information determining unit, used to determine the initial environment configuration information of the test case;

[0077] An initialization unit is used to initialize the initial test data based on the environment configuration information.

[0078] Based on the technical solution of the above embodiment, the device further includes:

[0079] A keyword information acquisition module, used to extract at least one keyword information of the test task according to the acquired test task, and encapsulate the at least one keyword information;

[0080] A business template acquisition module, used to splice the at least one keyword information based on the business logic of the test task to form a business module, and encapsulate the business template;

[0081] A test case acquisition module, used to acquire data information of a test task, and form the test case based on the data information and the business module;

[0082] The execution result determination module is used to test the test case based on the test task and obtain the execution result of the test case.

[0083] Based on the technical solution of the above embodiment, the verification module 33 is specifically used for:

[0084] Execute the test case containing the initialized test data and obtain the verification result of the execution result.

[0085] Based on the technical solution of the above embodiment, the device further includes:

[0086] The alarm information generating module is used to compare the verification result and the execution result, and generate an alarm information when the verification result is inconsistent with the execution result.

[0087] The test case verification device provided in the embodiment of the present invention can execute the test case verification method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.

[0088] Embodiment 4

[0089] Figure 4 A schematic diagram of the structure of an electronic device provided in Embodiment 4 of the present invention is shown in FIG. Figure 4 As shown, the electronic device includes a processor 70, a memory 71, an input device 72 and an output device 73; the number of processors 70 in the electronic device can be one or more. Figure 4 A processor 70 is taken as an example; the processor 70, the memory 71, the input device 72 and the output device 73 in the electronic device can be connected by a bus or other means. Figure 4 The example of connecting through bus is taken in the following.

[0090] The memory 71, as a computer-readable storage medium, can be used to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to the test case verification method in the embodiment of the present invention (for example, the test data acquisition module 31, the initialization module 32 and the verification module 33). The processor 70 executes various functional applications and data processing of the electronic device by running the software programs, instructions and modules stored in the memory 71, that is, implements the above-mentioned test case verification method.

[0091] The memory 71 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created according to the use of the terminal, etc. In addition, the memory 71 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 71 may further include a memory remotely arranged relative to the processor 70, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0092] The input device 72 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the electronic device. The output device 73 may include a display device such as a display screen.

[0093] Embodiment 5

[0094] Embodiment 5 of the present invention further provides a storage medium comprising computer executable instructions, wherein the computer executable instructions are used to execute a test case verification method when executed by a computer processor.

[0095] Of course, the computer executable instructions of a storage medium containing computer executable instructions provided by an embodiment of the present invention are not limited to the method operations described above, and can also execute related operations in the verification method of the test case provided by any embodiment of the present invention.

[0096] Through the above description of the implementation methods, the technicians in the relevant field can clearly understand that the present invention can be implemented by means of software and necessary general hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for a computer electronic device (which can be a personal computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.

[0097] It is worth noting that in the embodiment of the verification device of the above test case, the various units and modules included are only divided according to functional logic, but are not limited to the above division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.

[0098] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. A test case verification method, characterized in that: include: When verification of the execution result of at least one test case is detected, obtaining test data of the at least one test case; Initializing the test data; Verifying the execution result based on the initialized test data; Before verifying the execution result of at least one test case, the method further includes: Extracting at least one keyword information of the test task according to the acquired test task, and encapsulating the at least one keyword information; Based on the business logic of the test task, the at least one keyword information is spliced ​​to form a business module, and the business module is encapsulated; Acquire data information of the test task, and form the test case based on the data information and the business module; Based on the test task, the test case is tested to obtain the execution result of the test case.

2. The method according to claim 1, characterized in that The initializing the test data includes: Determining initial environment configuration information of the test case; The test data is initialized based on the initial environment configuration information.

3. The method according to claim 1, characterized in that The verifying the execution result based on the initialized test data includes: Execute the test case containing the initialized test data and obtain the verification result of the execution result.

4. The method according to claim 3, characterized in that After verifying the execution result, the method further includes: The verification result and the execution result are compared, and when the verification result is inconsistent with the execution result, an alarm message is generated.

5. A test case verification device, characterized in that: include: A test data acquisition module, configured to acquire test data of at least one test case when verification of the execution result of at least one test case is detected; An initialization module, used for initializing the test data; A verification module, used for verifying the execution result based on the initialized test data; The device also includes: A keyword information acquisition module, used to extract at least one keyword information of the test task according to the acquired test task, and encapsulate the at least one keyword information; A business template acquisition module, used to splice the at least one keyword information based on the business logic of the test task to form a business module, and encapsulate the business module; A test case acquisition module, used to acquire data information of a test task, and form the test case based on the data information and the business module; The execution result determination module is used to test the test case based on the test task and obtain the execution result of the test case.

6. The device according to claim 5, characterized in that The initialization module includes: An initial environment configuration information determining unit, used to determine the initial environment configuration information of the test case; An initialization unit is used to initialize the test data based on the initial environment configuration information.

7. An electronic device, characterized in that: The electronic device comprises: one or more processors; A storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the test case verification method as described in any one of claims 1-4.

8. A storage medium containing computer executable instructions, characterized in that: The computer executable instructions are used to execute the test case verification method as described in any one of claims 1 to 4 when executed by a computer processor.

Citation Information

Patent Citations

  • Testing method and device, testing equipment and storage medium

    CN108228468A