WO2022095518A1 - Procédé et appareil de test d'interface automatique, et dispositif informatique et support de stockage - Google Patents

Procédé et appareil de test d'interface automatique, et dispositif informatique et support de stockage Download PDF

Info

Publication number
WO2022095518A1
WO2022095518A1 PCT/CN2021/109474 CN2021109474W WO2022095518A1 WO 2022095518 A1 WO2022095518 A1 WO 2022095518A1 CN 2021109474 W CN2021109474 W CN 2021109474W WO 2022095518 A1 WO2022095518 A1 WO 2022095518A1
Authority
WO
WIPO (PCT)
Prior art keywords
interface
execution
test
strategy
layer
Prior art date
Application number
PCT/CN2021/109474
Other languages
English (en)
Chinese (zh)
Inventor
陈林
Original Assignee
深圳壹账通智能科技有限公司
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 深圳壹账通智能科技有限公司 filed Critical 深圳壹账通智能科技有限公司
Publication of WO2022095518A1 publication Critical patent/WO2022095518A1/fr

Links

Images

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/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/3672Test management
    • G06F11/3692Test management for test results analysis

Definitions

  • the present application relates to the technical field of testing, and in particular, to a method, device, computer equipment and storage medium for automated testing of interfaces.
  • the inventor realizes that, at present, most of the common interface invocation test solutions directly write the interface parameters into the test strategy of the test case layer. When the interface parameters are changed, the parameter content in the corresponding test strategy needs to be modified. As the types of projects increase, this approach leads to low reusability of test strategies, and the defects of low test efficiency are gradually revealed.
  • the purpose of the embodiments of the present application is to provide an interface automated testing method, device, computer equipment and storage medium, which effectively improves the reusability of test cases and improves the test efficiency.
  • the embodiment of the present application provides an interface automatic testing method, which adopts the following technical solutions:
  • An interface automated testing method comprising the following steps:
  • the execution strategy corresponding to the test purpose in the preset API layer is invoked to execute the interface request to complete the interface test.
  • the embodiment of the present application also provides an interface automatic testing device, which adopts the following technical solutions:
  • An interface automated testing device comprising:
  • the parameter generation module is used to determine the test purpose corresponding to the test command when receiving the test command sent by the user, call the preset dto layer based on the test case layer, and generate an interface through the dto layer based on the test purpose input;
  • a request sending module configured to obtain the interface input parameters based on the test case layer, and generate an interface request based on the interface input parameters, where the interface request carries the test purpose;
  • the request execution module is configured to, based on the test purpose, invoke the execution strategy corresponding to the test purpose in the preset API layer to execute the interface request to complete the interface test.
  • the embodiment of the present application also provides a computer device, which adopts the following technical solutions:
  • a computer device comprising a memory and a processor, wherein computer-readable instructions are stored in the memory, and when the processor executes the computer-readable instructions, the steps of the interface automated testing method described below are implemented:
  • the execution strategy corresponding to the test purpose in the preset API layer is invoked to execute the interface request to complete the interface test.
  • the embodiments of the present application also provide a computer-readable storage medium, which adopts the following technical solutions:
  • a computer-readable storage medium on which computer-readable instructions are stored, and when the computer-readable instructions are executed by a processor, the steps of the interface automated testing method described below are implemented:
  • the execution strategy corresponding to the test purpose in the preset API layer is invoked to execute the interface request to complete the interface test.
  • the independent generation of interface input parameters is achieved through a separately set dto layer, and then the generated interface input parameters are transmitted to the test case layer, which avoids the need to modify the test strategy every time the parameters of the interface change, resulting in low test strategy reusability Case.
  • the application only needs to modify the generation method of the interface input parameters in the dto layer, and does not need to modify the test case layer, which effectively improves the reusability of the test strategy in the test case layer and improves the test efficiency.
  • the present application calls different execution strategies in the API layer in the execution process according to different testing purposes. It improves the simplicity and understandability of the overall test process, and realizes the rapid execution of the test process.
  • FIG. 1 is an exemplary system architecture diagram to which the present application can be applied;
  • Fig. 2 is a flow chart of an embodiment of an interface automated testing method according to the present application.
  • FIG. 3 is a schematic structural diagram of an embodiment of an interface automated testing device according to the present application.
  • FIG. 4 is a schematic structural diagram of an embodiment of a computer device according to the present application.
  • the system architecture 100 may include terminal devices 101 , 102 , and 103 , a network 104 and a server 105 .
  • the network 104 is a medium used to provide a communication link between the terminal devices 101 , 102 , 103 and the server 105 .
  • the network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, among others.
  • the user can use the terminal devices 101, 102, 103 to interact with the server 105 through the network 104 to receive or send messages and the like.
  • Various communication client applications may be installed on the terminal devices 101 , 102 and 103 , such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, and the like.
  • the terminal devices 101, 102, and 103 can be various electronic devices that have a display screen and support web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III, dynamic Picture Experts Compression Standard Audio Layer 3), MP4 (Moving Picture Experts Group Audio Layer IV, Moving Picture Experts Compression Standard Audio Layer 4) Players, Laptops and Desktops, etc.
  • MP3 players Moving Picture Experts Group Audio Layer III, dynamic Picture Experts Compression Standard Audio Layer 3
  • MP4 Moving Picture Experts Group Audio Layer IV, Moving Picture Experts Compression Standard Audio Layer 4
  • the server 105 may be a server that provides various services, such as a background server that provides support for the pages displayed on the terminal devices 101 , 102 , and 103 .
  • the automated interface testing method provided by the embodiments of the present application is generally performed by a server/terminal device, and accordingly, an automated interface testing apparatus is generally set in the server/terminal device.
  • terminal devices, networks and servers in FIG. 1 are merely illustrative. There can be any number of terminal devices, networks and servers according to implementation needs.
  • the interface automated testing method includes the following steps:
  • the test purpose is included in the test strategy of the test case layer, and the corresponding test purpose in the test case layer is determined according to the test instruction.
  • DTO Data Transfer Object, data transfer object
  • This application combines the dto layer with the test case layer, and generates the interface input parameters and other information contained in the test strategy (that is, the case method) in the original test case layer through the dto layer, so that different test strategies can be reused.
  • the dto layer can be combined with different test strategies in the test case layer to meet the needs of different test strategies to generate different types of parameters.
  • changes in parameters may occur, which in turn lead to changes in the test strategy in the test case layer.
  • a required parameter needs to be added to an interface.
  • the interface has 50 parameters, the interface has at least 51 test strategies (ie case methods), including 1 entry and 50 test strategies.
  • Parameter validation test strategy ie case method.
  • the parameter section of the 51 test strategies needs to be modified.
  • the electronic device (for example, the server/terminal device shown in FIG. 1 ) on which the interface automated testing method runs may receive the test purpose through a wired connection or a wireless connection.
  • the above wireless connection methods may include but are not limited to 3G/4G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultra wideband) connection, and other wireless connection methods currently known or developed in the future .
  • the dto layer includes different dto classes, and the dto classes have different parameter generation strategies.
  • the test purpose corresponding to the test command is determined, based on the test case
  • the layer calls the preset dto layer, and the steps of generating interface input parameters through the dto layer based on the test purpose include:
  • the corresponding dto class is selected based on the test target user, wherein the test target user and the dto class are in a one-to-one correspondence;
  • the parameter generation strategy and the test purpose are in a one-to-one correspondence.
  • the Dto layer includes different dto classes, and different test target users correspond to different dto classes, for example, a bank can correspond to one dto class.
  • Different parameter generation strategies ie dto generation methods
  • different test purposes correspond to different dto generation methods. This setting is convenient for unified maintenance and management. When the project requirements change and the interface parameters change, you only need to find the corresponding dto class and maintain the dto generation method of the corresponding interface under this class.
  • Different dto classes meet the needs of different test strategies to generate different types of parameters.
  • the dto class will be generated according to the received key and value. corresponding parameters.
  • the incoming key is the request serial number (applyNo), and the value is null (null), and further generates a test case for parameter validation where the request serial number parameter is null.
  • the A interface has 1, 2, and 3 parameters, which become 2, 3, and 4 parameters, then only the method for generating the parameters of the A interface needs to be modified at the dto layer.
  • the parameters are 2, 3, 4.
  • the 1-parameter verification method of the A interface is removed from the test case layer, and a 4-parameter verification method can be added.
  • the parameter generation strategy includes an assembly strategy
  • the step of generating interface input parameters through the parameter generation strategy includes:
  • the corresponding parameter generation strategy in the dto class determined based on the test purpose is an assembly strategy
  • obtain preset interface parameters based on the test purpose assemble the interface parameters through the dto layer, and generate an interface input Ref.
  • the computer when a fixed parameter needs to be tested, the computer receives and sets the interface parameter, calls the dto layer through the test case layer to assemble the interface parameter, and generates the interface input parameter. If you do not need fixed parameters, but in the case of random testing, you can directly generate the interface input parameters through the dto layer according to the requirements.
  • the parameter generation strategy includes a random generation strategy
  • the step of generating interface input parameters through the parameter generation strategy includes:
  • the preset interface parameters are acquired based on the test purpose, and the preset interface parameters in the tool layer are called through the dto layer. Random number generator;
  • the Dto layer invokes a random number generating tool in the tool layer (util layer) to generate random numbers, wherein the random number generating tool may use a pre-packaged random number generating function.
  • the design of the Dto layer is convenient for decoupling from the test case layer, and the Dto layer is set separately to generate interface input parameters to meet the requirement that the parameters can be reused.
  • the dto layer can generate parameters randomly. For example, in loan application, it is generally required that the same user cannot apply for the same loan product repeatedly. Then, during the interface testing process, the user's identity information, such as mobile phone number, ID number, bank card number, etc., cannot be reused. Therefore, random numbers can be randomly generated through timestamps, so that parameters are not repeatedly generated, and various test cases can be executed repeatedly.
  • S2 Obtain the interface input parameters based on the test case layer, and generate an interface request based on the interface input parameters, where the interface request carries the test purpose.
  • the test case layer that is, the Case layer
  • the Case layer is used to define a test strategy (case method), including two kinds of process test strategy and parameter verification test strategy. Because the interface input parameters are generated through the dto layer alone, the code template of the test strategy defined by the test case layer of the present application is more unified, clear and simple, and it is easy to quickly copy to other projects. The learning of relevant personnel and the maintenance cost of the test strategy are all lower.
  • the test case layer sends corresponding interface requests to the API layer according to different test purposes, and the API layer is used to define the API to be called.
  • different execution strategies are preset in the calling API layer, and different execution strategies are selected according to different test purposes, so as to facilitate the rapid progress of automated testing.
  • the API layer includes a first interface and a second interface
  • the first interface is encapsulated with different main execution strategies
  • the second interface is encapsulated with different secondary execution strategies
  • the For the test purpose call the execution strategy corresponding to the test purpose in the preset API layer to execute the interface request
  • the steps to complete the interface test include:
  • the main execution strategy corresponding to the first interface is invoked, and at least one sub-execution strategy corresponding to the second interface is invoked through the main execution strategy to execute the interface request to obtain the final execution result ;
  • the assertion tool in the preset tool layer is invoked through the test case layer, the final execution result is asserted, and the assertion result is obtained to complete the interface test.
  • different main execution policies are encapsulated in the first interface (FlowBaseAPI).
  • Different secondary execution strategies are encapsulated in the second interface (BaseAPI), wherein there is a one-to-one and one-to-many correspondence between the primary execution strategy and the secondary execution strategy.
  • the main execution strategy invokes multiple sub-execution strategies
  • the sub-execution strategies execute corresponding operations in sequence, that is, after the execution of one sub-execution strategy is completed, the result is returned to the first interface, and when the continuation returned by the first interface is received
  • the instruction is executed, it continues to execute the next sub-execution strategy.
  • different primary execution strategies in the first interface and different secondary execution strategies in the second interface are invoked.
  • the automated testing can be carried out in an orderly manner.
  • the test case layer will only accept the final execution result (that is, the final processing result) returned by the first interface.
  • the assertion tool is used to assert the final execution result.
  • the commonly used assertion tool is JsonAssertion, which compares the final execution result with the pre-conceived result. Compare, and output consistency or inconsistency as the assertion result.
  • the step of invoking at least one corresponding secondary execution policy in the second interface to execute the interface request through the primary execution policy, and obtaining a final execution result includes:
  • the secondary execution strategies are executed in sequence, wherein each secondary execution strategy is executed, an intermediate execution result is obtained, and the intermediate execution result is returned to the The first interface, when receiving the continuing execution instruction returned by the first interface, executes the next sub-execution strategy until all sub-execution strategies called by the current main execution strategy are executed, and the final execution result is obtained.
  • the test case layer only accepts the final execution result (ie, the final processing result) returned by the first interface.
  • the second interface may perform multiple operations, and each step returns an intermediate execution result to the first interface, and the entire process is processed in the API layer.
  • the orderly execution of different interface tests is realized, and the intermediate execution result is returned to the first interface, which ensures that the entire operation process is in the API layer, and the first interface receives the intermediate execution result.
  • the next sub-execution strategy is called, and the final execution result is not returned to the test case layer until the final execution result is received, which ensures that the test case layer does not need to care about the intermediate execution process, and only receives the final execution result. Test confusion.
  • the first interface includes a first primary execution strategy, a second primary execution strategy and a third primary execution strategy
  • the second interface includes a first secondary execution strategy, a second secondary execution strategy and a third secondary execution strategy , based on the test purpose, call the corresponding main execution strategy in the first interface, and invoke at least one sub-execution strategy corresponding to the second interface through the main execution strategy to execute the interface request, and obtain the final execution
  • the resulting steps include:
  • test purpose is parameter encryption
  • first main execution strategy in the first interface is called, and the first sub-execution strategy in the second interface is invoked through the first main execution strategy to perform parameter encryption, and obtain final execution result
  • the second primary execution strategy in the first interface is invoked, and the first secondary execution strategy and the second secondary execution strategy in the second interface are invoked through the second primary execution strategy, Execute parameter encryption and log comparison in turn to obtain intermediate execution results and final execution results;
  • the third main execution strategy in the first interface is invoked, and the first sub-execution strategy and the second sub-execution strategy in the second interface are invoked through the third main execution strategy.
  • the sub-execution strategy and the third sub-execution strategy execute parameter encryption, log comparison, and notification log comparison in sequence to obtain intermediate execution results and final execution results.
  • the result returned by parameter encryption belongs to the final execution result.
  • the test purpose is log comparison
  • the result returned by parameter encryption belongs to the intermediate execution result
  • the result returned by log comparison belongs to the final execution result.
  • the results returned by parameter encryption operations and log comparison operations belong to the intermediate execution results.
  • the result returned by the notification class log comparison operation is the final execution result.
  • One or more sub-execution strategies are invoked by the main execution strategy, which realizes the control of the sub-execution strategy by the main execution strategy in the API layer, and ensures that the test process can be carried out in an orderly manner according to the control of the main execution strategy.
  • the first interface includes three different main execution strategies (ie methods): 1) getAPIResult method: interface request sending. 2) getCompareLogResult method: interface request sending, interface log comparison. 3) getCompareNoticeLogResult method: interface request sending, interface log comparison, notification interface log comparison.
  • the second interface includes three different sub-execution strategies: 1) getAPIResult method: encrypt the message and send a post request. 2) compareLog method: compare the input parameters of the interface and the interface input of the log call related party, specifically: according to the keyword, extract the interface parameters of the request related party in the log, and compare them with the interface input parameters. The comparison content is based on the interface For the same key, compare the value. 3) compareNoticeLog method: compares the interface input parameters with the parameters in the notification class log.
  • the step of parameter encryption is executed in the test purpose of parameter encryption, log comparison and notification type log comparison.
  • the steps of log comparison are performed in both log comparison and notification log comparison for test purposes.
  • the steps of notification class log comparison are performed only when the test purpose is notification class log comparison.
  • the steps of invoking the second main execution strategy, the first sub-execution strategy, and the second sub-execution strategy to perform the parameter encryption operation and the log comparison operation include:
  • the second main execution strategy is invoked to send a log comparison request to the second interface
  • the general application system will print a log for the convenience of checking the running situation and analyzing the cause of the problem when encountering a failure.
  • the log records the program execution process, execution information, etc.
  • the application sends an interface request to the application system under test at the beginning of the test, it cannot directly obtain the request information sent by the system under test when it calls the associated party. It can only be obtained through the log information printed by the server under test. It is necessary to extract the log first to obtain the call association
  • the request parameters of the party under test are compared with the interface input parameters generated by the dto layer to confirm that the request parameters in the request information of the related party under test are correct, wherein the request parameters in the request information of the related party under test are called Indicates the interface input parameters obtained through transparent transmission.
  • the request serial number (applyNo) of the request from the system under test to the related party is unique, the request serial number (applyNo) can be used as the interface log print mark, and at the same time as the extraction log keyword, to accurately extract the interface log of the log file.
  • the step of obtaining the parameters for calling the related party interface in the interface log, comparing the parameters for calling the related party interface and the interface input parameters, and obtaining the log comparison result includes:
  • the regular expression uses a single character string to describe and match a series of character strings conforming to a certain syntax rule.
  • a preset regular expression is used to match the log file of the related party, and the request parameters of the interface related party are obtained, wherein the related party may include the bank party or the platform party.
  • the present application can encapsulate the parameter extraction method as a log extraction API, which is directly invoked during parameter extraction, specifically including: reading the log file printed by the system under test, following up the log print information of the system under test, and extracting the request parameters of the associated party.
  • the step of executing the parameter encryption includes: 1) invoking the first main execution policy in the first interface (FlowBaseAPI) to send a post request to the second interface (BaseAPI), where the post request carries the interface entry. parameter; 2) parameter encryption is performed on the interface input parameter by the Http tool tool in the tool layer called by the first sub-execution policy in the second interface, and an encrypted message is generated; 3) based on the encrypted message, by The first secondary execution strategy in the second interface calls the Http tool tool to initiate an interface admission request, and generates a response result; 4) transmit the response result to the first interface; 5) the first interface transfers all The response result is transmitted to the test case layer; 6) The test case layer invokes an assertion tool to assert the response result, generates an assertion result, and completes the interface test.
  • the application system generally encrypts the request information. Therefore, during the test process, the application also needs to encrypt the request parameters first, then initiate the request, and determine whether the response result meets the expectation through assertion. Wherein, the present application also includes comparing the encrypted message with the expected result to determine whether they are consistent, and if they are consistent, the parameter encryption test is correct.
  • the step of executing the log comparison includes: 1) invoking the second primary execution strategy in the first interface to send a log comparison request to the second interface; 2) through the second secondary execution strategy in the second interface Call the log extraction tool class (GetLogUnits) in the tool layer to perform log query to obtain the interface log; 3) obtain the parameters of the calling related party interface in the interface log, and compare the parameters of the calling related party interface with the interface Enter the parameters to obtain the log comparison result; 4) Return the log comparison result to the first interface; 5) The first interface transmits the log comparison result to the test case layer; 6) The test The use case layer invokes an assertion tool to assert the log comparison result, generates an assertion result, and completes the interface test.
  • GetLogUnits log extraction tool class
  • the request information sent when the system under test calls the related party cannot be directly obtained. It can only be obtained through the log information printed by the server under test. It is necessary to extract the log first to obtain the request parameters of the calling related party. Then, it is compared with the interface input parameters generated by the dto layer to confirm that the request parameters in the request information of the related party under test call are correct, wherein the request parameters in the request information of the related party under test call are obtained through transparent transmission interface input parameters.
  • the step of executing the notification class log comparison includes: 1) invoking the third main execution policy of the first interface to initiate a notification interface log comparison request to the second interface; 2) through the third interface in the second interface
  • the log extraction tool class (GetLogUnits) in the sub-execution strategy calling tool layer traverses the notification log collection to obtain the corresponding notification log; 3) extracts and compares the notification interface parameters corresponding to different related parties in the notification log, and obtains Notification class log comparison result; 4) Return the notification class log comparison result to the first interface; 5)
  • the first interface transmits the notification class log comparison result to the test case layer; 6) All
  • All The test case layer invokes an assertion tool (JsonAssertion) to assert the log comparison result, generates an assertion result, and completes the interface test.
  • JsonAssertion an assertion tool
  • tool classes in this application are all deployed in the tool layer (util), and the tool layer (util) includes different tool classes, such as Http tool class (Http tool), log extraction tool class (GetLogUnits), Assertion tool class (JsonAssertion), parameter type conversion tool class, random data generation tool class, such as random generation of mobile phone numbers, bank card numbers, ID numbers, etc., log platform reading tool class, configuration file reading tool class, and request sending tools etc.
  • Http tool class Http tool
  • log extraction tool class GetLogUnits
  • Assertion tool class JobAssertion
  • parameter type conversion tool class random data generation tool class, such as random generation of mobile phone numbers, bank card numbers, ID numbers, etc.
  • random data generation tool class such as random generation of mobile phone numbers, bank card numbers, ID numbers, etc.
  • this application is also provided with a Config layer.
  • the Config layer is used to define the configuration.
  • the Config layer includes environment information (Config-properties) and constant parameters. If there is a need for subsequent changes, the maintenance configuration information can be uniformly modified in the Config layer.
  • the environment information is used in the test case layer, such as interface IP, port, request URL, log file path, log file name and other information. If the subsequent environment information changes, it only needs to be uniformly modified in the Config configuration file, without the need to modify the test.
  • Constant parameters refer to: for example, some random numbers in the generation method of the dto layer, which are generated by the tool class of the tool layer. Some parameters are constants, and multiple interfaces and multiple dto methods may need to be used. They can be written in the Config configuration file. If the constant value needs to be changed later, there is no need to modify multiple dto methods, and only need to be in the Config configuration file. unified modification.
  • the embodiments of the present application can be applied in the field of artificial intelligence technology to test data interfaces related to artificial intelligence such as semantic analysis, image recognition, and biometric identification.
  • the execution strategy in the above API layer can also be stored in a node of a blockchain.
  • the blockchain referred to in this application is a new application mode of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanism, and encryption algorithm.
  • Blockchain essentially a decentralized database, is a series of data blocks associated with cryptographic methods. Each data block contains a batch of network transaction information to verify its Validity of information (anti-counterfeiting) and generation of the next block.
  • the blockchain can include the underlying platform of the blockchain, the platform product service layer, and the application service layer.
  • the present application may be used in numerous general purpose or special purpose computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, including A distributed computing environment for any of the above systems or devices, and the like.
  • the application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer.
  • program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types.
  • the application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network.
  • program modules may be located in both local and remote computer storage media including storage devices.
  • the aforementioned storage medium may be a non-volatile storage medium such as a magnetic disk, an optical disk, a read-only memory (Read-Only Memory, ROM), or a random access memory (Random Access Memory, RAM) or the like.
  • the present application provides an embodiment of an interface automated testing device, and the device embodiment corresponds to the method embodiment shown in FIG. 2 . Can be applied to various electronic devices.
  • the interface automated testing apparatus 300 described in this embodiment includes: a parameter generation module 301 , a request sending module 302 and a request execution module 303 .
  • the parameter generation module 301 is used to determine the test purpose corresponding to the test command when receiving the test command sent by the user, call the preset dto layer based on the test case layer, and pass the dto layer based on the test purpose layer generates interface input parameters
  • the request sending module 302 is configured to obtain the interface input parameters based on the test case layer, and generate an interface request based on the interface input parameters, and the interface request carries the test purpose
  • request execution module 303 Based on the test purpose, invoking an execution strategy corresponding to the test purpose in the preset API layer to execute the interface request to complete the interface test.
  • the independent generation of interface input parameters is achieved through a separately set dto layer, and then the generated interface input parameters are transmitted to the test case layer, which avoids the need to modify the test strategy correspondingly each time the parameters of the interface are changed, resulting in Test the case where the reusability of the strategy is low.
  • the application only needs to modify the generation method of the interface input parameters in the dto layer, and does not need to modify the test case layer, which effectively improves the reusability of the test strategy in the test case layer and improves the test efficiency.
  • the present application calls different execution strategies in the API layer in the execution process according to different testing purposes. It improves the simplicity and understandability of the overall test process, and realizes the rapid execution of the test process.
  • Described dto layer includes different dto classes, has different parameter generation strategies in described dto class, described parameter generation module 301 comprises to determine submodule, call submodule, select submodule and generate submodule.
  • the determination submodule is used to determine the test target user and the test purpose corresponding to the test instruction when receiving the test instruction sent by the user;
  • the calling submodule is used for calling the preset dto layer based on the test case layer;
  • the selection submodule is used for The corresponding dto class is selected based on the test target user, wherein the test target user and the dto class are in a one-to-one correspondence;
  • the generation sub-module is used to determine the corresponding parameter generation in the dto class based on the test purpose Strategy, the interface input parameters are generated through the parameter generation strategy.
  • the parameter generation strategy includes an assembly strategy.
  • the above generation sub-module is further used for: when the corresponding parameter generation strategy in the dto class determined based on the test purpose is assembly During the strategy, the preset interface parameters are obtained based on the test purpose, and the interface parameters are assembled through the dto layer to generate interface input parameters.
  • the parameter generation strategy includes a random generation strategy
  • the generation submodule includes a calling unit and a generating unit.
  • the calling unit is configured to obtain preset interface parameters based on the test purpose when the corresponding parameter generation strategy in the dto class determined based on the test purpose is a random generation strategy, and call the preset interface parameters through the dto layer.
  • a random number generation tool in the tool layer; the generation unit is used to obtain a timestamp, generate a random number according to the timestamp based on the random number generation tool, assemble the random number and preset interface parameters through the dto layer, and generate Interface input parameters.
  • the request execution module 303 includes an execution sub-module, a return sub-module, and an assertion sub-module.
  • the execution sub-module is used to invoke the corresponding main execution strategy in the first interface based on the test purpose, and to invoke the main execution strategy through the main execution strategy.
  • At least one sub-execution strategy corresponding to the second interface executes the interface request and obtains the final execution result;
  • the return submodule is used to return the final execution result to the first interface, and send the final execution result to the first interface through the first interface.
  • the final execution result is returned to the test case layer;
  • the assertion submodule is used to invoke the pre-set assertion tool in the tool layer through the test case layer, assert the final execution result, and obtain the assertion result to complete the interface test.
  • the execution sub-module is further configured to obtain a final execution result when the secondary execution strategy invoked by the primary execution strategy is one, and when the primary execution strategy invokes the secondary execution strategy
  • execute the secondary execution strategies in sequence wherein, each time a secondary execution strategy is executed, an intermediate execution result is obtained, and the intermediate execution result is returned to the first interface.
  • the next sub-execution strategy is executed until all sub-execution strategies called by the current main execution strategy are executed, and the final execution result is obtained.
  • the first interface includes a first primary execution strategy, a second primary execution strategy and a third primary execution strategy
  • the second interface includes a first secondary execution strategy, a second secondary execution strategy and a third secondary execution strategy
  • the module also includes an identification unit, an encryption unit, a log comparison unit and a notification log comparison unit.
  • the identification unit is used to identify the test purpose; the encryption unit is used to call the first main execution strategy in the first interface when the test purpose is parameter encryption, and call the first main execution strategy through the first main execution strategy.
  • the execution parameters of the first secondary execution strategy in the second interface are encrypted to obtain the final execution result;
  • the log comparison unit is used for calling the second main execution strategy in the first interface when the test purpose is log comparison, and through the The second main execution strategy invokes the first sub-execution strategy and the second sub-execution strategy in the second interface, respectively executes parameter encryption and log comparison in sequence, and obtains the intermediate execution result and the final execution result;
  • the notification type log comparison unit is used when all the The purpose of the test is to call the third main execution strategy in the first interface, and call the first sub-execution strategy and the second sub-execution strategy in the second interface through the third main execution strategy
  • the strategy and the third sub-execution strategy execute parameter encryption, log comparison, and notification log comparison in sequence to obtain intermediate execution results and final execution results.
  • the notification type log comparison unit includes a calling subunit, a query subunit and a comparison subunit.
  • the calling subunit is used to call the second main execution strategy to send a log comparison request to the second interface when the test purpose is log comparison;
  • the query subunit is used to pass the first secondary execution strategy in the second interface
  • Invoke the log extraction tool class in the preset tool layer perform log query based on the preset request serial number, obtain the interface log, use the interface log as an intermediate execution result, and return to the first interface; compare the subunit When receiving the continuation execution instruction sent by the first interface, obtain the parameters of calling the related party interface in the interface log through the second sub-execution strategy, and compare the parameters of calling the related party interface with all the parameters. Input parameters of the above interface, and obtain the log comparison result as the final execution result.
  • the above-mentioned comparison subunit module is further configured to: match the interface log through a preset regular expression, and obtain parameters in the interface log for calling the associated party interface; compare Whether the parameters for calling the associated party interface are the same as the keys of the interface input parameters; when the keys are the same, compare whether the corresponding values are consistent, and obtain the log comparison result.
  • the independent generation of interface input parameters is achieved through a separately set dto layer, and then the generated interface input parameters are transmitted to the test case layer, which avoids the need to modify the test strategy every time the parameters of the interface change, resulting in low test strategy reusability Case.
  • the application only needs to modify the generation method of the interface input parameters in the dto layer, and does not need to modify the test case layer, which effectively improves the reusability of the test strategy in the test case layer and improves the test efficiency.
  • the present application calls different execution strategies in the API layer in the execution process according to different testing purposes. It improves the simplicity and understandability of the overall test process, and realizes the rapid execution of the test process.
  • FIG. 4 is a block diagram of a basic structure of a computer device according to this embodiment.
  • the computer device 200 includes a memory 201 , a processor 202 , and a network interface 203 that communicate with each other through a system bus. It should be noted that only the computer device 200 with components 201-203 is shown in the figure, but it should be understood that implementation of all shown components is not required, and more or less components may be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculation and/or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, special-purpose Integrated circuit (Application Specific Integrated Circuit, ASIC), programmable gate array (Field-Programmable Gate Array, FPGA), digital processor (Digital Signal Processor, DSP), embedded equipment, etc.
  • ASIC Application Specific Integrated Circuit
  • FPGA Field-Programmable Gate Array
  • DSP Digital Signal Processor
  • the computer equipment may be a desktop computer, a notebook computer, a palmtop computer, a cloud server and other computing equipment.
  • the computer device can perform human-computer interaction with the user through a keyboard, a mouse, a remote control, a touch pad or a voice control device.
  • the memory 201 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static Random Access Memory (SRAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), Programmable Read Only Memory (PROM), Magnetic Memory, Magnetic Disk, Optical Disk, etc.
  • the computer-readable storage medium may be non-volatile or volatile.
  • the memory 201 may be an internal storage unit of the computer device 200 , such as a hard disk or a memory of the computer device 200 .
  • the memory 201 may also be an external storage device of the computer device 200, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, flash memory card (Flash Card), etc.
  • the memory 201 may also include both the internal storage unit of the computer device 200 and its external storage device.
  • the memory 201 is generally used to store the operating system and various application software installed in the computer device 200 , such as computer-readable instructions of an interface automated testing method, and the like.
  • the memory 201 can also be used to temporarily store various types of data that have been output or will be output.
  • the processor 202 may be a central processing unit (Central Processing Unit, CPU), a controller, a microcontroller, a microprocessor, or other data processing chips.
  • the processor 202 is typically used to control the overall operation of the computer device 200 .
  • the processor 202 is configured to execute computer-readable instructions stored in the memory 201 or process data, for example, computer-readable instructions for executing the interface automated testing method.
  • the network interface 203 may include a wireless network interface or a wired network interface, and the network interface 203 is generally used to establish a communication connection between the computer device 200 and other electronic devices.
  • test case layer there is no need to modify the test case layer, which effectively improves the reusability of the test strategy in the test case layer and improves the test efficiency.
  • different execution strategies in the API layer are invoked, which improves the simplicity of the overall test process.
  • the present application also provides another embodiment, that is, to provide a computer-readable storage medium, where the computer-readable storage medium stores computer-readable instructions, and the computer-readable instructions can be executed by at least one processor to The at least one processor is caused to perform the steps of the interface automation testing method as described above.
  • test case layer there is no need to modify the test case layer, which effectively improves the reusability of the test strategy in the test case layer and improves the test efficiency.
  • different execution strategies in the API layer are invoked, which improves the simplicity of the overall test process.
  • the method of the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is better implementation.
  • the technical solution of the present application can be embodied in the form of a software product in essence or in a part that contributes to the prior art, and the computer software product is stored in a storage medium (such as ROM/RAM, magnetic disk, CD-ROM), including several instructions to make a terminal device (which may be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) execute the methods described in the various embodiments of this application.
  • a storage medium such as ROM/RAM, magnetic disk, CD-ROM

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

Les modes de réalisation de la présente invention appartiennent au domaine technique des tests, et concernent un procédé de test d'interface automatique. Le procédé consiste : lorsqu'une instruction de test envoyée par un utilisateur est reçue, à déterminer un objectif de test correspondant à l'instruction de test, à faire appel à une couche dto prédéfinie sur la base d'une couche de cas de test, et à générer un paramètre d'accès d'interface au moyen de la couche dto et sur la base de l'objectif de test ; à acquérir le paramètre d'accès d'interface sur la base de la couche de boîtier de test, et à générer une requête d'interface sur la base du paramètre d'accès d'interface, la requête d'interface portant l'objectif de test ; et sur la base de l'objectif de test, à faire appel à une politique d'exécution, qui correspond à l'objectif de test, dans une couche API prédéfinie pour exécuter la demande d'interface, de façon à achever un test d'interface. La présente invention concerne également un appareil de de test d'interface automatique, un dispositif informatique et un support de stockage. Une politique d'exécution dans une couche API peut être stockée dans une chaîne de blocs. Au moyen de la présente invention, la réutilisation d'un boîtier de test est efficacement améliorée, et l'efficacité de test est améliorée.
PCT/CN2021/109474 2020-11-06 2021-07-30 Procédé et appareil de test d'interface automatique, et dispositif informatique et support de stockage WO2022095518A1 (fr)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011232732.5 2020-11-06
CN202011232732.5A CN112328486A (zh) 2020-11-06 2020-11-06 接口自动化测试方法、装置、计算机设备及存储介质

Publications (1)

Publication Number Publication Date
WO2022095518A1 true WO2022095518A1 (fr) 2022-05-12

Family

ID=74316819

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/109474 WO2022095518A1 (fr) 2020-11-06 2021-07-30 Procédé et appareil de test d'interface automatique, et dispositif informatique et support de stockage

Country Status (2)

Country Link
CN (1) CN112328486A (fr)
WO (1) WO2022095518A1 (fr)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115086436A (zh) * 2022-06-16 2022-09-20 平安银行股份有限公司 Api间参数校验方法、装置、计算机设备及存储介质
CN115567455A (zh) * 2022-09-23 2023-01-03 平安科技(深圳)有限公司 一种访问流量切换方法、装置、计算机设备及存储介质

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112328486A (zh) * 2020-11-06 2021-02-05 深圳壹账通智能科技有限公司 接口自动化测试方法、装置、计算机设备及存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130318402A1 (en) * 2012-05-23 2013-11-28 Sap Ag Software Systems Testing Interface
CN109783350A (zh) * 2018-12-13 2019-05-21 重庆金融资产交易所有限责任公司 接口测试方法、装置及计算机可读存储介质
CN110389898A (zh) * 2019-06-19 2019-10-29 深圳壹账通智能科技有限公司 测试策略的获取方法、装置、终端及计算机可读存储介质
CN111143192A (zh) * 2019-11-28 2020-05-12 叮当快药科技集团有限公司 接口自动化测试方法、装置以及相关产品
CN112328486A (zh) * 2020-11-06 2021-02-05 深圳壹账通智能科技有限公司 接口自动化测试方法、装置、计算机设备及存储介质

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10452522B1 (en) * 2015-06-19 2019-10-22 Amazon Technologies, Inc. Synthetic data generation from a service description language model
CN109495334B (zh) * 2017-09-13 2021-05-28 杭州海康威视系统技术有限公司 一种测试方法及装置
CN111190808A (zh) * 2018-11-14 2020-05-22 北京京东尚科信息技术有限公司 自动化测试方法、系统、装置和计算机可读存储介质
CN109558316A (zh) * 2018-11-21 2019-04-02 武汉风行在线技术有限公司 一种测试策略自动化配置的http接口动态化参数测试方法
CN110990269A (zh) * 2019-11-26 2020-04-10 苏宁云计算有限公司 一种接口测试的方法、装置及系统
CN111679989A (zh) * 2020-06-16 2020-09-18 贝壳技术有限公司 接口健壮性测试方法、装置、电子设备及存储介质
CN111782546B (zh) * 2020-07-23 2021-10-01 北京斗米优聘科技发展有限公司 一种基于机器学习的自动接口测试方法及装置

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130318402A1 (en) * 2012-05-23 2013-11-28 Sap Ag Software Systems Testing Interface
CN109783350A (zh) * 2018-12-13 2019-05-21 重庆金融资产交易所有限责任公司 接口测试方法、装置及计算机可读存储介质
CN110389898A (zh) * 2019-06-19 2019-10-29 深圳壹账通智能科技有限公司 测试策略的获取方法、装置、终端及计算机可读存储介质
CN111143192A (zh) * 2019-11-28 2020-05-12 叮当快药科技集团有限公司 接口自动化测试方法、装置以及相关产品
CN112328486A (zh) * 2020-11-06 2021-02-05 深圳壹账通智能科技有限公司 接口自动化测试方法、装置、计算机设备及存储介质

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115086436A (zh) * 2022-06-16 2022-09-20 平安银行股份有限公司 Api间参数校验方法、装置、计算机设备及存储介质
CN115567455A (zh) * 2022-09-23 2023-01-03 平安科技(深圳)有限公司 一种访问流量切换方法、装置、计算机设备及存储介质
CN115567455B (zh) * 2022-09-23 2024-05-07 平安科技(深圳)有限公司 一种访问流量切换方法、装置、计算机设备及存储介质

Also Published As

Publication number Publication date
CN112328486A (zh) 2021-02-05

Similar Documents

Publication Publication Date Title
US11127088B2 (en) Cross-blockchain interaction method, system, computer device, and storage medium
WO2022095518A1 (fr) Procédé et appareil de test d'interface automatique, et dispositif informatique et support de stockage
CN110555299B (zh) 电子合同签订和存储方法、装置、计算机设备及存储介质
CN111414407A (zh) 数据库的数据查询方法、装置、计算机设备及存储介质
CN111814179A (zh) 用户权限管理和数据控制方法及其相关设备
WO2021013033A1 (fr) Procédé, appareil, dispositif et système d'opération de fichier, et support de stockage lisible par ordinateur
CN113254445B (zh) 实时数据存储方法、装置、计算机设备及存储介质
CN109769010B (zh) 基于SDK访问CloudStack服务器的方法、装置、设备及存储介质
CN112966304B (zh) 流程文档的防篡改方法、装置、计算机设备及介质
WO2022126962A1 (fr) Procédé sur la base d'un graphique de connaissances destiné à détecter un corpus de guidage et de soutien et dispositif associé
CN112256760B (zh) 一种数据预测方法、装置、计算机设备及存储介质
WO2022156087A1 (fr) Procédé et appareil d'établissement de liens de parenté de données, dispositif informatique et support de stockage
CN116244682A (zh) 数据库的访问方法、装置、设备以及存储介质
CN112448909A (zh) 电子锁管理方法、装置、系统及存储介质
CN113360172B (zh) 应用部署方法、装置、计算机设备及存储介质
CN112416875B (zh) 日志管理方法、装置、计算机设备及存储介质
CN114637672A (zh) 自动化数据测试方法、装置、计算机设备及存储介质
CN110941412A (zh) 基于图片化实现多终端动画协同浏览的方法、系统及终端
CN113449035B (zh) 数据同步方法、装置、计算机设备及可读存储介质
CN111835852B (zh) Web页面与ftp服务器数据传输的方法及其相关设备
US11271738B1 (en) Secure, reliable, and decentralized communication in cloud platform
WO2023159900A1 (fr) Procédé et dispositif de développement à distance
CN116723247A (zh) 微服务调用方法、装置、设备及存储介质
CN117235785A (zh) 一种隐私信息管理方法、装置、计算机设备及存储介质
CN116996292A (zh) 接口配置方法、装置、计算机设备及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21888217

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 07.08.2023)

122 Ep: pct application non-entry in european phase

Ref document number: 21888217

Country of ref document: EP

Kind code of ref document: A1