A data testing method and device
By receiving and sorting test cases, processing and encapsulating test cases in different formats, and generating test cases in unified formats, solving the problem of time waste caused by interface diversity and format differences in software testing, improving testing efficiency and compatibility .
Patent Information
- Application Number
- CN202011550379.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-24
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2040-12-24
AI Technical Summary
In software testing, due to the large differences in software interface types, complex structures and different types of software products, full-link functional tests and performance tests require a long time to enter test cases, and the interface formats of different departments are different, which adds The communication and entry time of the tester.
Provide a data testing method, by receiving at least two test cases and determining their test sequence, directly testing test cases in the target format, script analysis and encapsulation of test cases in non-target formats, and generate test cases in a unified format. And generate reports based on test results to reduce manual participation and format conversion time.
It reduces the time for manual repeated participation in manufacturing interface test data, provides use case import function, reduces the time for testers to write use cases, improves testing efficiency and compatibility, and solves cross-departmental and full-link testing efficiency problems.
Smart Images

Figure CN112631914B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of interface automatic testing, and in particular to a data testing method. The present application also relates to a data testing device, a computing device, and a computer-readable storage medium. Background Art
[0002] Software testing is an important stage in the software life cycle and an important means to ensure software quality. In the practice of software testing, it is found that there are many types of software interfaces, complex structures, and large differences in the interfaces of different types of software products. As web services become more complex and systems become larger, the number of test cases required for a complete full-link functional test or performance test has also increased. Due to modular development, full-link testers need to spend more time communicating with various departments and studying the interface test cases of different formats used by various departments. It also takes longer to enter interface test cases. Summary of the invention
[0003] In view of this, an embodiment of the present application provides a data testing method. The present application also relates to a data testing device, a computing device, and a computer-readable storage medium to solve the technical defects existing in the prior art.
[0004] According to a first aspect of an embodiment of the present application, a data testing method is provided, including:
[0005] receiving at least two test cases and determining a test order of the at least two test cases;
[0006] In a case where the at least two test cases include a first test case, testing is performed according to a test order of the first test case, wherein the first test case is in a target format;
[0007] In a case where the at least two test cases include a second test case, selecting a script corresponding to the second test case to encapsulate the second test case into a test case in a target format, and performing the test in a test order of the second test case, wherein the second test case is in a non-target format;
[0008] Generate a test report based on the test results.
[0009] According to a second aspect of an embodiment of the present application, a data testing device is provided, including:
[0010] A receiving module, configured to receive at least two test cases and determine a test order of the at least two test cases;
[0011] A first test module is configured to perform testing according to a test order of a first test case when the at least two test cases include the first test case, wherein the first test case is in a target format;
[0012] A second test module is configured to select a script corresponding to the second test case to encapsulate the second test case into a test case in a target format, and perform testing according to a test sequence of the second test case, when the second test case is included in the at least two test cases, wherein the second test case is in a non-target format;
[0013] The generating module is configured to generate a test report according to the test result.
[0014] According to a third aspect of an embodiment of the present application, a computing device is provided, including:
[0015] Memory, processor:
[0016] The memory is used to store computer executable instructions, and the processor implements the steps of the data testing method when executing the instructions.
[0017] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, which stores computer instructions, and when the instructions are executed by a processor, the steps of the data testing method are implemented.
[0018] The data testing method provided by the present application receives at least two test cases and determines the test order of the at least two test cases; when the at least two test cases include a first test case, the test is performed in accordance with the test order of the first test case, wherein the first test case is in a target format; when the at least two test cases include a second test case, the script corresponding to the second test case is selected to encapsulate the second test case into a test case in a target format, and the test is performed in accordance with the test order of the second test case, wherein the second test case is in a non-target format; and a test report is generated according to the test results. The time for manual repetitive participation in manufacturing interface test data is reduced, and a case import function is provided to reduce the time for testers to write cases. By determining the test order, the time for processing the running order is reduced. The high compatibility of test cases can also be achieved by converting the format, solving the problem of cross-departmental and full-link testing efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 is a flow chart of a data testing method provided by an embodiment of the present application;
[0020] Figure 2It is a processing flow chart of a data testing method applied to payment software provided by an embodiment of the present application;
[0021] Figure 3 It is a structural schematic diagram of a data testing device provided by an embodiment of the present application;
[0022] Figure 4 It is a structural block diagram of a computing device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0023] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present application, so the present application is not limited by the specific implementation disclosed below.
[0024] The terms used in one or more embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of the present application. The singular forms of "a", "said" and "the" used in one or more embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of the present application refers to and includes any or all possible combinations of one or more associated listed items.
[0025] It should be understood that, although the terms first, second, etc. may be used to describe various information in one or more embodiments of the present application, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of the present application, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0026] First, the terms involved in one or more embodiments of the present application are explained.
[0027] Test case: refers to the description of the test task for a specific software product, reflecting the test plan, method, technology and strategy. Its content includes test objectives, test environment, input data, test steps, expected results, test scripts, etc., and finally forms a document. Simply put, a test case is a set of test inputs, execution conditions and expected results compiled for a special goal, used to verify whether a specific software requirement is met.
[0028] Packet capture tool: It is software that intercepts and views the contents of network data packets. Packet capture tools can capture all IP packets in the data communication process and perform layer-by-layer unpacking and analysis.
[0029] Script: (Script) is an executable file written in a specific descriptive language and according to a certain format.
[0030] Next, the basic concept of the data testing method provided in this specification is briefly described.
[0031] In the prior art, when testing software, it is all based on modular testing, which requires full-link testers to spend a long time communicating with various departments. Due to the large number of software interface types, complex structures, and a large number of test cases, testers also need to study the interface test cases of different formats used by various departments, which causes testers to spend a longer time entering interface test cases.
[0032] In response to this situation, the present application invents a data testing method with format compatibility function. First, each department imports its own test cases in turn. Then, use the packet capture tool to record the manual full-link operations. Automatically sort the imported test cases according to the recorded interface request sequence. Subsequently, by judging the format of the test case, use the script to parse the encapsulation parameters such as the request method, request body, context, etc. and store them in the database. Then assemble the encapsulation parameters stored in the database into a unified pytest format test case. Finally, generate a test report and distribute it to each department. The use of the format compatibility feature can reduce the time for full-link testers to enter test cases, greatly improving the efficiency, coverage and accuracy of the test.
[0033] In the present application, a data testing method is provided. The present application also relates to a data testing device, a computing device, and a computer-readable storage medium, which are described in detail one by one in the following embodiments.
[0034] Figure 1 A flow chart of a data testing method provided according to an embodiment of the present application is shown, which specifically includes the following steps:
[0035] Step 102: Receive at least two test cases and determine a test order of the at least two test cases.
[0036] Specifically, a test case refers to a test case for a software product that is imported by various departments through an automated testing platform; a test sequence refers to the order in which all test cases for a software product are executed based on the analysis of the test case.
[0037] In actual applications, the automated testing platform interface will display an information box for logging into the platform. Testers can log into the automated testing platform by entering their account number, password, verification code, and other information and clicking the login button. After successfully logging in, the tester clicks the test button and creates a new test plan. At this point, the preliminary preparations for data testing are completed.
[0038] Further, on the basis of the test plan being created, each department imports test cases through the interfaces used by each department in turn, and the formats of the test cases include postman format, har format, json format, jmx format, pytest format, etc., that is, receiving at least two test cases. Afterwards, the test order of the at least two test cases is determined according to the actual situation.
[0039] In the present application, at least two test cases are received through different interfaces, so as to determine the test order of the at least two test cases, thereby laying a foundation for ensuring the smooth testing of the test cases and the fast and efficient testing process.
[0040] Furthermore, the specific implementation process of determining the test order of the at least two test cases may be as follows:
[0041] The test order of the at least two test cases is determined according to the interface for receiving the at least two test cases and the order of the interface requests.
[0042] Specifically, the interface for receiving the at least two test cases may include a login interface, a payment interface, a logout interface, etc.; the interface request sequence refers to the sequence of requesting the login interface, the payment interface, and the logout interface according to a certain request. Generally speaking, after clarifying the interface request sequence and the test interface, the execution sequence for the test, i.e., the test sequence, can be determined.
[0043] For example, there are three test cases: test case A, test case B and test case C, where the receiving interface of test case A is the payment interface, the receiving interface of test case B is the logout interface, and the receiving interface of test case C is the login interface. In addition, the order of interface requests is: the first request is the login interface, the second request is the payment interface, and the third request is the logout interface. It can be determined that the test order of these three test cases is: first test case C, second test case A, and third test case B.
[0044] In practical applications, before receiving the interfaces and the interface request sequence of the at least two test cases, it is also necessary to confirm the interface request sequence, and the specific implementation process can be as follows:
[0045] Use the packet capture tool to record the manual full-link operation and obtain the interface request information.
[0046] The interface request information is parsed to determine the interface request sequence.
[0047] Specifically, the packet capture tool can be Fiddler packet capture software or other packet capture software, which is not limited in this application; the manual full-link operation refers to simulating user operations such as clicking and inputting. Generally speaking, the manual full-link operation is recorded through the Http packet capture tool, and then the har file carrying the interface request information is exported. The har file can be unsealed to obtain the interface request information. On this basis, the interface request information is parsed to determine the interface request order.
[0048] For example, by using Fiddler packet capture software to record manual full-link operations, interface request information is obtained and parsed to obtain the order in which the first request is the login interface, the second request is the payment interface, and the third request is the logout interface.
[0049] In this application, the interface request order is determined by a packet capture tool, and on this basis, the test order of the test cases is determined in combination with the interface for receiving the test cases. In this way, the execution order of the test cases for a specific software application can be determined according to different test cases and different interface request orders, which is more adaptable.
[0050] Step 104: When the at least two test cases include a first test case, testing is performed according to a test sequence of the first test case, wherein the first test case is in a target format.
[0051] Specifically, the test order of the first test case refers to the order of a test case in the target format in the entire data test. For example, if test case A is in the target format and its test order is 3, then the third test case to be tested is test case A. On the basis of receiving at least two test cases and determining the test order of the at least two test cases, further, in the case that the at least two test cases include the first test case, the first test case in the target format is tested according to the test order of the first test case.
[0052] In practical applications, the target format is the default format of the automated testing platform, or a format manually set and specified in the automated testing platform. For the test case that is consistent with the format specified by the automated testing platform, that is, the first test case, no other operations are required and it can be reserved for testing. When it is the turn of the first test case to be tested, the first test case is tested.
[0053] For example, on the basis that the target format is pytest format, the platform receives three test cases, test case A, test case B and test case C, wherein test case A is in pytest format, test case B is in json format, and test case C is in postman format. When the test sequence of the test cases is determined to be test case C-test case A-test case B, no operation is performed on test case A, and after the test case C is tested, test case A is directly tested.
[0054] In the present application, the test cases in the target format are tested in the test order of the test cases in the target format, which reduces the processing pressure of the platform during data testing and can improve the speed of data testing to a certain extent.
[0055] Step 106, when the at least two test cases include a second test case, select a script corresponding to the second test case to encapsulate the second test case into a test case in a target format, and perform testing according to the test sequence of the second test case, wherein the second test case is in a non-target format.
[0056] Specifically, the test order of the second test case refers to the order of a test case in a non-target format in the entire data test. For example, if test case B is in a non-target format and its test order is 2, then the second test case to be tested is test case B. For test cases in non-target formats, since their formats are different from the platform-specified or default formats, if the test cases in non-target formats are tested directly, not only will there be extremely high requirements on the processing capabilities of the platform, but also testers will need to spend a lot of time recording and coordinating the various interfaces for testing. Therefore, it is necessary to convert the test cases in non-target formats into test cases in target formats, that is, to encapsulate the second test cases into test cases in target formats, and then test the test cases in target formats according to the test order of the test cases.
[0057] For example, two test cases are received: test case A and test case B, where test case A is in jmx format and test case B is in pytest format, and pytest format is the target format. If the test order is to test test case A first and then test case B, then select the script corresponding to the jmx file to parse test case A to obtain the encapsulation parameters of test case A, and then encapsulate test case A into test case A' in pytest format according to the encapsulation parameters; no operation is performed on test case B. After that, start testing test case A' and then test case B.
[0058] It should be noted that step 104 and step 106 are not a simple sequence. For the received test cases, the test cases in the target format are not processed; the test cases in non-target formats can be encapsulated at the same time, or they can be encapsulated in sequence according to the order in which the test cases are received. After all the test cases in non-target formats are encapsulated as test cases in the target format, all the test cases are integrated and tested in the test sequence. Alternatively, the received test cases are encapsulated and tested in the test sequence, and for the test cases in the target format, that is, the first test case, the encapsulation process is ignored and tested directly.
[0059] For example, three test cases are received: test case A, test case B, and test case C, of which only test case B is in the target format, and the test order is: test case A-test case B-test case C. Test case B is not processed first, while test case A and test case C need to be packaged: test case A and test case C can be packaged at the same time, or test case A can be packaged first in the order of receipt to obtain test case A', and then test case C can be packaged to obtain test case C'. At this time, all test cases are in the target format, and test case A', test case B, and test case C' are tested in the test order. Alternatively, the order of the test cases can be directly followed: first, test case A is packaged to obtain test case A' and tested; second, since test case B is in the target format, it does not need to be packaged, and test case B is directly tested; finally, test case C is packaged to obtain test case C' and tested.
[0060] Specifically, the implementation process of selecting the script corresponding to the second test case to encapsulate the second test case into a test case in a target format may be:
[0061] determining a format of the second test case;
[0062] selecting a script corresponding to the second test case according to the format of the second test case;
[0063] Parsing the second test case through the script and obtaining encapsulation parameters;
[0064] The second test case is packaged into a test case in a target format based on the packaging parameters.
[0065] In actual applications, multiple types of scripts are stored locally in advance. Each script can parse a test case in a format, such as script A can parse a test case in format a, and script B can parse a test case in format b. Therefore, before selecting the script corresponding to the second test case, it is necessary to first determine the format of the second test case. On this basis, a matching script is selected according to the format of the second test case. The script is called to parse the second test case to obtain the encapsulation parameters of the second test case, and then the encapsulation parameters are encapsulated according to the preset target format to form a test case in the target format, that is, the second test case is encapsulated as a test case in the target format.
[0066] In order to encapsulate the second test case in the non-target format into a test case in the target format, it is necessary to parse the second test case through the script and obtain encapsulation parameters. The specific implementation process is as follows:
[0067] Parsing the second test case through the script;
[0068] Locating the encapsulation parameters in the parsing result according to the keywords;
[0069] Delete the keywords and separators in the parsing result, obtain the encapsulation parameters of the second test case and store them in the database.
[0070] Specifically, the keywords include "method", "url", "headers", "cookies", and may also include other keywords. First, parse the second test case by running the script corresponding to the second test case, and obtain the parsing result of the second test case. Regardless of the format of the test case, its encapsulation parameters include encapsulation parameters in fixed formats such as request method, request address, request header, request body, etc. Therefore, for the parsing result of the second test case, the position of the encapsulation parameters in the parsing result can be located by searching for keywords such as "method", "url", "headers", "cookies", etc. After successful positioning, delete unnecessary information other than the encapsulation parameters in the parsing result, that is, delete the keywords and separators in the parsing result, thereby separating the encapsulation parameters of the second test case, and storing the encapsulation parameters of the second test case.
[0071] In the present application, the second test case is parsed, and the encapsulation parameters of the second test case are finally obtained according to the keywords, thereby preparing for the subsequent encapsulation of the second test case based on the encapsulation parameters.
[0072] Further, after obtaining the encapsulation parameters of the second test case, the second test case is encapsulated based on the encapsulation parameters to convert it into a test case in a target format. The specific implementation process is as follows:
[0073] Read the database to obtain the encapsulation parameters of the second test case;
[0074] The encapsulation parameters are stored in corresponding positions in the target format model framework to generate test cases in the target format.
[0075] Specifically, the database is specifically used to store encapsulation parameters. Generally speaking, when encapsulating, it is necessary to retrieve the corresponding encapsulation parameters from the database, that is, read the database to obtain the encapsulation parameters of the second test case. After obtaining the encapsulation parameters, fill them into the corresponding positions in the target format model framework, and then a test case in the target format is generated, that is, the encapsulation of the second test case in the non-target format is completed.
[0076] Furthermore, before storing the encapsulation parameters into the corresponding position in the target format model framework, the target format model framework needs to be created. The specific implementation process is as follows:
[0077] A target format model framework is created, wherein the target format model framework includes a keyword, wherein a position for storing encapsulation parameters corresponding to the keyword is reserved after the keyword.
[0078] Specifically, a target format model framework is created according to the target format, that is, the target format model framework is different for different target formats. The target format model framework includes keywords and reserved encapsulation parameter positions. The target format model framework can be: "keyword 1 () keyword 2 () keyword 3 () keyword 4 ()...", or it can be: "keyword 1 keyword 2 keyword 3 keyword 4..." and other forms.
[0079] For example, there are four keywords, namely: "method", "url", "headers", and "cookies". The target format model framework constructed can be: method()url()headers()cookies(). If the encapsulation parameters of the second test case read from the database are: request method A, request address B, request header C, and request body D, then fill the request method A, request address B, request header C, and request body D into the target format model framework, and the test case in the target format is: method(request method A)url(request address B)headers(request header C)cookies(request body D).
[0080] In addition, in order to facilitate testers to download test cases in the target format for further extended testing, the method also provides a download function, and the implementation process may be: receiving a test case download request in the target format, and feeding back the test case in the target format.
[0081] The present application fills the obtained encapsulation parameters of the second test case into a pre-established target format model framework, so that all test cases can be quickly encapsulated into a unified format, thereby improving the convenience and ease of use of data testing.
[0082] Step 108: Generate a test report based on the test results.
[0083] Specifically, on the basis of testing all test cases in the target format according to the test sequence of the test cases, further, the test results are obtained, and a test report is generated according to the test results, wherein the test report may be an allure test report.
[0084] In practical applications, allure test reports can be generated based on allure-pytest. Among them, generating an allure test report can be divided into two parts, the first part is to generate test report data, and the second part is to generate a test report page. After the test report is generated, the test report is distributed to the department corresponding to this full-link test, that is, the test results are fed back according to the interface for receiving test cases. In this way, the test results are directly fed back to each department, eliminating the cumbersome procedures for testers to communicate with each department, and it is also convenient for each department to obtain the test results in a timely manner for subsequent analysis.
[0085] The data testing method provided by the present application receives at least two test cases and determines the test order of the at least two test cases; when the at least two test cases include a first test case, the test is performed in accordance with the test order of the first test case, wherein the first test case is in a target format; when the at least two test cases include a second test case, the script corresponding to the second test case is selected to encapsulate the second test case into a test case in a target format, and the test is performed in accordance with the test order of the second test case, wherein the second test case is in a non-target format; and a test report is generated according to the test results. The time for manual repetitive participation in manufacturing interface test data is reduced, and a case import function is provided to reduce the time for testers to write cases. By determining the test order, the time for processing the running order is reduced. The high compatibility of test cases can also be achieved by converting the format, solving the problem of cross-departmental and full-link testing efficiency.
[0086] The following combination Figure 2, taking the application of the data testing method provided by this application in payment software testing as an example, the data testing method is further described. Figure 2 A processing flow chart of a data testing method applied to payment software provided by an embodiment of the present application is shown, which specifically includes the following steps:
[0087] Step 202: Log in to the interface automation testing platform.
[0088] In actual applications, testers can log in to the automated testing platform by entering their account and password, or by using their account and verification code, and create a test plan for payment software X.
[0089] Step 204: import test cases in any format.
[0090] Specifically, the test case refers to the test case for payment software X imported by each department through the automated testing platform. On the basis of the creation of the test plan, each department imports the test case in turn, wherein the format of the test case can be postman format, har format, json format, jmx format, pytest format, etc.
[0091] Step 206: Record the manual operation and determine the test sequence of the test case.
[0092] The test order refers to the order of execution of the three test cases determined based on the analysis of the test cases. Specifically, the manual full-link operation is recorded through the Fiddler packet capture software, the interface request information of the payment software is obtained, the interface request information of the payment software is parsed, and the interface request order is determined. Generally speaking, the manual full-link operation is recorded through the Fiddler packet capture software, and then the har file carrying the interface request information is exported. The har file can be unsealed to obtain the interface request information. On this basis, the interface request information is parsed to obtain the interface request order: the first request is the login interface, the second request is the payment interface, and the third request is the logout interface. Furthermore, the test order of the test case can be determined according to the interface for receiving the test case and the interface request order.
[0093] Specifically, for payment software X, the test case interfaces include a login interface, a payment interface, and a logout interface, and the interface request sequence is: login interface, payment interface, and logout interface. At this time, the order of testing the test cases can be determined based on the interfaces imported by the test cases and the interface request sequence.
[0094] For example, three test cases are imported, namely, test case 1, test case 2 and test case 3, where the receiving interface of test case 1 is the payment interface, the receiving interface of test case 2 is the logout interface, and the receiving interface of test case 3 is the login interface. According to the interface request sequence, the test order of the three test cases is determined, that is, the first test is test case 3, the second test is test case 1, and the third test is test case 2.
[0095] In this application, test cases are received through different interfaces to determine the test order of the test cases, which lays a foundation for ensuring the smooth progress of the test of payment software X and the fast and efficient testing process. In this application, the interface request order is determined by Fiddler packet capture software, and on this basis, the test order of the test cases is determined in combination with the interface for receiving the test cases. In this way, the execution order of the test cases of payment software X can be determined according to different test cases and different interface request orders, which is more adaptable.
[0096] Step 208, determine the format of the test case and run the corresponding script to obtain packaging parameters.
[0097] Specifically, for the test cases in pytest format, since they are already test cases in the target format, there is no need to operate them; for the test cases in other formats, since their formats are non-target formats, the platform cannot directly test the test cases in other formats. The formats of the test cases in other formats are determined respectively, and the corresponding scripts are selected to parse the test cases in other formats and obtain the encapsulation parameters, which are stored in the database.
[0098] For example, for test case A in json format, select the script corresponding to the json file to parse test case A to obtain the encapsulation parameters of test case A, and store the parameters in the repository; for test case B in jmx format, select the script corresponding to the jmx file to parse test case B to obtain the encapsulation parameters of test case B, and store the parameters in the repository.
[0099] Furthermore, the specific implementation process of running the corresponding script for the test case in other formats to obtain the encapsulation parameters is as follows:
[0100] Select the scripts corresponding to other formats to parse the test cases in other formats;
[0101] Locating encapsulation parameters in the parsing results of the test cases in other formats according to the keywords;
[0102] The keywords and separators in the parsing results of the test cases in other formats are deleted, and the encapsulation parameters of the test cases in other formats are obtained and stored in the database.
[0103] Specifically, the keywords include "method", "url", "headers", and "cookies". First, according to the format of the test case in other formats, the corresponding script is selected to parse the test case, and the parsing result of the test case in other formats is obtained. The position of the encapsulation parameters in the parsing result of the test case in other formats is located by searching for keywords such as "method", "url", "headers", and "cookies", and unnecessary information other than the encapsulation parameters in the parsing result of the test case in other formats is deleted, so as to separate the encapsulation parameters of the test case in other formats, and store the encapsulation parameters of the test case in other formats.
[0104] In this application, by parsing the test cases in other formats in the test cases, and finally obtaining the encapsulation parameters of the test cases in other formats according to the keywords, a foundation is prepared for the subsequent encapsulation of the test cases in other formats based on the encapsulation parameters.
[0105] Step 210, uniformly encapsulate the test cases into pytest format.
[0106] Based on the encapsulation parameters, the test cases in other formats are encapsulated into test cases in pytest format, and the test cases in pytest format are tested according to the test order of the other formats. First, the database is read to obtain the encapsulation parameters of the test cases in other formats, and the encapsulation parameters of the test cases in other formats are filled in the corresponding positions in the pytest format model framework.
[0107] Specifically, when encapsulating, it is necessary to retrieve the corresponding encapsulation parameters from the database, that is, read the database, obtain the encapsulation parameters of the test cases in other formats, and fill them into the corresponding positions in the pytest format model framework, so as to generate the test cases in the pytest format. Before that, it is also necessary to create the pytest format model framework. The specific implementation process is as follows:
[0108] A pytest format model framework is created, wherein the pytest format model framework includes keywords, wherein a position for storing encapsulation parameters corresponding to the keywords is reserved after the keywords.
[0109] This application obtains the encapsulation parameters of test cases in other formats and fills them into the pre-established pytest format model framework, so that all non-pytest format test cases can be quickly encapsulated into pytest format, thereby improving the convenience and ease of use of data testing.
[0110] In addition, in order to facilitate testers to download test cases in pytest format for further extended testing, the method also provides a download function, and the implementation process can be: receiving a test case download request in pytest format and feeding back the test case in pytest format.
[0111] Step 212: Run the test case in pytest format in the entire link.
[0112] For all test cases, when you know that all test cases are in pytest format, test all pytest format test cases in the test order of the test cases. For example, there are three test cases: test case 1, test case 2, and test case 3. Assume that the test order is test case 2, test case 1, and test case 3, where test case 2 and test case 3 are in other formats. You can first encapsulate test case 2 and test case 3 to get test case 2 in pytest format and test case 3 in pytest format, and then test them in the order of test case 2 in pytest format, test case 1, and test case 3 in pytest format.
[0113] Step 214, generating an allure test report.
[0114] Specifically, on the basis of testing all pytest format test cases in the test order of the test cases, further, the test results are obtained, and the allure test report is generated according to the test results. In practical applications, the allure test report can be generated based on allure-pytest.
[0115] Step 216, distribute the test report to each department.
[0116] After the test report is generated, it is distributed to each department that imported the test case, that is, the test result is fed back according to the interface for receiving the test case. In this way, the test result is directly fed back to each department, eliminating the tedious procedures of the tester communicating with each department, and it is also convenient for each department to obtain the test result in time for subsequent analysis.
[0117] The data testing method provided by this application includes: logging into the interface automation testing platform; importing test cases in any format; recording manual operations to determine the test order of test cases; judging the format of test cases and running the corresponding scripts to obtain encapsulation parameters; uniformly encapsulating test cases in pytest format; running test cases in pytest format throughout the entire link; generating allure test reports; and distributing test reports to various departments. It reduces the time for manual repetitive participation in manufacturing interface test data, and provides a use case import function to reduce the time for testers to write use cases. By determining the test order, it reduces the time for processing the running order. It can also achieve high compatibility of test cases by converting the format, solving the problem of cross-departmental and full-link testing efficiency.
[0118] Corresponding to the above method embodiment, the present application also provides a data testing device embodiment, Figure 3 FIG. 1 is a schematic diagram showing the structure of a data testing device provided by an embodiment of the present application. Figure 3 As shown, the device comprises:
[0119] The receiving module 302 is configured to receive at least two test cases and determine a test order of the at least two test cases;
[0120] A first test module 304 is configured to perform testing according to a test order of a first test case when the at least two test cases include the first test case, wherein the first test case is in a target format;
[0121] The second test module 306 is configured to select a script corresponding to the second test case to encapsulate the second test case into a test case in a target format, and perform the test in a test order of the second test case when the at least two test cases include the second test case, wherein the second test case is in a non-target format;
[0122] The generating module 308 is configured to generate a test report according to the test result.
[0123] The receiving module 302 is further configured to determine a test order of the at least two test cases according to the interfaces and the interface request order of the at least two test cases received.
[0124] The device also includes:
[0125] The processing module is configured to record the manual full-link operation through a packet capture tool, obtain the interface request information, parse the interface request information, and determine the interface request order.
[0126] The second test module 306 is also configured to determine the format of the second test case, select a script corresponding to the second test case according to the format of the second test case, parse the second test case through the script and obtain encapsulation parameters, and encapsulate the second test case into a test case in a target format based on the encapsulation parameters.
[0127] The second test module 306 is further configured to parse the second test case through the script, locate the encapsulation parameters in the parsing result according to keywords, delete the keywords and separators in the parsing result, obtain the encapsulation parameters of the second test case and store them in the database.
[0128] The second test module 306 is further configured to read the database, obtain the encapsulation parameters of the second test case, store the encapsulation parameters into corresponding positions in the target format model framework, and generate a test case in the target format.
[0129] The device also includes:
[0130] The creation module is configured to create a target format model framework, wherein the target format model framework includes a keyword, wherein a position for storing encapsulation parameters corresponding to the keyword is reserved after the keyword.
[0131] The feedback module is configured to feed back the test result according to the interface receiving the test case.
[0132] The data testing device provided by the present application includes a receiving module, which is configured to receive at least two test cases and determine the test order of the at least two test cases; a first test module, which is configured to select a script corresponding to the second test case to encapsulate the second test case into a test case in a target format when the at least two test cases include the second test case, and test it according to the test order of the second test case, wherein the second test case is in a non-target format; a second test module, which is configured to select a script corresponding to the second test case to encapsulate the second test case into a test case in a target format when the at least two test cases include the second test case, and test it according to the test order of the second test case, wherein the second test case is in a non-target format; a generating module, which is configured to generate a test report according to the test results. The time for manual repeated participation in manufacturing interface test data is reduced, and a case import function is provided to reduce the time for testers to write cases, and by determining the test order, the time for processing the running order is reduced, and the high compatibility of test cases can be achieved by converting the format, solving the problem of cross-departmental and full-link test efficiency.
[0133] The above is a schematic scheme of a data testing device of this embodiment. It should be noted that the technical scheme of the data testing device and the technical scheme of the above data testing method belong to the same concept, and the details not described in detail in the technical scheme of the data testing device can be referred to the description of the technical scheme of the above data testing method.
[0134] Figure 4 The block diagram of a computing device 400 according to an embodiment of the present application is shown. The components of the computing device 400 include but are not limited to a memory 410 and a processor 420. The processor 420 is connected to the memory 410 via a bus 430, and the database 450 is used to store data.
[0135] The computing device 400 also includes an access device 440 that enables the computing device 400 to communicate via one or more networks 460. Examples of these networks include a public switched telephone network (PSTN), a local area network (LAN), a wide area network (WAN), a personal area network (PAN), or a combination of communication networks such as the Internet. The access device 440 may include one or more of any type of network interface (e.g., a network interface card (NIC)) wired or wireless, such as an IEEE 802.11 wireless local area network (WLAN) wireless interface, a World Wide Interoperability for Microwave Access (Wi-MAX) interface, an Ethernet interface, a universal serial bus (USB) interface, a cellular network interface, a Bluetooth interface, a near field communication (NFC) interface, and the like.
[0136] In one embodiment of the present application, the above components of the computing device 400 and Figure 4 Other components not shown in the figure may also be connected to each other, for example, via a bus. It should be understood that Figure 4 The computing device structure block diagram shown is only for the purpose of illustration, and is not intended to limit the scope of the present application. Those skilled in the art may add or replace other components as needed.
[0137] Computing device 400 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., a tablet computer, a personal digital assistant, a laptop computer, a notebook computer, a netbook, etc.), a mobile phone (e.g., a smart phone), a wearable computing device (e.g., a smart watch, smart glasses, etc.), or other types of mobile devices, or a stationary computing device such as a desktop computer or PC. Computing device 400 may also be a mobile or stationary server.
[0138] The processor 420 is used to execute the following computer executable instructions:
[0139] receiving at least two test cases and determining a test order of the at least two test cases;
[0140] In a case where the at least two test cases include a first test case, testing is performed according to a test order of the first test case, wherein the first test case is in a target format;
[0141] In a case where the at least two test cases include a second test case, selecting a script corresponding to the second test case to encapsulate the second test case into a test case in a target format, and performing the test in a test order of the second test case, wherein the second test case is in a non-target format;
[0142] Generate a test report based on the test results.
[0143] The above is a schematic scheme of a computing device of this embodiment. It should be noted that the technical scheme of the computing device and the technical scheme of the above data testing method belong to the same concept, and the details not described in detail in the technical scheme of the computing device can be referred to the description of the technical scheme of the above data testing method.
[0144] An embodiment of the present application further provides a computer-readable storage medium storing computer instructions, which, when executed by a processor, implement the steps of the data testing method as described above.
[0145] The above is a schematic scheme of a computer-readable storage medium of this embodiment. It should be noted that the technical scheme of the storage medium and the technical scheme of the above data testing method belong to the same concept, and the details not described in detail in the technical scheme of the storage medium can be referred to the description of the technical scheme of the above data testing method.
[0146] The above describes specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0147] The computer instructions include computer program codes, which may be in source code form, object code form, executable files or some intermediate forms, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium, etc. It should be noted that the content contained in the computer-readable medium may be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0148] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity of description, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
[0149] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0150] The preferred embodiments of the present application disclosed above are only used to help explain the present application. The optional embodiments do not describe all the details in detail, nor do they limit the invention to the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of the present application. The present application selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present application, so that those skilled in the art can understand and use the present application well. The present application is only limited by the claims and their full scope and equivalents.
Claims
1. A data testing method, It is characterized in that include: receiving at least two test cases and determining a test order of the at least two test cases; In a case where the at least two test cases include a first test case, testing is performed according to a test order of the first test case, wherein the first test case is in a target format; In the case where the at least two test cases include a second test case, a script corresponding to the second test case is selected to encapsulate the second test case into a test case in a target format, and the test is performed according to the test sequence of the second test case, wherein the second test case is in a non-target format, the target format is a default format of the automated testing platform, or a manually set format specified in the automated testing platform, and the target format is obtained by filling the encapsulation parameters of the obtained second test case into a pre-established target format model framework; Generate a test report based on the test results; Among them, the selecting a script corresponding to the second test case to encapsulate the second test case into a test case in a target format includes: determining the format of the second test case; selecting a script corresponding to the second test case according to the format of the second test case; parsing the second test case through the script and obtaining a parsing result, locating the encapsulation parameters in the parsing result according to keywords, deleting keywords and separators in the parsing result, obtaining the encapsulation parameters of the second test case and storing them in a database; encapsulating the second test case into a test case in a target format based on the encapsulation parameters.
2. The method according to claim 1, It is characterized in that Determining the test order of the at least two test cases includes: The test order of the at least two test cases is determined according to the interface for receiving the at least two test cases and the order of the interface requests.
3. The method according to claim 2, It is characterized in that Before receiving the interfaces and the interface request sequence of the at least two test cases, the method further comprises: Use the packet capture tool to record the manual full-link operation and obtain the interface request information. The interface request information is parsed to determine the interface request sequence.
4. The method according to claim 1, It is characterized in that The step of encapsulating the second test case into a test case in a target format based on the encapsulation parameter includes: Read the database to obtain the encapsulation parameters of the second test case; The encapsulation parameters are stored in corresponding positions in the target format model framework to generate test cases in the target format.
5. The method according to claim 4, It is characterized in that Before storing the encapsulation parameters into the corresponding position in the target format model framework, the method further includes: A target format model framework is created, wherein the target format model framework includes a keyword, wherein a position for storing encapsulation parameters corresponding to the keyword is reserved after the keyword.
6. The method according to claim 1, It is characterized in that After generating the test report according to the test results, the following steps are included: Feedback the test results based on the interface that receives the test cases.
7. A data testing device, It is characterized in that include: A receiving module, configured to receive at least two test cases and determine a test order of the at least two test cases; A first test module is configured to perform testing according to a test order of a first test case when the at least two test cases include the first test case, wherein the first test case is in a target format; The second test module is configured to select a script corresponding to the second test case to encapsulate the second test case into a test case in a target format when the at least two test cases include the second test case, and to test the second test case in a test order of the second test case, wherein the second test case is in a non-target format, and the target format is a default format of the automated testing platform, or a manually set format specified in the automated testing platform, and the target format is obtained by filling the obtained encapsulation parameters of the second test case into a pre-established target format model framework, wherein the selecting of the script corresponding to the second test case to encapsulate the second test case into a test case in a target format comprises: determining the format of the second test case; selecting a script corresponding to the second test case according to the format of the second test case; parsing the second test case through the script and obtaining a parsing result, locating the encapsulation parameters in the parsing result according to keywords, deleting keywords and separators in the parsing result, obtaining the encapsulation parameters of the second test case and storing them in a database; encapsulating the second test case into a test case in a target format based on the encapsulation parameters; The generating module is configured to generate a test report according to the test result.
8. A computing device comprising a memory, a processor, and computer instructions stored in the memory and executable on the processor, It is characterized in that When the processor executes the instructions, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium storing computer instructions. It is characterized in that When the instruction is executed by a processor, the steps of the method described in any one of claims 1 to 6 are implemented.
10. A computer program product, It is characterized in that The method comprises computer instructions, which, when executed by a processor, implement the steps of the data testing method according to any one of claims 1 to 6.
