A unit test method, device, electronic equipment and storage medium
By pre-registering the parameter description information of the method under test and dynamically generating operation styles in the visual interface, the problem of manually writing code in existing unit tests is solved, and efficient unit testing without code is achieved.
Patent Information
- Application Number
- CN202110742023.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-30
- Publication Date
- 2026-02-27
- Estimated Expiration
- 2041-06-30
AI Technical Summary
Existing unit testing tools require developers to write code manually, resulting in low testing efficiency and the need to modify the code multiple times to adapt to different functional tests.
By pre-registering the parameter description information of the method under test, the system dynamically generates parameter operation styles, receives parameter values submitted by users on the visual interface, and obtains the response information of the method under test for correctness verification, thus realizing no-code unit testing.
Users can perform multiple tests in a visual interface without writing code, improving testing efficiency and convenience.
Smart Images

Figure CN115543769B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and more specifically to a unit testing method, apparatus, electronic device, and storage medium. Background Technology
[0002] Currently, software is used more and more widely in various industries, so software stability is increasingly valued by developers. Therefore, developers have introduced unit testing into the existing software development process. Unit testing tests a program unit implemented from source code to check whether each program module correctly implements the specified functions.
[0003] There are already many tools available for unit testing development, such as JUnit for Java and gtest for C++. However, these tools still require developers to manually write unit test code, which takes up a lot of time in software development. Moreover, developers need to input different parameters for the methods and modify the code multiple times. Therefore, traditional unit testing solutions suffer from low testing efficiency. Summary of the Invention
[0004] The purpose of this invention is to address the shortcomings of the prior art by providing a unit testing method, apparatus, electronic device, and storage medium, which is achieved through the following technical solutions.
[0005] A first aspect of the present invention provides a unit testing method, the method comprising:
[0006] Obtain parameter description information of the pre-registered method to be tested;
[0007] Dynamically generate parameter operation styles on the specified page based on the parameter description information;
[0008] Receive parameter values submitted by the user on the specified page;
[0009] The response information of the method under test is obtained based on the parameter values for correctness verification.
[0010] In some embodiments of this application, the method further includes a registration process for the method under test: receiving registration information of the method under test submitted by a user on a preset registration page, the registration information including basic information, access path information, and parameter description information; detecting whether the registration information is correct; if correct, storing the registration information in a database.
[0011] In some embodiments of the present application, the parameter description information of the pre-registered to-be-tested method is acquired by reading the basic information of the to-be-tested method from the database, and the related description of the to-be-tested method is displayed in a specified page according to the basic information; and when a trigger command of the to-be-tested method is received in the specified page, the parameter description information of the to-be-tested method is read from the database.
[0012] In some embodiments of the present application, the parameter operation style of each parameter in the parameter description information is dynamically generated on the specified page according to the name, type and candidate list of the parameter.
[0013] In some embodiments of the present application, the parameter operation style of each parameter in the parameter description information is dynamically generated on the specified page according to the name, type and candidate list of the parameter.
[0014] In some embodiments of the present application, the parameter value submitted by the user on the specified page is received by detecting whether the submitted parameter value is correct according to the parameter description information; if correct, the step of calling the to-be-tested method based on the parameter value to obtain response information is executed; and if incorrect, a parameter exception prompt is returned to the specified page.
[0015] In some embodiments of the present application, the response information of the to-be-tested method is obtained based on the parameter value by reading the access path information of the to-be-tested method from the database, generating a call request according to the parameter value, the access path information and the parameter description information, and sending the call request to obtain the response information of the to-be-tested method.
[0016] In some embodiments of the present application, after the response information of the to-be-tested method is obtained based on the parameter value, the method further comprises: displaying the response information to check whether the response information is correct by the user.
[0017] A second aspect of the present application provides a unit testing device, the device comprising:
[0018] A first acquisition module is configured to acquire parameter description information of a pre-registered to-be-tested method.
[0019] A dynamic generation module is configured to dynamically generate a parameter operation style in a specified page according to the parameter description information.
[0020] The parameter submission module is used to receive parameter values submitted by the user on the specified page;
[0021] The second acquisition module is used to acquire the response information of the method under test based on the parameter value for correctness verification.
[0022] A third aspect of the present invention provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, performs the steps of the method described in the first aspect above.
[0023] A fourth aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method described in the first aspect above.
[0024] Based on the unit testing method and apparatus described in the first and second aspects above, the present invention has at least the following beneficial effects or advantages:
[0025] Users pre-register the necessary information for the method under test. When testing is needed, the parameter descriptions of the method under test can be retrieved from the registered information, and parameter operation styles for the method under test can be generated in a visual interface. This maps the method under test to the front-end visual interface, allowing users to easily input parameter values and initiate unit tests. The testing process is simple and convenient for users, requiring no coding. Furthermore, users can freely change parameter values and conduct multiple tests within the visual interface without modifying the code. Therefore, this solution employs no-code unit testing, which improves testing efficiency. Attached Figure Description
[0026] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this invention, illustrate exemplary embodiments of the invention and are used to explain the invention, but do not constitute an undue limitation of the invention. In the drawings:
[0027] Figure 1 This is a flowchart illustrating an embodiment of a unit testing method according to an exemplary embodiment of the present invention;
[0028] Figure 2A This is a schematic diagram illustrating a registration process for a method under test according to an exemplary embodiment of the present invention;
[0029] Figure 2B According to the present invention Figure 1 The illustrated embodiment presents a schematic diagram of a registration page;
[0030] Figure 3 According to the present invention Figure 1The embodiment shown in the figure illustrates a designated page dynamically generated parameter operation style diagram;
[0031] Figure 4 According to the present application Figure 1 The embodiment shown in the figure illustrates a response information display page diagram;
[0032] Figure 5 According to the present application Figure 1 The embodiment shown in the figure illustrates a specific flowchart of a unit test method;
[0033] Figure 6 The embodiment shown in the figure illustrates a unit test device structure diagram according to an exemplary embodiment of the present application;
[0034] Figure 7 The embodiment shown in the figure illustrates a hardware structure diagram of an electronic device according to an exemplary embodiment of the present application;
[0035] Figure 8 The embodiment shown in the figure illustrates a storage medium structure diagram according to an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0036] The exemplary embodiments will be described in detail herein below with reference to the drawings. In the following description, the same drawings refer to the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all the embodiments consistent with the present application. Rather, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0037] The terminology used in the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the present application. As used in the present application and the appended claims, the singular forms "a," "an" and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It will be further understood that the terms "comprises" and / or "comprising," when used in this specification, specify the presence of stated features, integers, steps, operations, elements, and / or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.
[0038] It will be understood that, although the terms first, second, third, etc. can be used herein to describe various information, these terms are not intended to denote a temporal or chronological order. Rather, these terms are used only to distinguish one from another. For example, a first information can be termed a second information, and similarly, a second information can also be termed a first information, without departing from the scope of the present application. The word "if' as used herein means "when" or "responsive to the determination" or "in response to the determination" or "upon the determination" or "when it is determined" or "upon it being determined" or "when the determination is made" or "upon the determination being made” or is otherwise consistent with the context.
[0039] In the prior art, when unit testing is performed, a user needs to write a piece of code for testing, for example, testing whether a login state is checked twice by a function, or submitting an error data type to a function to test whether the compatibility of the function is robust, etc., but different codes need to be written for different function tests, which requires the user to modify the codes multiple times, and the testing efficiency is very low.
[0040] To solve the above technical problems, the present application provides an improved unit testing method, that is, when there is a testing requirement, the parameter description information of a pre-registered method to be tested is obtained, and the parameter operation style is dynamically generated in a specified page according to the parameter description information, then the parameter value submitted by the user on the specified page is received, and the response information of the method to be tested is obtained based on the parameter value, for correctness verification, and the testing is completed.
[0041] The technical effects achieved based on the above description are as follows:
[0042] The user pre-registers the necessary information of the method to be tested, so that when testing is required, the parameter description information of the method to be tested can be obtained from the registered necessary information, and the parameter operation style of the method to be tested is generated on the visual interface, so as to map the method to be tested to the front-end visual interface, and the user can input the parameter value on the parameter operation style of the visual interface to initiate unit testing, which is simple and convenient for the user, and does not require writing any code, and the user can randomly change the parameter value for multiple tests without modifying the code. Therefore, the present application adopts codeless unit testing, which can improve the testing efficiency.
[0043] In order for those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the accompanying drawings.
[0044] Embodiment one:
[0045] Figure 1 An embodiment flowchart of a unit testing method according to an exemplary embodiment of the present application is shown, which can be applied to an electronic device, which can include a terminal device, a mobile terminal, a PC, a server, etc. As shown in Figure 1 The unit testing method includes the following steps:
[0046] Step 101: obtaining the parameter description information of a pre-registered method to be tested.
[0047] Before step 101 is performed, the necessary information of the method to be tested needs to be pre-registered for subsequent calling. In an optional specific embodiment, the registration process of the method to be tested includes the following steps:
[0048] Step 201: Receive the registration information of the method to be tested submitted by the user on the preset registration page.
[0049] Optionally, the submitted registration information includes three items: basic information, access path information, and parameter description information.
[0050] like Figure 2B The registration page shown is a schematic diagram. Users need to input the following registration information: basic information 10, access path information 20, and parameter description information 30. Basic information 10 includes the function description of the method to be tested, its location in the menu, the registrant, and any notes or reminders. Access path information 20 includes the service name, module name, class name, and method name. Parameter description information 30 includes the parameter name, parameter type, and a list of options.
[0051] When accessing path information including service name and module name, it indicates that the currently registered method under test belongs to a method provided by an application on a remote server, namely an RPC (Remote Procedure Call) method.
[0052] Therefore, users only need to fill in the information related to the method to be tested in the information input boxes provided on the registration page to complete the registration of the relevant information of the method to be tested. The operation is simple and convenient.
[0053] It should be noted that the basic information is used to display the functionality of the method under test on the specified page, making it easier for users to understand; the parameter description information is used to describe the relevant information of the input parameters of the method under test; and the access path information is information that needs to be used when calling the method under test.
[0054] Step 202: Check if the registration information is correct.
[0055] Optionally, based on the description of step 201 above, for the basic information and access path information, check whether these information are empty, and for the parameter description information, check whether the format of these information is correct, so as to avoid the user entering incorrect information and thus being unable to call the method under test.
[0056] Specifically, jsonschema rules can be used to check the correctness of registration information.
[0057] Continue as described above Figure 2B As shown, by displaying the parameter operation style at the bottom of the registration page, the parameter description information of the method to be tested filled in by the user is generated in real time, so as to remind the user to correct the input error in time.
[0058] Step 203: If correct, store the registration information in the database.
[0059] Optionally, in order to facilitate subsequent calling, a unique primary key value can be generated for the to-be-tested method, and the generated primary key value is stored in the database in correspondence with the registration information.
[0060] Based on the above description, for the parameter description information acquisition process of the to-be-tested method in step 101, the basic information of the to-be-tested method can be read from the database first, and the related function description of the to-be-tested method is displayed in the specified page according to the basic information, so that when the trigger command of the to-be-tested method is received in the specified page, the parameter description information of the to-be-tested method is read from the database.
[0061] Among them, the specified page displays the related function description information of all to-be-tested methods in the database.
[0062] For example, as shown in Figure 3 The menu 101 includes five kinds of menu settings: "common", "innovation", "doctor", "agency", and "user". The database stores the related information of six to-be-tested methods, each row 102 represents a to-be-tested method, and the tool name, register information, and note reminder information of the to-be-tested method are displayed in each row. The left " > " button 103 of each row, if triggered by the user, will generate a trigger command for indicating to read the parameter description information of the to-be-tested method from the database for display.
[0063] Step 102: Dynamically generating parameter operation style in the specified page according to the parameter description information.
[0064] In an optional embodiment, for each parameter in the parameter description information, the parameter operation style of the parameter can be dynamically generated on the specified page according to the name, type, and to-be-selected list of the parameter.
[0065] For example, the type of the parameter can include a numerical type, a string type, etc. The to-be-selected list is used to indicate the value range that the parameter needs to be limited to. If the to-be-selected list in the parameter description information is empty, it means that the parameter does not limit the value range, and if the to-be-selected list is not empty, it means that the parameter is limited to the value in the to-be-selected list.
[0066] Optionally, if the to-be-selected list of the parameter is empty, the parameter operation style of the parameter can be an input box; if the to-be-selected list of the parameter is not empty, the parameter operation style of the parameter can be a drop-down box.
[0067] Continuing to refer to the above Figure 3As shown, when the user selects the to-be-tested method in the first row, the left ">" button 103 is triggered, and the parameter description information obtained from the database includes two parameters, "doctor id" and "institution id". Since the to-be-selected list of the parameter "doctor id" is not empty, the generated parameter operation style is a drop-down box, and the user can select a value (833241, 3023, 833244) in the drop-down box as the parameter value of the parameter; since the to-be-selected list of the parameter "institution id" is empty, the generated parameter operation style is an input box, and the user can input the parameter value of the parameter in the input box according to the actual needs.
[0068] It can be seen that, by dynamically generating the parameter operation style of each parameter on the specified page, the parameter value input mode is mapped to the visual interface, and the user can input the corresponding parameter value for each parameter without writing any code.
[0069] It should be noted that, in addition to the drop-down box and the input box given above, the parameter operation style can also include a search box, a drop-down box, a selection button, multi-level linkage, etc. The present application does not specifically limit the specific parameter operation style, as long as the user can conveniently fill in the parameter value for the corresponding parameter in the operation style.
[0070] Step 103: receiving the parameter value submitted by the user on the specified page.
[0071] In an optional specific embodiment, when the submitted parameter value is received, the correctness of the submitted parameter value can be further detected according to the parameter description information. If correct, step 104 is executed; if incorrect, a parameter exception prompt is returned to the specified page to remind the user to re-input the parameter value of the parameter. In this way, the influence of the unit test result determination due to the user inputting an incorrect parameter value can be avoided.
[0072] The specific conditions for detecting the correctness of the parameter value include whether the number of parameters is correct and whether the type of the parameter value meets the requirements.
[0073] Step 104: obtaining the response information of the to-be-tested method based on the parameter value, for correctness verification.
[0074] In an optional specific embodiment, the access path information of the to-be-tested method is read from the database, and then a call request is generated according to the parameter value, the access path information, and the parameter description information, and the call request is sent to obtain the response information of the to-be-tested method.
[0075] Specifically, the access path information and the parameter description information can be obtained from the database according to the primary key value of the to-be-tested method, and the calling request can be generated by combining the service name, the module name, the class name, the method name in the access path information, the parameter name in the parameter description information, and the parameter value submitted by the user based on the step 201.
[0076] It should be noted that after the step 104 is performed, the obtained response information can be displayed in a page manner, as shown in Figure 4 , so as to facilitate the user to verify whether the response information is correct, that is, whether it meets the expectation.
[0077] At this point, the test process shown in Figure 1 is completed, and the user pre-registers the necessary information of the to-be-tested method, so that the parameter description information of the to-be-tested method can be obtained from the registered necessary information when the to-be-tested method needs to be tested, and the parameter operation style of the to-be-tested method can be generated on the visual interface, so as to map the to-be-tested method to the front-end visual interface. After the user inputs the parameter value on the parameter operation style of the visual interface, the unit test can be initiated, and for the user, the test process is simple and convenient, without the need to write any code, and the user can randomly change the parameter value for multiple tests without modifying the code. Therefore, the present scheme adopts the codeless unit test, which can improve the test efficiency.
[0078] Embodiment Two:
[0079] Figure 5 is a specific flowchart of a unit test method according to the embodiment shown in Figure 1 , and based on the embodiment shown in Figures 1 to 4 , the specific flow of the unit test method includes the following steps:
[0080] Step 501: receiving registration information of a to-be-tested method submitted by a user on a preset registration page, wherein the registration information includes basic information, access path information, and parameter description information.
[0081] Step 502: detecting whether the registration information is correct.
[0082] Step 503: if correct, storing the registration information in a database.
[0083] Step 504: reading the basic information of the to-be-tested method from the database.
[0084] Step 505: displaying the related description of the to-be-tested method in a specified page according to the basic information.
[0085] Step 506: when a trigger command of the to-be-tested method is received in the specified page, reading the parameter description information of the to-be-tested method from the database.
[0086] Step 507: dynamically generate the parameter operation style of each parameter on the specified page according to the name, type and candidate list of each parameter in the parameter description information.
[0087] Step 508: detect whether the submitted parameter value is correct according to the parameter description information.
[0088] Step 509: if correct, read the access path information of the method to be tested from the database.
[0089] Step 510: generate a call request according to the parameter value, access path information and parameter description information.
[0090] Step 511: send the call request to obtain the response information of the method to be tested.
[0091] Step 512: display the response information to check whether the response information is correct by the user.
[0092] For the above steps 501 to 512, please refer to the related description in the above embodiments, and the present application will not be described one by one in detail.
[0093] So far, the above Figure 5 The test specific process shown in the figure, the user pre-registered the necessary information of the method to be tested, so that when testing is needed, the parameter description information of the method to be tested can be obtained from the registered necessary information, and the parameter operation style of the method to be tested is generated in the visual interface, so as to map the method to be tested to the front-end visual interface, and the user can input the parameter value on the parameter operation style of the visual interface and then initiate unit testing, which is simple and convenient for the user, without writing any code, and the user can change the parameter value at will in the visual interface for multiple tests without modifying the code. Therefore, the present application adopts codeless unit testing, which can improve the testing efficiency.
[0094] Corresponding to the foregoing embodiment of the unit test method, the present application also provides an embodiment of a unit test device.
[0095] Figure 6 An embodiment of a unit test device according to an exemplary embodiment of the present application is shown in the flowchart, which is used to execute the unit test method provided by any of the above embodiments, as shown in the figure, the unit test device comprises: Figure 6
[0096] The first acquisition module 610 is used to acquire the parameter description information of the pre-registered method to be tested.
[0097] The dynamic generation module 620 is used to dynamically generate the parameter operation style in the specified page according to the parameter description information.
[0098] The parameter submitting module 630 is configured to receive the parameter value submitted by the user on the specified page.
[0099] The second obtaining module 640 is configured to obtain response information of the to-be-tested method based on the parameter value, for correctness verification.
[0100] The functions and effects of the units in the above apparatus are specifically described in the implementation process of the corresponding steps in the above method, and will not be repeated here.
[0101] For the device embodiment, since it basically corresponds to the method embodiment, the related parts can be referred to the part of the method embodiment. The above described device embodiment is only illustrative, and the units described as separate components can be or can not be physically separated, and the components displayed as units can be or can not be physical units, that is, they can be located in one place or distributed on multiple network units. According to actual needs, some or all of the modules can be selected to achieve the purpose of the present application. Those skilled in the art can understand and implement without creative labor.
[0102] The embodiment of the present application also provides an electronic device corresponding to the unit test method provided by the above-mentioned embodiment, to execute the above-mentioned unit test method.
[0103] Figure 7 A hardware structure diagram of an electronic device according to an exemplary embodiment of the present application is shown, which includes a communication interface 601, a processor 602, a memory 603 and a bus 604; wherein the communication interface 601, the processor 602 and the memory 603 complete the communication among each other through the bus 604. The processor 602 can execute the unit test method described above by reading and executing the machine executable instructions corresponding to the control logic of the unit test method in the memory 603, and the specific content of the method is described in the above embodiment, which will not be repeated here.
[0104] The memory 603 mentioned in the present application can be any electronic, magnetic, optical or other physical storage device, and can contain stored information such as executable instructions, data, etc. Specifically, the memory 603 can be a RAM (Random Access Memory), a flash memory, a storage drive (such as a hard disk drive), any type of storage disk (such as an optical disk, a DVD, etc.), or a similar storage medium, or a combination thereof. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 601 (which can be wired or wireless), and the Internet, a wide area network, a local network, a metropolitan area network, etc. can be used.
[0105] The bus 604 can be an ISA bus, a PCI bus, or an EISA bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. The memory 603 is configured to store programs, and the processor 602 executes the programs after receiving an execution instruction.
[0106] The processor 602 can be an integrated circuit chip with a processing capability of signals. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor 602 or an instruction in the form of software. The processor 602 described above can be a general processor, including a central processing unit (CPU), a network processor (NP), etc.; can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a ready programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. Each method, step and logic block diagram disclosed in the embodiments of the present application can be implemented or executed. The general processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in combination with the embodiments of the present application can be directly embodied as a hardware code processor for execution, or a combination of hardware and software modules in the code processor for execution.
[0107] The electronic device provided by the embodiments of the present application and the unit test method provided by the embodiments of the present application have the same beneficial effects as the method adopted, run or implemented.
[0108] The embodiments of the present application also provide a computer readable storage medium corresponding to the unit test method provided by the preceding embodiments. Please refer to Figure 8 The computer readable storage medium shown in the figure is an optical disc 30, and a computer program (i.e. program product) is stored on the optical disc 30, and the computer program will execute the unit test method provided by any of the preceding embodiments when run by a processor.
[0109] It should be noted that examples of the computer readable storage medium can also include, but are not limited to, a phase change memory (PRAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), other types of random access memory (RAM), a read only memory (ROM), an electrically erasable programmable read only memory (EEPROM), a flash memory or other optical, magnetic storage medium, which will not be described one by one here.
[0110] The computer readable storage medium provided by the above embodiments of the present application has the same beneficial effects as the method adopted, run or implemented by the application program stored therein, with the same inventive concept as the unit test method provided by the embodiments of the present application.
[0111] Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. It is intended that the present application cover any and all variations of the present application comprising modifications, alterations, adaptations, improvements, combinations, sub-combinations, and the like of the present application that are within its spirit and scope. For purposes of the present application, the term "about" means that the following recited numerical data are intended to allow for variations that can exist in the upper and lower limits of the range. It is therefore intended that the present application not be limited to the specifically recited embodiments, but that the present application include all embodiments falling within the principles and the scope of the present application.
[0112] It should also be noted that the terms "comprising", "comprises", "including", "includes" or any other variation thereof are intended to cover a non-exclusive inclusion, such that a process, method, article or apparatus that comprises a list of elements does not include only those elements but can include other elements not expressly listed or inherent to such process, method, article or apparatus. Without further limitation, an element preceded by "comprises a" does not, without more limitations, foreclose the existence of additional identical elements in the process, method, article or apparatus that includes the recited element.
[0113] The above description is only preferred embodiments of the present application, and is not intended to limit the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the scope of protection of the present application.
Claims
1. A method of unit testing, characterized by, The method comprises: acquiring parameter description information of a pre-registered method to be tested; dynamically generating parameter operation styles in a specified page according to the parameter description information; receiving parameter values submitted by a user on the specified page; acquiring response information of the method to be tested based on the parameter values for correctness verification, including: combining a service name, a module name, a class name, a method name in access path information read from a database, a parameter name in the parameter description information, and the parameter values submitted by the user to generate a call request, and sending the call request to acquire the response information of the method to be tested; The method further comprises a registration process of the method to be tested, and the registration process comprises: before writing registration information of the method to be tested into a database, generating parameter operation styles in real time according to parameter description information of the method to be tested filled by the user on a preset registration page, to remind the user to correct in time when an error is input, and the content of a candidate list in the parameter operation styles generated in real time is configured by the user on the registration page; if the configured candidate list is empty, the parameter operation style of the corresponding parameter comprises an input box, and if the configured candidate list is not empty, the parameter operation style of the corresponding parameter comprises a drop-down box.
2. The method of claim 1, wherein, The method further comprises a registration process of the method to be tested: receiving registration information of the method to be tested submitted by a user on a preset registration page, the registration information comprising basic information, access path information, and parameter description information; detecting whether the registration information is correct; if correct, storing the registration information into a database.
3. The method of claim 2, wherein, The acquiring of the parameter description information of the pre-registered method to be tested comprises: reading basic information of the method to be tested from the database; displaying relevant descriptions of the method to be tested on a specified page according to the basic information; when a trigger command of the method to be tested is received on the specified page, reading parameter description information of the method to be tested from the database.
4. The method of claim 1, wherein, The dynamically generating of parameter operation styles in a specified page according to the parameter description information comprises: for each parameter in the parameter description information, dynamically generating a parameter operation style of the parameter on the specified page according to the name, type, and candidate list of the parameter.
5. The method of claim 4, wherein, The dynamically generating of a parameter operation style of the parameter on the specified page according to the name, type, and candidate list of the parameter comprises: if the candidate list of the parameter is empty, the parameter operation style of the parameter is an input box; if the candidate list of the parameter is not empty, the parameter operation style of the parameter is a drop-down box.
6. The method of claim 1, wherein, The receiving of parameter values submitted by a user on the specified page comprises: detecting whether the submitted parameter values are correct according to the parameter description information; if correct, performing the step of calling the method to be tested based on the parameter values to acquire response information; if incorrect, returning a parameter exception prompt to the specified page.
7. The method of claim 1, wherein, After acquiring the response information of the method to be tested based on the parameter values, the method further comprises: displaying the response information to verify whether the response information is correct by a user.
8. A unit testing apparatus, characterized by, The device comprises: The first obtaining module is configured to obtain parameter description information of a pre-registered method to be tested; The dynamic generation module is configured to dynamically generate a parameter operation style in a designated page according to the parameter description information; The parameter submission module is configured to receive parameter values submitted by a user on the designated page; The second obtaining module is configured to obtain response information of the method to be tested based on the parameter values, for correctness verification; and the second obtaining module is specifically configured to: combine a service name, a module name, a class name, a method name in access path information read from a database, a parameter name in the parameter description information, and the parameter values submitted by the user to generate a calling request, send the calling request, and obtain the response information of the method to be tested. The apparatus is further configured to: in a registration process of the method to be tested, before writing registration information of the method to be tested into the database, generate a parameter operation style according to the parameter description information of the method to be tested filled by the user in a preset registration page in real time, to remind the user to correct input errors in time, and the content of a candidate list in the parameter operation style generated in real time is configured by the user on the registration page; if the configured candidate list is empty, the parameter operation style of a corresponding parameter includes an input box, and if the configured candidate list is not empty, the parameter operation style of the corresponding parameter includes a drop-down box.
9. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor implements the steps of the method according to any one of claims 1-7 when executing the program.
10. A computer-readable storage medium having stored thereon a computer program, characterized in that, The program is executed by the processor to implement the steps of the method according to any one of claims 1-7.
Citation Information
Patent Citations
Pressure test configuration method and device
CN114416561A