A business testing method and system
By adding response assertions and adjusting parameters to script files in business testing, the error problem caused by business changes in automatically generated script files is solved, automated testing is realized, regression testing workload is reduced, and test reliability is improved.
Patent Information
- Application Number
- CN202111242483.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-25
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2041-10-25
AI Technical Summary
During the software development process, the parameter information in the script files automatically generated during the business testing process will change with business changes, causing the direct execution of unprocessed script files to fail to successfully perform business operations, and when testers change or the business is rapidly iterated, Regression testing requires a lot of time and is difficult to cover all business operations.
By adding response assertions to the script file, verify whether there is an error message during the execution process, and adjust the business parameters until no errors are reported, and generate a test script file that matches the test case to ensure the normal operation and automated testing of the script file.
It implements automated test script files for business operations, reduces testers' regression testing workload, improves test reliability and quality, and avoids error reporting problems caused by business changes.
Smart Images

Figure CN113886269B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software testing, and in particular to a business testing method and system. Background Art
[0002] The statements in this section merely provide background information related to the present invention and do not necessarily constitute prior art.
[0003] During the software development process, due to the complexity of software functions and the different business scenarios they target, in order to ensure the performance of the software, it is necessary to test the business functions of the software product under different businesses.
[0004] At present, the business testing process is carried out by users. Each business to be tested requires testers to understand the business and design corresponding test models based on their understanding of the business. However, given the numerous and complex businesses, this will create a huge workload for testers. Moreover, the test model relies on the tester's understanding of the business. When the tester changes, the new tester has to understand the business again, and it is difficult to cover all operations included in the smart catering business. When the business iterates rapidly, testers need to spend a lot of time and energy on regression testing.
[0005] Furthermore, when executing new business operations or repeating business operations, the parameter information contained in the automatically generated script file needs to be manually changed. Moreover, if the script file is directly executed without parameter processing, the corresponding business operation cannot be successfully executed and an error message will be displayed. Summary of the invention
[0006] In order to solve the above problems, the present invention proposes a business testing method and system. To address the problem that the corresponding business operation cannot be successfully executed due to directly executing an unprocessed script file, the script file is pre-executed and the execution process is verified through response assertions to ensure that a test script file is obtained that will not report an error and can run normally.
[0007] In order to achieve the above object, the present invention adopts the following technical solution:
[0008] In a first aspect, the present invention provides a service testing method, comprising:
[0009] Get script files related to business operations based on test cases;
[0010] Add response assertion to the script file, execute the script file, and verify whether there is any error message during the execution process through response assertion. If there is an error message, adjust the business parameters in the script file until there is no error message, and obtain a test script file that matches the test case;
[0011] Use the test script file to test the business operation and obtain the test results.
[0012] As an optional implementation, the process of adding a response assertion to a script file includes, the script file includes response information corresponding to the business operation, selecting a string in the response information, defining the selected string as verification information for successful execution of the business operation, and adding it to the script file as a response assertion.
[0013] As an optional implementation, when executing a script file, the required business parameters are analyzed. The script file includes response information corresponding to the business operation. Based on the parameter comparison of the previous business operation and the next business operation, the required business parameters are extracted from the response information, and when executing the business operation, the business parameters are directly called.
[0014] As an optional implementation method, the execution process of verifying the response assertion includes executing the script file, determining whether the response assertion has error information, and if so, adjusting the business parameters of the script file based on the comparison between the actual response information and the response assertion, and verifying the response assertion again, until the response information after the execution contains the corresponding response assertion and no error information.
[0015] As an optional implementation, the process of testing business operations with a test script file includes executing the test script file, determining whether there are any exceptions that are inconsistent with expectations during the test process, and if so, issuing an alarm and recording the execution results of the test script file.
[0016] As an optional implementation, the execution result includes the response time, the number of abnormal errors, and the cause of the abnormal errors of each business operation.
[0017] As an optional implementation, in the process of obtaining script files related to business operations based on test cases, only the test cases based on which the script files are generated for the first time cover all business operations. When the business is updated, the test cases based on which the script files are updated only cover the newly added business operations.
[0018] In a second aspect, the present invention provides a service testing system, comprising:
[0019] A script generation module is configured to obtain a script file related to the business operation according to the test case;
[0020] The script analysis and processing module is configured to add a response assertion to the script file, execute the script file, and verify whether there is an error message during the execution process through the response assertion. If there is an error message, the business parameters in the script file are adjusted until there is no error message, thereby obtaining a test script file that matches the test case;
[0021] The business testing module is configured to test the business operation with a test script file to obtain a test result.
[0022] In a third aspect, the present invention provides an electronic device comprising a memory and a processor, and computer instructions stored in the memory and executed on the processor, wherein when the computer instructions are executed by the processor, the method described in the first aspect is performed.
[0023] In a fourth aspect, the present invention provides a computer-readable storage medium for storing computer instructions, wherein when the computer instructions are executed by a processor, the method described in the first aspect is performed.
[0024] Compared with the prior art, the present invention has the following beneficial effects:
[0025] Since the parameter information contained in the automatically generated script file is recorded according to the current actual business operation and is the real value of the current business operation, when a new business operation is performed again or the same business operation is executed, these parameter information will change, so an error will occur, resulting in the inability to continue the business execution; therefore, in order to address the problem that directly executing an unprocessed script file cannot successfully execute the corresponding business operation, the present invention provides a business testing method and system, in which the script file is pre-executed, and the execution process is verified through response assertions to ensure that a test script file is obtained that will not report an error and can run normally.
[0026] The present invention provides a business testing method and system, which can construct an automated test script file for the business operation of a software product. When the business is iterating rapidly, the workload of the tester for regression testing can be reduced, and a large amount of time can be avoided from being spent on inefficient and repetitive work. When the tester changes, the problem that the new tester is unfamiliar with the business and thus cannot cover all the business when testing the business can be avoided, thereby ensuring the quality of the test and improving the reliability of the test.
[0027] Advantages of additional aspects of the present invention will be given in part in the following description, and in part will become obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] The accompanying drawings in the specification, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.
[0029] Figure 1 A schematic diagram of a service testing method flow chart provided in Example 1 of the present invention;
[0030] Figure 2 This is a schematic diagram of the business test system structure provided in Example 2 of the present invention. DETAILED DESCRIPTION
[0031] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0032] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present invention. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present invention belongs.
[0033] It should be noted that the terms used herein are only for describing specific embodiments, and are not intended to limit exemplary embodiments according to the present invention. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that the terms "include" and "have" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0034] In the absence of conflict, the embodiments of the present invention and the features of the embodiments may be combined with each other.
[0035] Example 1
[0036] According to the problems described in the background technology, this embodiment takes the smart catering business as an example. At present, when performing functional testing on the smart catering business, the test model is established through the tester's understanding of the business. However, due to the complexity of the smart catering business, a huge workload is generated for the tester, and the test model depends on the tester's understanding of the business. When the tester changes, it is difficult for the new tester to cover all the operations included in the smart catering business. And when the smart catering business is iterated quickly, the tester needs to spend a lot of time and energy on regression testing. Based on this, this embodiment provides a business testing method, such as Figure 1 As shown, including:
[0037] S1: Automatically generate business-related script files based on test cases;
[0038] S2: Analyze and process the script file according to the test case to obtain a test script file that matches the test case;
[0039] S3: Test the business according to the test script file that matches the test case and output the test results.
[0040] An automated test script file can be built to cover the main operations of the smart catering business. When the business is iterating rapidly, the workload of testers for regression testing can be reduced, and a large amount of time can be avoided from being spent on inefficient and repetitive work. When there are changes in testers, the problem of new testers not being able to cover all business operations during testing due to their unfamiliarity with the business can be avoided, thereby ensuring the quality of the test and improving the reliability of the test.
[0041] Various non-limiting implementations of the present application are described in detail below in conjunction with the accompanying drawings.
[0042] In the step S1, in the process of automatically generating a script file according to the test case, the business operations performed according to the test case are recorded to automatically generate the script file;
[0043] It is particularly noted that the test case used when executing step S1 for the first time covers all major operations. When step S1 is executed again due to business iteration, the test case used only covers the major operations included in the newly added business.
[0044] It should be noted that the script file at this time cannot be used directly and needs further processing;
[0045] The reason is: the parameter information contained in the automatically generated script file is recorded according to the current actual business operation, so these parameter information records the real value of the current business operation; however, when a new business operation is performed again or the same business operation is executed, these parameter information will change, so an error will occur, resulting in the inability to continue the business execution; that is, directly executing the unprocessed script file cannot successfully execute the corresponding business operation, so these parameter information need to be processed, so that each time a new business operation is executed or the same business operation is executed, that is, when the script file is executed, the real and valid parameter information required for the current business operation can be automatically obtained according to the actual business operation, without having to manually change the parameter information each time.
[0046] Therefore, in step S2, the process of analyzing and processing the script file that cannot be used directly includes: analyzing the test case represented by each record in the script file, analyzing the business parameters that need to be processed in the record, executing the script file, and verifying the basic script file obtained after execution by adding a response assertion to verify whether the script file under the current business parameters can be executed normally. If an error is reported, the business parameters are adjusted until there is no error in the execution process, and a test script file matching the test case is obtained.
[0047] In step S2, the process of analyzing the service parameters to be processed in the record includes:
[0048] During the first business operation, the operation process is recorded and a script file is generated. The script file records the request information, response information, information header and other information of each operation;
[0049] According to the request information, response information, information header and other information of the previous operation, the request information, response information, information header and other information of the next operation are compared to obtain the parameters required in each business operation;
[0050] Use regular expressions to extract the required parameter information from request information, response information, or information headers, and name each parameter as a variable. When performing other business operations, you can directly call the variable. When performing various business operations, you can automatically obtain response information based on the request information, and then use regular expressions to extract the parameter information at the corresponding position from the response information or information header, and name it as a variable. When other business operations need it, you can directly call the parameter information represented by the variable.
[0051] In step S2, the process of verifying the basic script file through the response assertion includes: the script file recorded when executing the business operation also includes request information, response information, information header and other information, so each business operation will have corresponding response information, and a special string content is selected in the response information, which represents the verification information of the success of the business operation, and is added to each business operation as a response assertion;
[0052] Execute the script file to determine whether the response assertion has any error information. If there is an error message, compare the response assertion with the actual response information, adjust the parameters of the script file, and verify the response assertion again until the response information of each operation has the corresponding response assertion set and there is no error message, then generate a test script file.
[0053] In step S3, the test script file is executed to simulate the business operations matching the test case, and the simulated business operations are tracked and tested to determine whether there are any exceptions that are inconsistent with expectations during the test process. If there are any exceptions, an alarm is issued and the execution results of all business operations simulated by the test script are recorded;
[0054] The execution result includes information such as the response time, number of abnormal errors, and causes of abnormal errors of each business operation.
[0055] In this embodiment, step S2 is to generate a basic script file, ensure that when the script file is executed alone, the parameters in the script file are automatically generated and valid, and verify that the basic script file can be executed normally, that is, a basic script file is generated that will not report an error and can run normally; however, this process does not have the ability to perform complex operations such as aggregation, statistics, and similar concurrent execution;
[0056] Step S3 is to actually execute the test script file, record, summarize and count the response time, number of abnormal errors, causes of abnormal errors, etc. in the script file. At this time, there is no need to adjust the business parameters in step S2; at the same time, the business parameters required for the actual test case can be further adjusted according to the actual test case, so as to achieve the purpose of realizing the special test case.
[0057] Example 2
[0058] like Figure 2 As shown, this embodiment provides a service testing system, including:
[0059] The script generation module 10 is used to automatically generate business-related script files according to the test cases;
[0060] The script analysis and processing module 20 is used to analyze and process the automatically generated script file to obtain a test script file that matches the test case.
[0061] The service testing module 30 is used to test the service using a test script file that matches the test case and output the test result.
[0062] It should be noted that the above modules correspond to the steps described in Example 1, and the examples and application scenarios implemented by the above modules and the corresponding steps are the same, but are not limited to the contents disclosed in the above Example 1. It should be noted that the above modules, as part of the system, can be executed in a computer system such as a set of computer executable instructions.
[0063] Preferably, the script generation module 10 comprises: a recording unit 101 for recording business operations executed according to test cases and automatically generating script files.
[0064] Preferably, the script analysis processing module 20 includes:
[0065] The analyzing unit 201 is used to analyze the test case represented by each record in the script file and analyze the business parameters that need to be processed in the record;
[0066] Processing unit 202, used for processing the business parameters of each record in the script file;
[0067] A verification unit 203 is used to add a response assertion to verify whether the script file that has processed the business parameters can be executed normally;
[0068] The generating unit 204 is used to generate a test script file.
[0069] Preferably, the service testing module 30 includes:
[0070] The simulation unit 301 is used to execute the test script file to simulate the business operation matching the test case;
[0071] The judging unit 302 is used to perform a tracking test on the simulated business operation and judge whether there are any exceptions that are inconsistent with expectations during the test process;
[0072] An alarm unit 303 is used to issue an alarm prompt when the judgment unit finds that the simulated business operation is abnormal and inconsistent with expectations;
[0073] The summarizing unit 304 is used to record the execution results of all business operations simulated by the test script, wherein the execution results include information such as the response time, the number of abnormal errors, and the cause of the abnormal errors of each business.
[0074] The test system described in this embodiment, when testing a business, first, automatically generates a script file according to the business operations executed by the test case; then, analyzes the test case represented by each record in the script file, analyzes the business parameters that need to be processed in the record, processes the business parameters that need to be processed in the record, and then adds a response assertion to verify the execution process, and finally obtains a test script file that matches the test case; finally, executes the test script file, simulates the business operations that match the test case, performs a tracking test on the simulated business operations, determines whether there are any exceptions that are inconsistent with expectations during the test process, and issues an alarm prompt for the exception, and finally records the execution results of all business operations simulated by the test script, wherein the execution results include information such as the response time, the number of exception errors, and the cause of the exception errors for each business operation.
[0075] In further embodiments, there is also provided:
[0076] An electronic device includes a memory and a processor, and computer instructions stored in the memory and executed on the processor, wherein when the computer instructions are executed by the processor, the method described in Embodiment 1 is performed. For the sake of brevity, it will not be described in detail here.
[0077] It should be understood that in this embodiment, the processor may be a central processing unit CPU, and the processor may also be other general-purpose processors, digital signal processors DSP, application-specific integrated circuits ASIC, off-the-shelf programmable gate arrays FPGA or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0078] The memory may include a read-only memory and a random access memory, and provide instructions and data to the processor. A portion of the memory may also include a non-volatile random access memory. For example, the memory may also store information about the device type.
[0079] A computer-readable storage medium is used to store computer instructions, and when the computer instructions are executed by a processor, the method described in Example 1 is completed.
[0080] The method in Example 1 can be directly embodied as a hardware processor, or a combination of hardware and software modules in the processor. The software module can be located in a mature storage medium in the field such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware. To avoid repetition, it is not described in detail here.
[0081] Those skilled in the art will appreciate that the units, i.e., algorithm steps, of the various examples described in conjunction with this embodiment can be implemented in electronic hardware or in a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0082] Although the above describes the specific implementation mode of the present invention in conjunction with the accompanying drawings, it is not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art on the basis of the technical solution of the present invention without creative work are still within the scope of protection of the present invention.
Claims
1. A business testing method, It is characterized in that include: Get script files related to business operations based on test cases; The parameter information contained in the automatically generated script file is recorded according to the current actual business operation, so these parameter information records the real value of the current business operation; however, when a new business operation is performed again or the same business operation is executed, these parameter information will change, so an error will occur, resulting in the inability to continue the business execution; That is, directly executing an unprocessed script file cannot successfully execute the corresponding business operation. Therefore, it is necessary to process these parameter information so that each time a new business operation or the same business operation is executed, that is, when the script file is executed, the real and valid parameter information required for the current business operation can be automatically obtained according to the actual business operation, without having to manually change the parameter information each time; Add response assertion to the script file, execute the script file, and verify whether there is any error message during the execution process through response assertion. If there is an error message, adjust the business parameters in the script file until there is no error message, and obtain a test script file that matches the test case; Specifically: according to the test case, the script file is analyzed and processed to obtain a test script file that matches the test case; wherein, the test case represented by each record in the script file is analyzed, the business parameters that need to be processed in the record are analyzed, the script file is executed, and the basic script file obtained after the execution is verified by adding a response assertion to verify whether the basic script file under the current business parameters can be executed normally. If there is an error, the business parameters are adjusted until there is no error in the execution process, and a test script file that matches the test case is obtained; The process of analyzing the business parameters that need to be processed in the record includes: During the first business operation, the operation process is recorded and a script file is generated. The script file records the request information, response information and information header of each operation; the request information, response information and information header of the previous operation are compared with the request information, response information and information header of the next operation to obtain the parameters required in each business operation; Use regular expressions to extract the required parameter information from the request information, response information, or information header, and name each parameter as a variable. When performing other business operations, you can directly call the variable, so that when performing various business operations, you can automatically obtain the response information based on the request information, and then use regular expressions to extract the parameter information at the corresponding position from the response information or information header, and name it as a variable. When other business operations need it, you can directly call the parameter information represented by the variable; The process of verifying the basic script file through the response assertion includes: the script file recorded when executing the business operation also includes request information, response information and information header, so each business operation will have corresponding response information, and a special string content is selected in the response information to represent the verification information of the success of the business operation, and is added to each business operation as a response assertion; Execute the script file to determine whether the response assertion has error information. If there is error information, compare the response assertion with the actual response information, adjust the parameters of the script file, and verify the response assertion again until the response information of each operation has the corresponding response assertion and there is no error information. Then generate a test script file; When executing the script file, the required business parameters are analyzed. The script file includes the response information corresponding to the business operation. According to the parameter comparison between the previous business operation and the next business operation, the required business parameters are extracted from the response information, and the business parameters are directly called when executing the business operation. Use the test script file to test the business operation and obtain the test results.
2. A service testing method as claimed in claim 1, It is characterized in that The process of adding a response assertion to a script file includes: the script file includes response information corresponding to a business operation; a character string is selected from the response information; the selected character string is defined as verification information for successful execution of the business operation; and the character string is added to the script file as a response assertion.
3. A service testing method as claimed in claim 1, It is characterized in that The execution process of response assertion verification includes executing the script file, determining whether the response assertion has error information, and if so, adjusting the business parameters of the script file based on the comparison between the actual response information and the response assertion, and verifying the response assertion again, until the response information after execution contains the corresponding response assertion and no error information.
4. A service testing method as claimed in claim 1, It is characterized in that The process of testing business operations with a test script file includes executing the test script file, determining whether there are any exceptions that are inconsistent with expectations during the test process, and if there are any exceptions, issuing an alarm prompt and recording the execution results of the test script file.
5. A service testing method as claimed in claim 4, It is characterized in that The execution results include the response time, number of abnormal errors, and causes of abnormal errors for each business operation.
6. A service testing method as claimed in claim 1, It is characterized in that In the process of obtaining script files related to business operations based on test cases, only the test cases based on which the script files are generated for the first time cover all business operations. When the business is updated, the test cases based on which the script files are updated only cover the newly added business operations.
7. A service testing system based on the method according to any one of claims 1 to 6, It is characterized in that include: A script generation module is configured to obtain a script file related to the business operation according to the test case; The script analysis and processing module is configured to add a response assertion to the script file, execute the script file, and verify whether there is an error message during the execution process through the response assertion. If there is an error message, the business parameters in the script file are adjusted until there is no error message, thereby obtaining a test script file that matches the test case; The business testing module is configured to test the business operation with a test script file to obtain a test result.
8. An electronic device, It is characterized in that The method comprises a memory and a processor and computer instructions stored in the memory and executed on the processor, wherein when the computer instructions are executed by the processor, the method according to any one of claims 1 to 6 is completed.
9. A computer-readable storage medium, It is characterized in that Used to store computer instructions, which, when executed by a processor, complete the method described in any one of claims 1 to 6.
