CN118093435A - Interface testing method and device, electronic equipment and storage medium - Google Patents

Interface testing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN118093435A
CN118093435A CN202410473013.4A CN202410473013A CN118093435A CN 118093435 A CN118093435 A CN 118093435A CN 202410473013 A CN202410473013 A CN 202410473013A CN 118093435 A CN118093435 A CN 118093435A
Authority
CN
China
Prior art keywords
interface
test
target
use case
testing
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202410473013.4A
Other languages
Chinese (zh)
Inventor
曾水强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
DMAI Guangzhou Co Ltd
Original Assignee
DMAI Guangzhou Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by DMAI Guangzhou Co Ltd filed Critical DMAI Guangzhou Co Ltd
Priority to CN202410473013.4A priority Critical patent/CN118093435A/en
Publication of CN118093435A publication Critical patent/CN118093435A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3664Environments for testing or debugging software
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3696Methods or tools to render software testable

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application provides a method, a device, electronic equipment and a storage medium for testing an interface, and relates to the technical field of software testing, wherein the method comprises the steps of importing at least one interface document corresponding to the interface forming a module to be tested into a test platform, and loading the interface and an interface use case corresponding to the interface in the test platform; editing test scene information in a test scene interface of a test platform, adding a test step for a test scene, wherein the test step comprises a first target interface and a first target interface use case, and configuring assertion for a second target interface or a second target interface use case in a post operation label page; configuring environment variable parameters for a test environment in a test environment management interface based on a preset environment type indicated by the test scene information; the test platform automatically tests the test steps in the currently created test scene to obtain test results, wherein the test results at least comprise assertion results, so that the test efficiency of the interface is improved, and the test cost is reduced.

Description

Interface testing method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of software testing technologies, and in particular, to a method and apparatus for testing an interface, an electronic device, and a storage medium.
Background
With the rapid development of technology, the use of interface management tools is becoming increasingly important. However, existing interface management tools often face compatibility and functionality challenges. However, the existing interface test method often requires a developer to write interface test codes manually, thereby increasing the workload, being easy to make mistakes and having low test efficiency.
Disclosure of Invention
Therefore, the application aims to provide a method, a device, electronic equipment and a storage medium for testing an interface, which realize automatic testing of the interface through a testing platform, improve the testing efficiency of the interface and reduce the testing cost.
In a first aspect, the present application provides a method for testing an interface, the method includes importing at least one interface document corresponding to an interface forming a module to be tested into a test platform, and loading the interface and an interface use case corresponding to the interface in the test platform; editing test scene information in a test scene interface of a test platform, adding a test step for a test scene, wherein the test step comprises a first target interface and a first target interface use case, and configuring assertion for a second target interface or the second target interface use case in a post-operation tag page, wherein the first target interface comprises the second target interface, and the first target interface use case comprises the second target interface use case; configuring environment variable parameters for a test environment in a test environment management interface based on a preset environment type indicated by the test scene information; and automatically testing the testing step by the testing platform according to the currently created testing scene so as to obtain a testing result, wherein the testing result at least comprises an assertion result.
Preferably, the method further comprises the step of generating a timing automatic test task in the CI/CD label page, enabling the test platform to automatically test the test steps according to the time interval indicated by the timing automatic test task, and sending the test result of each automatic test to a mailbox address indicated by the automatic test task by the test platform.
Preferably, an interface document corresponding to a module to be tested is imported into a test platform, and an interface case corresponding to the module to be tested are created in the test platform, which specifically comprises the following steps: selecting a type button corresponding to the type of the interface document in the import data tab page; dragging the file of the interface document to an importing area in an importing data tag page, and clicking a submit button; acquiring an interface list acquired by a test platform according to an interface document; and selecting an interface to be tested from the interface list so as to load the corresponding interface and interface use cases in the test platform.
Preferably, any interface or interface use case created for the test platform further includes: adjusting target request parameters of the interface or the interface use case, wherein the request parameters are automatically generated by a test platform; the step of adjusting the target request parameter of the interface or the interface use case specifically includes: clicking an interface or an operation area corresponding to the interface use case, and expanding an interface detail interface; and inputting a preset return value into a parameter value editing box corresponding to the target request parameter in a request parameter label page of the interface detail interface, or adding a virtual object into the parameter value editing box corresponding to the target request parameter in the request parameter label page of the interface detail interface, wherein the virtual object is used for generating a return value matched with the format of the target request parameter when the interface runs.
Preferably, for any second target interface or second target interface use case, assertions are configured in the following manner: adding an assertion task item in the second target interface or a post operation tag page corresponding to the second target interface use case; and respectively inputting a corresponding assertion name, an assertion object, a path expression and an assertion condition in a configuration interface of the assertion task item.
Preferably, before the step of automatically testing the testing step, the method further comprises configuring an encryption task for the third target interface, so that the third target interface encrypts communication fields with other interfaces in the testing process.
Preferably, the encryption task is configured for each third target interface by: configuring a field needing encryption in a body operation tag page of the third target interface; in the front operation tab page of the third target interface, an encryption script for encrypting a field is input.
In a second aspect, the present application provides a testing apparatus for an interface, the apparatus comprising:
The importing module is used for importing at least one interface document corresponding to an interface forming the module to be tested into the testing platform, and loading the interface and an interface use case corresponding to the interface in the testing platform;
The step configuration module is used for editing test scene information in a test scene interface of the test platform, adding a test step for the test scene, wherein the test step comprises a first target interface and a first target interface use case, and configuring assertion for a second target interface or the second target interface use case in a post-operation tag page, the first target interface comprises the second target interface, and the first target interface use case comprises the second target interface use case;
the environment configuration module is used for configuring environment variable parameters for the test environment in the test environment management interface according to the preset environment type indicated by the test scene information;
the test module is used for enabling the test platform to automatically test the test steps in the currently created test scene so as to obtain test results, and the test results at least comprise assertion results.
In a third aspect, the present application also provides an electronic device, including: the system comprises a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory are communicated through the bus, and the machine-readable instructions are executed by the processor to perform the steps of the method for testing an interface as described above.
In a fourth aspect, the present application also provides a computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of a method of testing an interface as described above.
The application provides a method, a device, electronic equipment and a storage medium for testing an interface, wherein the method comprises the steps of importing at least one interface document corresponding to the interface forming a module to be tested into a test platform, and loading the interface and an interface use case corresponding to the interface in the test platform; editing test scene information in a test scene interface of a test platform, adding a test step for a test scene, wherein the test step comprises a first target interface and a first target interface use case, and configuring assertion for a second target interface or the second target interface use case in a post-operation tag page, wherein the first target interface comprises the second target interface, and the first target interface use case comprises the second target interface use case; configuring environment variable parameters for a test environment in a test environment management interface based on a preset environment type indicated by the test scene information; and automatically testing the testing step by the testing platform according to the currently created testing scene so as to obtain a testing result, wherein the testing result at least comprises an assertion result. Through the test platform with automatic interface test capability, the interface is automatically tested, only the interface document and simple parameter adjustment are needed to be imported, a complex test script is not needed to be written, the test efficiency of the interface is improved, and the test cost is reduced.
In order to make the above objects, features and advantages of the present application more comprehensible, preferred embodiments accompanied with figures are described in detail below.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments will be briefly described below, it being understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and other related drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a method for testing an interface according to an embodiment of the present application;
FIG. 2 is a schematic structural diagram of a testing device for an interface according to an embodiment of the present application;
FIG. 3 is a schematic structural diagram of another interface testing device according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present application more apparent, the technical solutions of the embodiments of the present application will be clearly and completely described with reference to the accompanying drawings in the embodiments of the present application, and it should be understood that the drawings in the present application are for the purpose of illustration and description only and are not intended to limit the scope of the present application. In addition, it should be understood that the schematic drawings are not drawn to scale. A flowchart, as used in this disclosure, illustrates operations implemented according to some embodiments of the present application. It should be appreciated that the operations of the flow diagrams may be implemented out of order and that steps without logical context may be performed in reverse order or concurrently. Moreover, one or more other operations may be added to or removed from the flow diagrams by those skilled in the art under the direction of the present disclosure.
The terms "a," "an," "the," and "said" are used in this specification to denote the presence of one or more elements/components/etc.; the terms "comprising" and "having" are intended to be inclusive and mean that there may be additional elements/components/etc. in addition to the listed elements/components/etc.; the terms "first" and "second" and the like are used merely as labels, and are not intended to limit the number of their objects.
It should be understood that in embodiments of the present application, "at least one" means one or more and "a plurality" means two or more. "and/or" is merely an association relationship describing an association object, meaning that there may be three relationships, e.g., a and/or B, may represent: a exists alone, A and B exist together, and B exists alone. The character "/" generally indicates that the context-dependent object is an "or" relationship. "comprising A, B and/or C" means comprising any 1 or any 2 or 3 of A, B, C.
It should be understood that in embodiments of the present application, "B corresponding to a", "a corresponding to B", or "B corresponding to a" means that B is associated with a from which B may be determined. Determining B from a does not mean determining B from a alone, but may also determine B from a and/or other information.
In addition, the described embodiments are only some, but not all, embodiments of the application. The components of the embodiments of the present application generally described and illustrated in the figures herein may be arranged and designed in a wide variety of different configurations. Thus, the following detailed description of the embodiments of the application, as presented in the figures, is not intended to limit the scope of the application, as claimed, but is merely representative of selected embodiments of the application. All other embodiments, which can be made by a person skilled in the art based on embodiments of the application without making any inventive effort, fall within the scope of the application.
First, an application scenario to which the present application is applicable will be described. The application can be applied to the test of application programming interfaces (Application Programming Interface, APIs) in the software development process.
With the rapid development of technology, the use of interface management tools is becoming increasingly important. However, existing interface management tools often face compatibility and functionality challenges. However, the existing interface test method often requires a developer to write interface test codes manually, thereby increasing the workload, being easy to make mistakes and having low test efficiency.
Based on the above, the embodiment of the application provides a method and a device for testing an interface, electronic equipment and a storage medium.
Specifically, the test platform is Apifox interface management platform, which can support importing interface documents and automatically generating test cases, and support functions of multi-person collaboration, continuous integration, real-time monitoring and the like.
Example 1
Here, a procedure of performing an interface test using Apifox will be described.
Referring to fig. 1, fig. 1 is a flowchart of a method for testing an interface according to an embodiment of the application. As shown in fig. 1, a method for testing an interface according to an embodiment of the present application includes:
S1, importing at least one interface document corresponding to an interface forming a module to be tested into a test platform, and loading the interface and an interface use case corresponding to the interface in the test platform.
The interface file is defined and produced by front-end engineers and back-end engineers according to the software function requirements in the target software development for developing the interface. The interface document at least comprises data specifications such as a request Url, a method, an information head, a request example, a response type, a response example and the like corresponding to the interface, and the data specifications can be Swagger Url or an OpenAPI JSON file generally. The target software is composed of a plurality of modules corresponding to different functions.
Importing at least one interface document corresponding to an interface forming a module to be tested into a test platform, and loading the interface and an interface use case corresponding to the interface in the test platform, wherein the method specifically comprises the following steps of:
In the import data tab page, a type button corresponding to the type of the interface document is selected. And dragging the file of the interface document to the importing area in the importing data tag page, and clicking a submit button. And acquiring an interface list acquired by the test platform according to the interface document. And selecting an interface to be tested from the interface list so as to load the corresponding interface and interface use cases in the test platform.
In performing interface testing using Apifox, a test item is first created. In the new tab page under the test item, an import option may be selected. The introduction may be performed at a selected timing or manually. Taking manual import as an example, the format of the interface document to be imported, such as Swagger, may be selected first, then the interface document is uploaded, and the test platform responds to the received interface document to display an import preview interface.
The import preview interface displays interfaces, data modules, environments, etc. corresponding to the uploaded content. In the interface label page of the preview interface, an interface list is displayed, and a tester can select an interface to be used in the test according to the requirement. A catalog to be imported by the interface in the current test item may also be set in the import preview interface.
After the tester selects the interface to be used, the tester can click a confirm import button in the import preview interface, and the test platform imports the corresponding interface and displays an import success interface. Here, the test platform automatically generates a successful interface use case corresponding to the interface while importing the interface.
For example, if the interface is a login function, the corresponding successful interface use case is the successfully logged-in interface use case.
The tester may then further operate on the imported interface in the interface management column in the current test item.
The interface may be imported in other manners, such as by URL.
S2, editing test scene information in a test scene interface of a test platform, adding a test step for a test scene, wherein the test step comprises a first target interface and a first target interface use case, and configuring assertion for a second target interface or the second target interface use case in a post-operation label page, wherein the first target interface comprises the second target interface, and the first target interface use case comprises the second target interface use case.
In step S2, the tester may open an automated test tab page in the test platform to create a test scenario for the current test item.
In the newly built test scene interface, a tester can input the name of a test scene, such as XX software core service, select targets and priorities, and can also add description information.
Subsequently, in the detail interface of the test scenario, the test steps may be further edited. Specifically, in the test step tab page, the add step button is clicked. Here, the interface or the interface use case may be selected to be added, which may be the interface or the interface use case imported in step S1 (default automatic inheritance of the request early and method in the test use case), or may be an interface or an interface use case that has been created in the test platform.
For example, the testing step may include registering, registering successfully, logging in successfully, recharging successfully, several interfaces and interface use cases.
For complex test scenarios, flow control test cases (e.g., grouping, condition judgment, looping, waiting) and the like may also be used.
Here, for any second target interface or second target interface use case, an assertion may be configured by:
Adding an assertion task item in the second target interface or a post operation tag page corresponding to the second target interface use case; and respectively inputting a corresponding assertion name, an assertion object, a path expression and an assertion condition in a configuration interface of the assertion task item.
To determine whether the results of the interface response are consistent with the expected results, the tester may open a post-operation tab page corresponding to the interface or the interface use case. With the post-addition operation button, select the operation of the assertion type and add. The test platform may display a configuration interface for the assertion task item, where the tester may input the assertion name, (optionally not filled in), the assertion object, such as "Response Text, response JSON, response Header, response Cookie, etc., JSONpath expressions, such as" $code ", and select assertion conditions, such as" equal to 0, greater than 1, less than 1, etc.
Thus, the tester may fire a send button in a detail page of the interface or interface use case, where the result of the assertion will be subsequently displayed, e.g. "success, $code equals 0".
In constructing the test scenario, the tester may select an operating environment, including a test environment, a development environment, a formal environment, and the like. The number of loops, number of threads, interval stalls, etc. may also be set. Here, the different test scenarios are independent of each other, and have no impact on the data and testing of other environments.
S3, configuring environment variable parameters for the test environment in the test environment management interface based on the preset environment type indicated by the test scene information.
In step S3, different parameters may be configured in each environment, and various personalized mock data may be easily created according to actual needs. Common environment variable parameters may include pictures, user names, cell phone numbers, web addresses, dates, times, time stamps, mailboxes, provinces, cities, addresses, IP, etc.
S4, the test platform automatically tests the test steps in the currently created test scene to obtain test results, wherein the test results at least comprise assertion results.
After the test case is configured, clicking an operation button, automatically testing by the test platform according to the configured environment in the previous step, and displaying a test result display interface after the test is finished, wherein the test result display interface comprises an assertion result of each interface, total time consumption of the test, average interface request time consumption, cycle number and the like. The tester can also develop the test details of the interface, check whether the request value in the interface test is normal, and further debug the interface.
Further, the test result can be derived from the test platform for subsequent adjustment of the interface, and the like.
According to the interface testing method provided by the embodiment of the application, the interface is automatically tested through the testing platform with the automatic interface testing capability, only the interface document and the simple parameter adjustment are required to be imported, the complex testing script is not required to be written, the testing efficiency of the interface is improved, and the testing cost is reduced.
Example two
In one embodiment of the present application, after an interface or an interface use case is created in the test platform, a target request parameter of the interface or the interface use case may be adjusted for any interface or any interface use case created by the test platform, where the request parameter is automatically generated by the test platform.
The step of adjusting the target request parameter of the interface or the interface use case specifically includes:
clicking an interface or an operation area corresponding to the interface use case, and expanding an interface detail interface;
And inputting a preset return value into a parameter value editing box corresponding to the target request parameter in a request parameter label page of the interface detail interface, or adding a virtual object into the parameter value editing box corresponding to the target request parameter in the request parameter label page of the interface detail interface, wherein the virtual object is used for generating a return value matched with the format of the target request parameter when the interface runs.
The tester can open the interface or the detail interface of the interface use case and select the document tag page, fill in the request parameter column with the request parameter, return the response, and the like.
In one case, it may be manually entered by a tester. In another case, the quick generation may be performed using the Mock function of Apifox. For example, the reg_time field may be the current time, and the virtual object may be selected to be "@ now (" mintue ")", and when the interface is running, the reg_time field may be the real-time, and specifically to minutes, such as "14:16". The virtual object herein is a data simulation tool provided by Apifox that can automatically generate parameters for format matching. In this way, the writing effort of the test procedure code can be further reduced.
Example III
In the development process, as the module to be tested can be increased, modified and the like, in order to discover possible problems of the module to be tested in real time, the continuous integration function of Apifox can be used, the interface of the module to be tested can be continuously updated, and automatic test can be performed.
Specifically, a timed automatic test task can be generated in the CI/CD label page, so that the test platform automatically tests the test steps according to the time interval indicated by the timed automatic test task, and the test platform sends the test result of each automatic test to the mailbox address indicated by the automatic test task.
The tester can select CI/CD label pages in the detail interface of the test scene of the test platform, newly establish timing automatic test tasks, and configure corresponding running environment, circulation times and other data. The tool type (such as Jenkins, github Actions or Apifox CLI) can also be selected, and the test platform automatically generates the execution script corresponding to the automatic test task. After each cycle is finished, the test platform can feed test results back to the testers in the form of mails, so that the testers can adjust interfaces with problems.
When a timing automatic test task is newly built, a Jenkins continuous integration tool can be installed on a Linux system, a node. Js environment is installed in the continuous integration tool, the version of the node. Js needs to be greater than or equal to v14.20.1, and a Apifox-CLI environment required by running a CLI command is finally installed.
And then selecting a scene needing continuous integrated test in an automatic test module of Apifox interface management tools, clicking a CI/CD label page, creating a Jenkins continuous integrated platform, and automatically generating a code for constructing configuration after storage. The code that builds the persistent integrated configuration is copied into the pipeline configuration in the Jenkins tool.
In the Jenkins tool, triggers are configured to execute interface automation test scripts at regular time. In the construction trigger, a construction periodic trigger option is checked, and a timing trigger is set through a Cron expression.
After the continuous integration flow is executed, the test report can be automatically sent to a project responsible person through an email so as to be notified and follow up in time.
After receiving the notification of the completion of the automated testing of the interface, it is necessary to compare the consistency of the actual test results with the expected results and to detect the response time of the interface according to the performance benchmark to evaluate the system performance. The method ensures that each test is clear and effective, and has practical value for improving the quality of products.
Example IV
In order to include the security line of the software, in practical application, some interface functions need to be encrypted, so when the interface is tested, corresponding encrypted transmission is also needed.
The method comprises the steps of automatically testing the testing step, and configuring an encryption task for a third target interface, so that the third target interface encrypts communication fields with other interfaces in the testing process.
The third target interface here is an interface that requires encrypted transmission. The step of configuring the encryption task in Apifox specifically includes:
Interface data is defined, and fields to be encrypted are defined in body parameters of the interface, for example, an encryption task may be configured for each third target interface by: in the body operation tag page of the third target interface, a field that needs encryption is configured. In the front operation tab page of the third target interface, an encryption script for encrypting a field is input.
The tester can write a script for encryption in a front-end operation panel of the login interface. This script will be executed before the request is sent, encrypting the data. For example, an AES encryption mode may be selected and corresponding encryption logic implemented in the script. After the script is executed, whether the encryption result meets the expectations is checked, so that the encrypted data can pass the login verification correctly.
The following is a code example of encrypting a login password field by AES:
JavaScript// import necessary libraries
Const CryptoJS = required ('crypto-js')/(define encryption function)
Function encryptPassword (password) {// set key and Initial Vector (IV)
const key = CryptoJS.enc.Utf8.parse('your_key_here');
Constiv=cryptojs.enc.utf8.parameter ('you_iv_here')/(encryption using AES encryption algorithm)
Const encrypted=cryptojs.aes. Encrypted (password, { iv: iv, mode: cryptojs.mode. CBC,// given encryption mode CBC (Cipher Block Chaining)
Padding CryptoJS. Pad. Pkcs7// designates the filling method as PKCS7
(Z) and/return of encrypted passwords
return encrypted.toString();
Encryption by calling encryption function
Const originalPassword =' you_original_password;// store original password
Const encryptedPassword = encryptPassword (originalPassword);// obtaining encrypted password
console.log('Encrypted password:', encryptedPassword).
Example five
Since multiple testers are often required to team cooperate during the software development process, the branching functions can be managed and iterated by the team of Apifox.
Specifically, an administrator and common members can be set for the current test item, and the administrator can assign rights to each common member.
The common member tests different functions of the module to be tested, the common member recreates a new branch according to the module to be tested which is responsible for the common member to carry out interface debugging and testing, and the data of the common member is not interfered with the data of other common members, so that the efficiency of the whole interface testing flow is effectively improved.
After the test on the new branch passes, the new branch can be combined to the main branch, so that potential risks in the updating process are avoided, the smooth integration of various functions is ensured, and the correctness of the interface functions of each module of the software is ensured.
Example six
Referring to fig. 2, fig. 2 is a schematic structural diagram of an interface testing device according to an embodiment of the application. As shown in fig. 2, a schematic structural diagram of an interface testing device 200 according to an embodiment of the present application includes:
An importing module 210, configured to import at least one interface document corresponding to an interface forming a module to be tested into a testing platform, and load the interface and an interface use case corresponding to the interface in the testing platform;
The step configuration module 220 is configured to edit test scenario information in a test scenario interface of the test platform, add a test step for the test scenario, where the test step includes a first target interface and a first target interface use case, and configure assertions for a second target interface or a second target interface use case in a post-operation tag page, where the first target interface includes the second target interface, and the first target interface use case includes the second target interface use case;
the environment configuration module 230 is configured to configure environment variable parameters for the test environment in the test environment management interface according to the preset environment type indicated by the test scene information;
the test module 240 is configured to enable the test platform to automatically test the test step with the currently created test scenario, so as to obtain a test result, where the test result at least includes an assertion result.
Fig. 3 is a schematic structural diagram of another interface testing device according to an embodiment of the present application, as shown in fig. 3.
Preferably, the system further comprises a continuous integration module 250, configured to generate a timed automatic test task in the CI/CD tag page, so that the test platform automatically tests the test steps according to a time interval indicated by the timed automatic test task, and the test platform sends a test result of each automatic test to a mailbox address indicated by the automatic test task.
Preferably, the import module 210 is specifically configured to select a type button corresponding to a type of the interface document in the import data tab page; dragging the file of the interface document to an importing area in an importing data tag page, and clicking a submit button; acquiring an interface list acquired by a test platform according to an interface document; and selecting an interface to be tested from the interface list so as to load the corresponding interface and interface use cases in the test platform.
Preferably, the system further comprises a parameter adjustment module 260, configured to adjust, for any interface or interface use case created by the test platform, a target request parameter of the interface or interface use case, where the request parameter is automatically generated by the test platform; the step of adjusting the target request parameter of the interface or the interface use case specifically includes: clicking an interface or an operation area corresponding to the interface use case, and expanding an interface detail interface; and inputting a preset return value into a parameter value editing box corresponding to the target request parameter in a request parameter label page of the interface detail interface, or adding a virtual object into the parameter value editing box corresponding to the target request parameter in the request parameter label page of the interface detail interface, wherein the virtual object is used for generating a return value matched with the format of the target request parameter when the interface runs.
Preferably, for either the second target interface or the second target interface use case, the step configuration module 220 configures the assertion by: adding an assertion task item in the second target interface or a post operation tag page corresponding to the second target interface use case; and respectively inputting a corresponding assertion name, an assertion object, a path expression and an assertion condition in a configuration interface of the assertion task item.
Preferably, the method further comprises an encryption module 270, configured to configure an encryption task for the third target interface before the step of automatically testing the testing step, so that the third target interface encrypts the communication fields with other interfaces during the testing process.
Preferably, encryption module 270 configures encryption tasks for each third target interface by: configuring a field needing encryption in a body operation tag page of the third target interface; in the front operation tab page of the third target interface, an encryption script for encrypting a field is input.
Referring to fig. 4, fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the application. As shown in fig. 4, the electronic device 400 includes a processor 410, a memory 420, and a bus 430.
The memory 420 stores machine-readable instructions executable by the processor 410, when the electronic device 400 is running, the processor 410 communicates with the memory 420 through the bus 430, and when the machine-readable instructions are executed by the processor 410, the steps of the method for testing an interface in the method embodiment described above can be executed, and specific implementation manners can be referred to the method embodiment and will not be described herein.
The embodiment of the present application further provides a computer readable storage medium, where a computer program is stored, where the computer program can execute the steps of the method for testing an interface in the method embodiment when the computer program is executed by a processor, and a specific implementation manner may refer to the method embodiment and will not be described herein.
It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the above-described system and apparatus may refer to corresponding procedures in the foregoing method embodiments, which are not described herein again. In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. The above-described apparatus embodiments are merely illustrative, for example, the division of the units is merely a logical function division, and there may be other manners of division in actual implementation, and for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be through some communication interface, device or unit indirect coupling or communication connection, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a non-volatile computer readable storage medium executable by a processor. Based on this understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution in the form of a software product stored in a storage medium, comprising several instructions for causing a computer device (which may be a personal computer, a server, a network device, etc.) to perform all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The foregoing is merely illustrative of the present application, and the present application is not limited thereto, and any person skilled in the art will readily appreciate variations or alternatives within the scope of the present application. Therefore, the protection scope of the application is subject to the protection scope of the claims.

Claims (10)

1. A method for testing an interface, the method comprising:
At least one interface document corresponding to an interface forming a module to be tested is imported into a test platform, and the interface and an interface use case corresponding to the interface are loaded in the test platform;
Editing test scene information in a test scene interface of a test platform, adding a test step for a test scene, wherein the test step comprises a first target interface and a first target interface use case, and configuring assertion for a second target interface or the second target interface use case in a post-operation tag page, wherein the first target interface comprises the second target interface, and the first target interface use case comprises the second target interface use case;
Configuring environment variable parameters for a test environment in a test environment management interface based on a preset environment type indicated by the test scene information;
and automatically testing the testing steps by the testing platform according to the currently created testing scene to obtain a testing result, wherein the testing result at least comprises an assertion result.
2. The method as recited in claim 1, further comprising:
And generating a timing automatic test task in the CI/CD label page, so that the test platform automatically tests the test steps according to the time interval indicated by the timing automatic test task, and sending the test result of each automatic test to a mailbox address indicated by the automatic test task.
3. The method according to claim 1, wherein the step of importing at least one interface document corresponding to an interface constituting the module to be tested into a test platform, and loading the interface and an interface use case corresponding to the interface in the test platform specifically includes:
selecting a type button corresponding to the type of the interface document in the import data tab page;
dragging the file of the interface document to an importing area in an importing data tag page, and clicking a submit button;
Acquiring an interface list acquired by a test platform according to the interface document;
and selecting an interface to be tested from the interface list so as to load the corresponding interface and interface use cases in the test platform.
4. A method according to claim 3, wherein any interface or interface use case created for the test platform further comprises:
adjusting target request parameters of the interface or the interface use case, wherein the request parameters are automatically generated by a test platform;
The step of adjusting the target request parameter of the interface or the interface use case specifically includes:
clicking an interface or an operation area corresponding to the interface use case, and expanding an interface detail interface;
And inputting a preset return value into a parameter value editing box corresponding to the target request parameter in a request parameter label page of the interface detail interface, or adding a virtual object into the parameter value editing box corresponding to the target request parameter in the request parameter label page of the interface detail interface, wherein the virtual object is used for generating a return value matched with the format of the target request parameter when the interface runs.
5. The method of claim 1, wherein for any second target interface or second target interface use case, asserting is configured by:
Adding an assertion task item in the second target interface or a post operation tag page corresponding to the second target interface use case;
And respectively inputting a corresponding assertion name, an assertion object, a path expression and an assertion condition in a configuration interface of the assertion task item.
6. The method of claim 1, further comprising, prior to the step of automatically testing the testing step:
And configuring an encryption task for the third target interface, so that the third target interface encrypts communication fields with other interfaces in the test process.
7. The method of claim 1, wherein the encryption task is configured for each third target interface by:
Configuring a field needing encryption in a body operation tag page of the third target interface;
in the front operation tab page of the third target interface, an encryption script for encrypting a field is input.
8. An apparatus for testing an interface, the apparatus comprising:
The importing module is used for importing at least one interface document corresponding to an interface forming the module to be tested into the testing platform, and loading the interface and an interface use case corresponding to the interface in the testing platform;
The step configuration module is used for editing test scene information in a test scene interface of the test platform, adding a test step for the test scene, wherein the test step comprises a first target interface and a first target interface use case, and configuring assertion for a second target interface or the second target interface use case in a post-operation label page, wherein the first target interface comprises the second target interface, and the first target interface use case comprises the second target interface use case;
the environment configuration module is used for configuring environment variable parameters for the test environment in the test environment management interface according to the preset environment type indicated by the test scene information;
The test module is used for enabling the test platform to automatically test the test steps in the currently created test scene so as to obtain test results, and the test results at least comprise assertion results.
9. An electronic device, comprising: a processor, a memory and a bus, said memory storing machine readable instructions executable by said processor, said processor and said memory communicating over the bus when the electronic device is running, said processor executing said machine readable instructions to perform the steps of the method of testing an interface as claimed in any one of claims 1 to 7.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, performs the steps of the method of testing an interface as claimed in any one of claims 1 to 7.
CN202410473013.4A 2024-04-19 2024-04-19 Interface testing method and device, electronic equipment and storage medium Pending CN118093435A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410473013.4A CN118093435A (en) 2024-04-19 2024-04-19 Interface testing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410473013.4A CN118093435A (en) 2024-04-19 2024-04-19 Interface testing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN118093435A true CN118093435A (en) 2024-05-28

Family

ID=91142258

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202410473013.4A Pending CN118093435A (en) 2024-04-19 2024-04-19 Interface testing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN118093435A (en)

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113176968A (en) * 2021-05-25 2021-07-27 平安国际智慧城市科技股份有限公司 Safety test method, device and storage medium based on interface parameter classification
CN115061912A (en) * 2022-06-17 2022-09-16 平安银行股份有限公司 Test case generation and test method, system and medium
CN116010287A (en) * 2023-03-06 2023-04-25 上海中通吉网络技术有限公司 Method for automatically generating interface test case
US20230153229A1 (en) * 2020-11-16 2023-05-18 Baidu Online Network Technology (Beijing) Co., Ltd. Method of testing performance, electronic device, and computer-readable medium
CN116383055A (en) * 2023-03-30 2023-07-04 中国工商银行股份有限公司 Financial scene testing method and device, processor and electronic equipment
CN116955192A (en) * 2023-07-28 2023-10-27 同盾科技有限公司 Management of interface test data interface testing method and device and storage medium
CN117687920A (en) * 2023-12-14 2024-03-12 天翼电子商务有限公司 Interface testing method and device, storage medium and electronic equipment

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20230153229A1 (en) * 2020-11-16 2023-05-18 Baidu Online Network Technology (Beijing) Co., Ltd. Method of testing performance, electronic device, and computer-readable medium
CN113176968A (en) * 2021-05-25 2021-07-27 平安国际智慧城市科技股份有限公司 Safety test method, device and storage medium based on interface parameter classification
CN115061912A (en) * 2022-06-17 2022-09-16 平安银行股份有限公司 Test case generation and test method, system and medium
CN116010287A (en) * 2023-03-06 2023-04-25 上海中通吉网络技术有限公司 Method for automatically generating interface test case
CN116383055A (en) * 2023-03-30 2023-07-04 中国工商银行股份有限公司 Financial scene testing method and device, processor and electronic equipment
CN116955192A (en) * 2023-07-28 2023-10-27 同盾科技有限公司 Management of interface test data interface testing method and device and storage medium
CN117687920A (en) * 2023-12-14 2024-03-12 天翼电子商务有限公司 Interface testing method and device, storage medium and electronic equipment

Similar Documents

Publication Publication Date Title
US10705942B1 (en) Simulated testing of API
CN107402880B (en) Test method and electronic equipment
US9846638B2 (en) Exposing method related data calls during testing in an event driven, multichannel architecture
US9665473B2 (en) Smart tester application for testing other applications
US20100153780A1 (en) Techniques for generating a reusable test script for a multiple user performance test
CN111159049A (en) Automatic interface testing method and system
US20060265475A9 (en) Testing web services as components
US20100153087A1 (en) Techniques for generating a reusable test script for a single user performance test
US11245601B2 (en) Automated integrated test system and method thereof
WO2018184361A1 (en) Application test method, server, terminal, and storage media
CN101193007A (en) Testing method, scenario testing method and corresponding device for URL command
US8660833B2 (en) Method, computer program product and apparatus for providing an interactive network simulator
US9900369B2 (en) Device characteristics detection and emulation
CN109977012B (en) Joint debugging test method, device, equipment and computer readable storage medium of system
CN108111364B (en) Service system testing method and device
CN110659206A (en) Simulation architecture establishing method, device, medium and electronic equipment based on microservice
CN105787364A (en) Automated testing method, device and system for task
CN114003451B (en) Interface testing method, device, system and medium
AU2013357047A1 (en) Web page variation
CN109739704A (en) A kind of interface test method, server-side and computer readable storage medium
US9477582B2 (en) Executable software specification generation
CN113778878A (en) Interface testing method and device, electronic equipment and storage medium
US10169216B2 (en) Simulating sensors
CN118093435A (en) Interface testing method and device, electronic equipment and storage medium
CN117707917A (en) Service testing method, device, medium and product

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination