Method, system, medium and equipment for constructing mass test data based on Web API (Application Program Interface)
Through the design requirements manual and combining Web API interfaces and testing equipment, a large amount of test data is automatically constructed, which solves the problems of inefficiency and low accuracy of existing test methods, and achieves efficient and accurate test data construction.
Patent Information
- Application Number
- CN202411496599.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-25
- Publication Date
- 2025-02-18
AI Technical Summary
When constructing large amounts of test data, existing testing methods are inefficient and cannot guarantee the authenticity of test data, which affects the quality and efficiency of software testing.
Through designing requirements instructions, analyzing business scenarios, combining relevant Web API interfaces and test equipment, using test equipment to run API interfaces, and automatically constructing a large amount of test data.
It realizes the rapid construction of large amounts of test data, improves testing efficiency, and enhances the accuracy of test results.
Smart Images

Figure CN119473881A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data testing, and in particular to a method, system, medium and device for constructing a large amount of test data based on a Web API. Background Art
[0002] The importance of software testing is unquestionable. However, how to complete the test in the shortest time with the least manpower and resource investment, discover the defects of the software system, and ensure the excellent quality of the software is the goal explored and pursued by software companies. Every software product or software development project needs a set of excellent testing plans and testing methods. There are many factors that affect software testing, such as the complexity of the software itself, the quality of developers (including analysis, design, programming and testing personnel), the use of testing methods and technologies, etc. Because some factors are objective and cannot be avoided. Some factors are fluctuating and unstable, such as the development team is mobile, experienced people leave, and new people are constantly added; a specific person's work is also affected by emotions, etc. How to ensure the stability of software testing quality? With test cases, no matter who comes to test, the quality of the test can be guaranteed by referring to the test cases. The impact of human factors can be minimized. Even if the initial test cases are not well considered, they will become more and more perfect as the test progresses and the software version is updated.
[0003] When executing test cases for platform projects, it is often necessary to verify the correctness of a certain function when the business data reaches a certain amount. For example, the maximum number of records required for the delivery address on the mall webpage is 30. When the 31st item is added, the addition fails and there will be a reasonable prompt message. When executing such test cases, you need to first add 30 address records, then add the 31st item to the page, and verify the added results and the returned prompt information. For another example, when executing the test case for the page turning function, according to the maximum number of records displayed on one page, construct test data that meets the test requirements, which may be 50, 100, or 200. The existing test method is to execute test cases manually. In the manual execution of test cases, there is a need to add one by one through page operations. This method not only has low test efficiency, but also cannot guarantee the absolute authenticity of the test data.
[0004] In view of this, it is necessary to provide a method, system, medium and device for constructing a large amount of test data based on Web API. Summary of the invention
[0005] The present invention provides a method, system, medium and device for constructing a large amount of test data based on Web API, which effectively solves the problems of low test efficiency and low test accuracy of existing test data.
[0006] The technical solution adopted by the present invention is
[0007] The method of constructing a large amount of test data based on Web API includes the following steps:
[0008] S1. Design requirements specification;
[0009] S2, test case text based on the design requirements specification in S1;
[0010] S3, determining whether the preset data of the test case is greater than the preset value;
[0011] S4. If it is determined that the preset data of the test case text is not greater than the preset value, the process ends; if it is determined that the preset data of the test case text is greater than the preset value, the amount of test data is confirmed, and then the relevant API interface is matched, and the test equipment is transferred to run the API interface, and the required large amount of test data is obtained through the operation of the API interface.
[0012] Furthermore, the method for matching the relevant API interface in step S4 is to obtain the API interface address link, http protocol, input parameter name from the Web page, and record whether the parameter has mandatory or unique restrictions.
[0013] Furthermore, when the test device runs the API interface in step S4, the test device needs to obtain the API interface address link, http protocol, input parameter name and parameter content.
[0014] Furthermore, the input parameters are required parameters to ensure that a correct test record can be generated.
[0015] Furthermore, when the test device runs the API interface in step S4, the test device obtains the number of cycles according to the number of records to be generated, and can construct a number of records that meets the requirements.
[0016] Furthermore, the requirement specification in step S1 includes the requirements to be implemented in this test and the functional framework of the system to be tested.
[0017] Furthermore: the test cases include the full set of functional test points to be tested in this requirement, and each test case contains the case number, title, preconditions, operation steps, expected results, execution results, and notes; each case must clearly specify the test tools to be used and the data information to be constructed in advance; the design of test cases must comply with the software quality model and use the test case design method.
[0018] A system that constructs a large amount of test data based on Web API, including:
[0019] Requirements entry module, used to enter requirements specifications;
[0020] Test case output module, used to output test case text;
[0021] A test evaluation module to determine whether a test requires a large number of tests;
[0022] The test module is used to confirm the amount of test data, then match the relevant API interface, Jmeter runs the API interface, and transfers it to the test device to run the API interface.
[0023] A computer-readable storage medium stores a computer program, which, when processed and executed, implements the steps of the method for constructing a large amount of test data based on Web API.
[0024] A computer device comprises a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus:
[0025] The memory is used to store computer programs;
[0026] The processor is used to execute the steps of the method for constructing a large amount of test data based on Web API by running the program stored in the memory. As an embodiment of the present invention, the communication bus mentioned in the above terminal can be a peripheral component interconnect standard (Peripheral Component Interconnect, referred to as PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, referred to as EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc.
[0027] As an implementation mode of the present invention, the communication interface is used for communication between the above-mentioned terminal and other devices.
[0028] As an embodiment of the present invention, the memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0029] As an embodiment of the present invention, the above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
[0030] The beneficial effects of the invention are as follows: for test cases that need to construct a large amount of test data, by designing a requirement specification and analyzing the business scenario, starting from the test case, combining relevant API interfaces and test equipment, inputting parameters, outputting results, and using the test equipment to run the API interface, a large amount of test data can be quickly constructed, which can not only effectively improve the test efficiency, but also further ensure the accuracy of the test results. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] Figure 1 A flowchart of a method for constructing a large amount of test data based on a Web API provided in an embodiment of the present application. DETAILED DESCRIPTION
[0032] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0033] like Figure 1 As shown, the present application provides a first embodiment, which is a method for constructing a large amount of test data based on Web API, comprising the following steps:
[0034] S1. Design requirements specification;
[0035] S2, test case text based on the design requirements specification in S1;
[0036] S3, determining whether the preset data of the test case is greater than the preset value;
[0037] S4. If it is determined that the preset data of the test case text is not greater than the preset value, the process ends; if it is determined that the preset data of the test case text is greater than the preset value, the amount of test data is confirmed, and then the relevant API interface is matched, and the test equipment is transferred to run the API interface, and the required large amount of test data is obtained through the operation of the API interface.
[0038] It should be noted that preset data refers to the pre-loading or setting of necessary data before the system or application is officially used to ensure the normal operation of the system and the consistency of the data. This process may include steps such as data cleaning, formatting, classification, and pre-loading to ensure that the system can immediately access the data when it starts. For example, in a development environment, preset data may include pre-prepared data sets that can be used directly in the development process without real-time generation or acquisition from external sources, thereby improving development efficiency and data availability. In addition, preset data can also include system configuration parameters, default values, etc., all of which are intended to optimize the initial state of the system and user experience.
[0039] In actual use, if the maximum number of records required for the delivery address on a shopping mall webpage is 30, then adding the 31st record will fail. In such a test scenario, 29 delivery address records need to be constructed, and then the 30th and 31st records need to be added from the page to verify whether they meet the expected results. Then the 29 delivery addresses can be quickly generated using the method of quickly constructing a large amount of test data based on Web API in this article. After generating the data, you can test the new scenario by viewing the delivery address page on the page. If there is a subsequent query that needs to verify whether the page turning operation is correct, this method can also be used to quickly generate 50 or 100 records on a page.
[0040] In the above design, for test cases that need to construct a large amount of test data, by designing the requirements specification and analyzing the business scenario, starting from the test case, combining the relevant API interface and test equipment, inputting parameters, outputting results, and using the test equipment to run the API interface, a large amount of test data can be quickly constructed. The number of data required and the number of threads input during execution can quickly form the test data that meets the conditions. This can not only effectively improve the test efficiency, but also further ensure the accuracy of the test results.
[0041] Specifically: the method for matching the relevant API interface in step S4 is: obtaining the API interface address link, http protocol, input parameter name from the web page, and recording whether the parameter is required or unique.
[0042] In the above design, the API interface address link, http protocol, input parameter name are obtained from the web page, and whether the parameters are required or unique can be recorded to create test conditions.
[0043] Specifically: when the test device runs the API interface in step S4, the test device needs to obtain the API interface address link, http protocol, input parameter name and parameter content.
[0044] In the above design, a test record is generated after obtaining the API interface address link, HTTP protocol, input parameter name and parameter content.
[0045] Specifically: The input parameters are required parameters to ensure that a correct test record can be generated.
[0046] In the above design, the input parameters are required parameters, which can ensure the accuracy of test record generation and ensure that the test records cover a wide range.
[0047] Specifically: when the test device runs the API interface in step S4, the test device obtains the number of cycles according to the number of records to be generated, and can construct the number of records that meet the requirements.
[0048] In the above design, by obtaining the number of cycles, which may be 30 times, 50 times, 100 times or other numbers, after the test equipment obtains the number of cycles, the data is recorded by entering the number of cycles into the system.
[0049] Specifically: the requirements specification in step S1 includes the requirements to be achieved in this test and the functional framework of the system to be tested
[0050] It should be noted that when designing a requirements specification, testers need to establish a requirements evaluation system from the company's perspective, and also analyze the feasibility of the requirements from the user's perspective and the development perspective, and sort out test cases based on the priority of the requirements.
[0051] In the above design, the requirements specification can concisely express the test requirements and sort out the test functions.
[0052] Specifically: the test cases include the full set of functional test points to be tested in this requirement. Each test case contains the case number, title, preconditions, operation steps, expected results, execution results, and notes; each test case must clearly specify the test tools to be used and the data information to be constructed in advance; the design of test cases must comply with the software quality model and use the test case design method.
[0053] It should be noted that the software quality model includes: functionality: suitability, accuracy, interoperability, confidentiality and security, and functionality compliance; reliability: maturity, marketability, recoverability, and reliability compliance; usability: understandability, learnability, operability, attractiveness, and usability compliance; efficiency: time characteristics, resource characteristics, and efficiency compliance; maintainability: ease of analysis, ease of change, stability, ease of testability, and maintainability compliance; portability: adaptability, ease of installation, coexistence, replaceability, and portability compliance.
[0054] In the above design, the design of test cases facilitates the verification of data testing methods to ensure that the testing methods can work correctly.
[0055] The present application also provides a second embodiment, which is a system for constructing a large amount of test data based on Web API, including:
[0056] The requirement entry module is used to enter the requirement specifications.
[0057] The test case output module is used to output the test case text.
[0058] The test evaluation module is used to determine whether the test requires a large number of tests.
[0059] The test module is used to confirm the amount of test data, then match the relevant API interface, Jmeter runs the API interface, and transfers it to the test device to run the API interface.
[0060] The present application also provides a third embodiment, which is a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is processed and executed, the steps of the method for constructing a large amount of test data based on the Web API are implemented.
[0061] In addition, the computer-readable storage medium of this embodiment may adopt any combination of one or more computer-readable storage media, wherein the computer-readable storage medium includes electrical, optical, electromagnetic, infrared or semiconductor systems, devices or components, or any combination thereof.
[0062] The present application also provides a fourth embodiment, which is a computer device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus:
[0063] The memory is used to store computer programs;
[0064] The processor is used to execute the steps of the method for constructing a large amount of test data based on Web API by running the program stored in the memory.
[0065] As an embodiment of the present invention, the communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc.
[0066] As an implementation mode of the present invention, the communication interface is used for communication between the above-mentioned terminal and other devices.
[0067] As an embodiment of the present invention, the memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0068] As an embodiment of the present invention, the above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components.
[0069] To further explain in detail, it should be understood that the above is only a specific embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for constructing a large amount of test data based on Web API, characterized in that: The following steps are included: S1. Design requirements specification; S2. Write test case text based on the design requirements specification in S1; S3, determining whether the preset data of the test case is greater than the preset value; S4. If it is determined that the preset data of the test case text is not greater than the preset value, the process ends; if it is determined that the preset data of the test case text is greater than the preset value, the amount of test data is confirmed, and then the relevant API interface is matched, and the test equipment is transferred to run the API interface, and the required large amount of test data is obtained through the operation of the API interface.
2. The method for constructing a large amount of test data based on Web API according to claim 1, characterized in that: The method for matching the relevant API interface in step S4 is: obtaining the API interface address link, http protocol, input parameter name from the Web page, and recording whether the parameter has mandatory or unique restrictions.
3. The method for constructing a large amount of test data based on Web API according to claim 1, characterized in that: When the test device runs the API interface in step S4, the test device needs to obtain the API interface address link, http protocol, input parameter name and parameter content.
4. The method for constructing a large amount of test data based on Web API according to claim 2, characterized in that: The input parameters are required parameters to ensure that a correct test record can be generated.
5. The method for constructing a large amount of test data based on Web API according to claim 1, characterized in that: When the test device runs the API interface in step S4, the test device obtains the number of cycles according to the number of records to be generated, and can construct the number of records that meet the requirements.
6. The method for constructing a large amount of test data based on Web API according to claim 1, characterized in that: The requirement specification in step S1 includes the requirements to be implemented in this test and the functional framework of the system to be tested.
7. The method for constructing a large amount of test data based on Web API according to claim 1, characterized in that: The test cases include the full set of functional test points to be tested in this requirement. Each test case includes the case number, title, preconditions, operation steps, expected results, execution results, and remarks. Each use case should clearly specify the test tools to be used and the data information to be constructed in advance; The design of test cases should comply with the software quality model and apply the test case design method.
8. A system for constructing large amounts of test data based on Web API, characterized by: include, Requirements entry module, used to enter requirements specifications; Test case output module, used to output test case text; A test evaluation module to determine whether a test requires a large number of tests; The test module is used to confirm the amount of test data, then match the relevant API interface, Jmeter executes the API interface, and transfers it to the test device to execute the API interface.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is processed and executed, the steps of the method for constructing a large amount of test data based on Web API according to any one of claims 1 to 7 are implemented.
10. A computer device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus: The memory is used to store computer programs; The processor is used to execute the steps of the method for constructing a large amount of test data based on Web API according to any one of claims 1 to 7 by running the program stored in the memory.