Interface Testing Method, Device, Equipment and Computer Readable Storage Medium

Through a new interface testing method, test cases, configuration files and message templates are obtained, and test messages are generated and adapted, which solves the problems of inefficiency of existing interface testing methods and difficult case reuse, and realizes more efficient interface testing.

CN113971110BActive Publication Date: 2025-05-27CHINA MERCHANTS BANK
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111259648.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-26
Publication Date
2025-05-27
Estimated Expiration
2041-10-26

AI Technical Summary

Technical Problem

Existing interface testing methods rely too much on the interface protocol and message format, resulting in inefficient testing. Once the interface protocol or message format changes, automation cases are basically unable to be reused and need to be redesigned and written.

Method used

An interface testing method is proposed, by obtaining the test cases corresponding to the test instructions, determining the configuration file and message template, generating test messages, and adapting the test messages according to the configuration files to perform interface testing.

Benefits of technology

It improves the efficiency of software system interface testing, reduces the learning cost of testers, and allows interface testing to adapt to changes in interface protocols and message formats more flexibly.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113971110B_ABST
    Figure CN113971110B_ABST
Patent Text Reader

Abstract

The present invention discloses an interface testing method, device, equipment and computer-readable storage medium. The method includes: when receiving a test instruction, obtaining a test case corresponding to the test instruction, and determining a corresponding configuration file and message template; generating a test message according to the test case, the configuration file and the message template; adapting the test message according to the configuration file, and performing interface testing on a software system through the adapted test message. According to the test case, the configuration file and the message template, the present invention generates a test message, adapts the test message according to the configuration file, and performs interface testing on the software system through the adapted test message, improving the efficiency of interface testing of the software system and reducing the learning cost of testers.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of fintech, and particularly to an interface testing method, device, equipment and computer-readable storage medium. Background Art

[0002] With the in-depth development of cloud computing and the Internet, cloud service applications have been rapidly popularized, and enterprises migrating to the cloud has become the norm for their development. During the process of various business migrations of enterprises to the cloud, the message protocols and interface types involved in the adopted cloud computing architectures and microservice architectures are becoming increasingly diverse. Testers need to spend time and effort on disassembling and assembling packets with different communication protocols and different message formats, as well as various encoding problems, which increases the learning cost of testers. At the same time, once the interface fields change, all corresponding business test scenarios need to be covered to ensure the consistency and continuity of the business. However, the interface testing method can only test for a certain specific protocol. This interface testing method is too dependent on the protocol and message format of the interface. Once the interface protocol or message format changes, a large number of automated cases developed by testers in the original old system are basically unusable, and new cases need to be redesigned and written for the corresponding interface testing, resulting in low efficiency of interface testing. Therefore, how to improve the efficiency of software system interface testing and reduce the learning cost of testers is an urgent problem to be solved. Summary of the Invention

[0003] The main object of the present invention is to propose an interface testing method, device, equipment and computer-readable storage medium, aiming to solve the problem of how to improve the efficiency of software system interface testing and reduce the learning cost of testers.

[0004] To achieve the above object, the present invention provides an interface testing method, and the interface testing method includes the following steps:

[0005] When receiving a test instruction, obtain the test case corresponding to the test instruction, and determine the corresponding configuration file and message template;

[0006] Generate a test message according to the test case, the configuration file and the message template;

[0007] Adapt the test message according to the configuration file, and perform interface testing on the software system through the adapted test message.

[0008] Preferably, the step of determining the corresponding configuration file and message template includes:

[0009] Obtain the environment variables and test transaction scenarios in the test case, determine the configuration file according to the environment variables and the test transaction scenarios, and determine the message template according to the test transaction scenario.

[0010] Preferably, the steps of generating a test message according to the test case, the configuration file, and the message template include:

[0011] Obtain the test message data and the adaptation file in the test case, and replace the message fields and message value data in the message template according to the test message data and the adaptation file;

[0012] Obtain the message format in the configuration file and the default format corresponding to the replaced message template, and compare the message format with the default format to obtain a first comparison result;

[0013] Perform a preset operation on the replaced message template according to the first comparison result to generate a test message.

[0014] Preferably, the steps of replacing the message fields and message value data in the message template according to the test message data and the adaptation file include:

[0015] Obtain the test message fields and test message value data in the test message data, and obtain the message fields and message value data in the message template according to the processing class in the adaptation file;

[0016] Compare the message fields with the test message fields, compare the message value data with the test message value data to obtain a second comparison result, and replace the message fields and message value data in the message template according to the second comparison result.

[0017] Preferably, the steps of performing a preset operation on the replaced message template according to the first comparison result to generate a test message include:

[0018] If the first comparison result is that the message format is the same as the default format, retain the default format corresponding to the replaced message template to generate a test message;

[0019] If the first comparison result is that the message format is different from the default format, perform format conversion on the replaced message template according to the message format to generate a test message.

[0020] Preferably, the steps of adapting the test message according to the configuration file and performing interface testing on the software system through the adapted test message include:

[0021] Obtain the protocol information in the configuration file, and adapt the test message according to the protocol information;

[0022] Packetize the adapted test message and send it to the software system for interface testing of the software system.

[0023] Preferably, after adapting the test message according to the configuration file and performing interface testing on the software system with the adapted test message, the interface testing method further includes:

[0024] Receive the response message sent by the software system and identify the message format corresponding to the response message;

[0025] If the message format corresponding to the response message is the default format, determine the test result based on the response message;

[0026] If the message format corresponding to the response message is not the default format, convert the message format corresponding to the response message to the default format and determine the test result based on the response message converted to the default format.

[0027] In addition, to achieve the above object, the present invention also provides an interface testing device, which includes:

[0028] An acquisition module, configured to acquire the test case corresponding to the test instruction and determine the corresponding configuration file and message template when receiving the test instruction;

[0029] A determination module, configured to generate a test message according to the test case, the configuration file, and the message template;

[0030] A test module, configured to adapt the test message according to the configuration file and perform interface testing on the software system with the adapted test message.

[0031] Further, the acquisition module is further configured to:

[0032] Acquire the environment variables and test transaction scenarios in the test case, determine the configuration file according to the environment variables and the test transaction scenarios, and determine the message template according to the test transaction scenario.

[0033] Further, the determination module is further configured to:

[0034] Acquire the test message data and adaptation file in the test case, and replace the message fields and message value data in the message template according to the test message data and the adaptation file;

[0035] Acquire the message format in the configuration file and the default format corresponding to the replaced message template, and compare the message format with the default format to obtain a first comparison result;

[0036] Perform a preset operation on the replaced message template according to the first comparison result to generate a test message.

[0037] Furthermore, the determination module further includes a replacement module, and the replacement module is used for:

[0038] Obtain the test message fields and test message value data in the test message data, and obtain the message fields and message value data in the message template according to the processing class in the adaptation file;

[0039] Compare the message fields with the test message fields, compare the message value data with the test message value data, obtain a second comparison result, and replace the message fields and message value data in the message template according to the second comparison result.

[0040] Furthermore, the determination module further includes a comparison module, and the comparison module is used for:

[0041] If the first comparison result is that the message format is the same as the default format, retain the default format corresponding to the replaced message template to generate a test message;

[0042] If the first comparison result is that the message format is different from the default format, perform format conversion on the replaced message template according to the message format to generate a test message.

[0043] Furthermore, the test module is further used for:

[0044] Obtain the protocol information in the configuration file, and adapt the test message according to the protocol information;

[0045] Packetize the adapted test message and send it to the software system to perform interface testing on the software system.

[0046] Furthermore, the test module further includes a receiving module, and the receiving module is used for:

[0047] Receive the response message sent by the software system and identify the message format corresponding to the response message;

[0048] If the message format corresponding to the response message is the default format, determine the test result based on the response message;

[0049] If the message format corresponding to the response message is not the default format, convert the message format corresponding to the response message to the default format, and determine the test result based on the response message converted to the default format.

[0050] In addition, to achieve the above object, the present invention further provides an interface testing device, which includes: a memory, a processor, and an interface testing program stored on the memory and executable on the processor. When the interface testing program is executed by the processor, the steps of the interface testing method described above are implemented.

[0051] In addition, to achieve the above object, the present invention further provides a computer-readable storage medium, on which an interface testing program is stored. When the interface testing program is executed by a processor, the steps of the interface testing method described above are implemented.

[0052] In the interface testing method proposed by the present invention, when a test instruction is received, the corresponding test case in the test instruction is obtained, and a configuration file and a message template are determined; according to the test case, the configuration file, and the message template, a test message is generated; the test message is adapted according to the configuration file, and the software system is subjected to interface testing through the adapted test message; according to the test case, the configuration file, and the message template, the present invention generates a test message, adapts the test message according to the configuration file, and performs interface testing on the software system through the adapted test message, improving the efficiency of interface testing of the software system and reducing the learning cost of testers. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] Figure 1 is a schematic diagram of the device structure of the hardware operating environment involved in the embodiment solution of the present invention;

[0054] Figure 2 is a schematic flowchart of the first embodiment of the interface testing method of the present invention;

[0055] Figure 3 is a schematic layered architecture diagram of the present invention;

[0056] Figure 4 is a flowchart of the present invention for processing the sending of different protocol and different message formats;

[0057] Figure 5 is a flowchart of the case execution processing logic of the present invention.

[0058] The realization, functional characteristics, and advantages of the object of the present invention will be further described with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0059] It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0060] As Figure 1 shown, Figure 1It is a schematic diagram of the device structure of the hardware operating environment involved in the embodiment of the present invention.

[0061] The device in the embodiment of the present invention can be a PC or a server device.

[0062] As Figure 1 shown, the device may include: a processor 1001, such as a CPU, a network interface 1004, a user interface 1003, a memory 1005, and a communication bus 1002. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display) and an input unit such as a keyboard (Keyboard). Optionally, the user interface 1003 may further include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory or a stable memory (non-volatile memory), such as a disk memory. Optionally, the memory 1005 may also be a storage device independent of the foregoing processor 1001.

[0063] Those skilled in the art can understand that Figure 1 the device structure shown in

[0064] does not constitute a limitation on the device, and may include more or fewer components than shown in the figure, or combine some components, or arrange different components. Figure 1 As

[0065] shown, the memory 1005, as a computer storage medium, may include an operating system, a network communication module, a user interface module, and an interface test program.

[0066] Among them, the operating system is a program for managing and controlling the portable interface test device and software resources, and supports the operation of the network communication module, the user interface module, the interface test program, and other programs or software; the network communication module is used to manage and control the network interface 1004; the user interface module is used to manage and control the user interface 1003. Figure 1

[0067] In the interface test device shown in

[0068] Figure 2 Referring to Figure 2 is a schematic flowchart of the first embodiment of the interface test method of the present invention. The method includes: ​

[0069] Step S10, when a test instruction is received, obtain the test case corresponding to the test instruction, and determine the corresponding configuration file and message template;

[0070] Step S20, generate a test message according to the test case, the configuration file, and the message template;

[0071] Step S30, adapt the test message according to the configuration file, and perform an interface test on the software system through the adapted test message.

[0072] The interface test method of this embodiment is applied to the interface test device of the software system of a financial institution. The interface test device can be a PC or a terminal. For the convenience of description, the interface test device is taken as an example for description below. When the interface test device receives a test instruction, it obtains the test case, environment variables, and test transaction scenario corresponding to the test instruction, determines the configuration file according to the environment variables and test transaction scenario, and determines the message template according to the test transaction scenario in the test case. The interface test device obtains the test message data and adaptation file in the test case, and replaces the message fields and message value data in the message template according to the test message data and adaptation file, obtains the message format in the configuration file and the default format corresponding to the replaced message template, compares the message format with the default format to obtain the first comparison result, and performs a preset operation on the replaced message template according to the first comparison result to generate a test message. The interface test device obtains the protocol information in the configuration file, adapts the test message according to the protocol information, packets the adapted test message, and sends it to the software system to perform an interface test on the software system. It should be noted that the test instruction is issued by a tester. The tester sets a test case including, but not limited to, test message data such as the default format, environment variables, adaptation files, test transaction scenarios, etc. according to the transaction scenario corresponding to the software system, and generates a corresponding test instruction according to the test case. Among them, the environment variables and test transaction scenarios may not be included in the test case, but are input into the interface test device by relevant testers separately. The configuration file includes, but is not limited to, the protocol information, actual message format, and encoding format of the interface corresponding to the API of the software system to be tested. API (Application Programming Interface) is some predefined interfaces (such as functions, HTTP interfaces), or refers to the convention for the connection of different components of the software system.

[0073] The interface testing method of this embodiment, when receiving a test instruction, obtains the corresponding test case in the test instruction, and determines a configuration file and a message template according to the test case; generates a test message according to the test case, the configuration file, and the message template; adapts the test message according to the configuration file, and performs interface testing on the software system through the adapted test message; receives the response message sent by the software system, and determines the test result based on the response message; according to the test case, the configuration file, and the message template, the present invention generates a test message, adapts the test message according to the configuration file, and performs interface testing on the software system through the adapted test message, improving the efficiency of interface testing of the software system.

[0074] The following will explain each step in detail:

[0075] Step S10, when receiving a test instruction, obtain the test case corresponding to the test instruction, and determine the corresponding configuration file and message template;

[0076] In this embodiment, when the interface testing device receives a test instruction, it obtains the test case, environment variables, and test transaction scenario corresponding to the test instruction, determines the configuration file through the environment variables, and determines the message template through the test transaction scenario; it should be noted that since the software system to be tested has been repeatedly tested in multiple environments, for example, from the ST environment to the UAT environment and then to the UAM environment, different environment variables correspond to different configuration files in the interface testing device in advance. Before the test starts, the tester can set the environment variables and test transaction scenarios according to the transaction scenario, or set the environment variables and test transaction scenarios in the test case according to the transaction scenario. When the interface testing device obtains the environment variables and test transaction scenarios, the corresponding configuration file is determined; in the interface testing device, the test transaction scenario is bound to the message template. It can be understood that different transaction scenarios use different message templates. Before the test starts, the tester determines the test transaction scenario according to the transaction scenario. When the interface testing device obtains the test transaction scenario, the corresponding message template is determined.

[0077] Specifically, step S10 includes:

[0078] Step a, obtain the environment variables and test transaction scenario, determine the configuration file according to the environment variables and the test transaction scenario, and determine the message template according to the test transaction scenario.

[0079] In this step, the interface testing device obtains the environment variables and test transaction scenarios, determines the configuration file according to the environment variables and test transaction scenarios, and determines the message template according to the test transaction scenarios. Generally speaking, testers set the environment variables and test transaction scenarios in the test cases according to the transaction scenarios, and then input the test cases into the interface testing device. Optionally, testers can set the environment variables and test transaction scenarios according to the transaction scenarios and directly input them into the interface testing device. For example, when the interface testing device obtains the test transaction scenario, it determines the corresponding transaction scenario. When the environment variable in the test case obtained by the interface testing device is the environment variable corresponding to the ST environment, it determines that the configuration file is the configuration file corresponding to the ST environment and the corresponding transaction scenario. When the environment variable in the test case obtained by the interface testing device is the environment variable corresponding to the UAT environment, it determines that the configuration file is the configuration file corresponding to the UAT environment and the corresponding transaction scenario. When the environment variable in the test case obtained by the interface testing device is the environment variable corresponding to the UAM environment, it determines that the configuration file is the configuration file corresponding to the UAM environment and the corresponding transaction scenario. The message templates used for different transaction scenarios are different. Testers determine the test transaction scenario according to the transaction scenario before the test starts. When the interface testing device obtains the test transaction scenario, it correspondingly determines the message template. It should be noted that if the interface testing device needs to perform interface testing on the software system in multiple environments, it can dynamically set the operating environment of this interface test by dynamically setting parameters. The dynamically set parameters include environment variables corresponding to multiple environments and switching environment keywords, etc. The interface testing device switches the corresponding environment variables according to the switching environment keywords in the dynamically set parameters, obtains the corresponding configuration file according to the switched environment variables, and then executes the subsequent steps according to the corresponding configuration file to achieve the purpose of performing interface testing on the software system in multiple environments.

[0080] Step S20: Generate a test message according to the test case, the configuration file, and the message template.

[0081] In this embodiment, after the interface testing device determines the configuration file and the message template, it replaces the message fields and message value data in the message template according to the test message data in the test case, the adaptation file, and the message format in the configuration file, and performs format conversion on the replaced message template to obtain a test message that matches the format definition corresponding to the API of the software system under test. It should be noted that the interface testing device can automatically obtain the interface definition corresponding to the API of the software system under test, and the interface definition includes, but is not limited to, the message format, protocol information, etc. that the software system under test can receive. Specifically, step S20 includes:

[0082] Step b: Obtain the test message data and the adaptation file in the test case, and replace the message field and message value data in the message template according to the test message data and the adaptation file;

[0083] In this step, the interface test device obtains the test message data and the adaptation file in the test case, obtains the corresponding message field and message value data in the message template according to the adaptation file, obtains the test message field and test message value data in the test message data, so as to replace the message field in the message template according to the test message field and replace the message value data in the message template according to the test message value data.

[0084] Further, step b includes:

[0085] Obtain the test message field and test message value data in the test message data, and obtain the message field and message value data in the message template according to the processing class in the adaptation file;

[0086] In this step, the interface test device obtains the test message field and test message value data in the test message data, and obtains the message field and message value data in the message template according to the processing class in the adaptation file; it should be noted that the processing class is the processing logic corresponding to the API of the software system to be tested. Different APIs of the software system to be tested correspond to different processing classes. There are multiple basic processing classes stored in the interface test device. If the processing class corresponding to the API of the software system to be tested has no special processing logic, when generating the adaptation file, the tester directly configures the basic processing class corresponding to the API of the software system to be tested in the interface test device as the processing class in the adaptation file. If the processing class corresponding to the API of the software system to be tested has special processing, such as deleting message field information according to a certain transaction data value, or dynamically adding multi-pack information, etc., when generating the adaptation file, the tester adds the corresponding processing class to obtain the processing class corresponding to the API of the software system to be tested in the adaptation file.

[0087] Compare the message field with the test message field, compare the message value data with the test message value data to obtain a second comparison result, and replace the message field and message value data in the message template according to the second comparison result.

[0088] In this step, the interface test device compares the message fields in the message template with the test message fields in the test message data, and compares the message value data in the message template with the test message value data in the test message data to obtain a second comparison result. If the second comparison result is that the message fields are different from the test message fields and the message value data is also different from the test message value data, the message fields are replaced with the test message fields, and the message value data is replaced with the test message value data. If the second comparison result is that the message fields are only partially different from the test message fields and the message value data is also only partially different from the test message value data, the parts of the message fields that are different from the test message fields are replaced with the corresponding parts of the test message fields, and the parts of the message value data that are different from the test message value data are replaced with the corresponding parts of the test message value data.

[0089] Step c: Obtain the message format in the configuration file and the default format corresponding to the replaced message template, and compare the message format with the default format to obtain a first comparison result.

[0090] In this step, the interface test device obtains the message format in the configuration file and the default format corresponding to the replaced message template, and compares the message format with the default format to obtain a first comparison result. It should be noted that the message format in the configuration file is the message format that the API of the software system under test can receive. When configuring test cases, the tester sets the system name corresponding to the software system to be tested in the adaptation file corresponding to the test case, and sets the test transaction scenario and environment variables in the test case. When the interface test device receives the test case, it determines the corresponding configuration file according to the system name, test transaction scenario, and environment variables. The configuration file includes the message format corresponding to the API of the software system to be tested. The default format corresponding to the message template can be one of the JSON format or other formats. The tester only needs to upload the test message data corresponding to one of the JSON format or other formats, and the interface test device can automatically convert the default format to the message format that the API of the software system under test can receive.

[0091] Step d: Perform a preset operation on the replaced message template according to the first comparison result to generate a test message.

[0092] In this step, the interface test device performs a preset operation on the replaced message template according to the first comparison result to generate a test message. The preset operation includes maintaining the default format corresponding to the replaced message template and converting the default format corresponding to the message template according to the message format in the configuration file.

[0093] If the first comparison result is that the message format is the same as the default format, retain the default format corresponding to the replaced message template to generate a test message;

[0094] In this step, if the first comparison result obtained by the interface test device is that the message format is the same as the default format, retain the default format corresponding to the replaced message template, and use the replaced message template as the test message. For example, if the default format corresponding to the replaced message template is the JSON format and the message format in the configuration file is also the JSON format, at this time, since the first comparison result obtained by the interface test device is that the message format is the same as the default format, retain the JSON format corresponding to the replaced message template and use the JSON format message template as the test message.

[0095] If the first comparison result is that the message format is different from the default format, perform format conversion on the replaced message template according to the message format to generate a test message.

[0096] In this step, if the first comparison result obtained by the interface test device is that the message format is different from the default format, convert the default format corresponding to the replaced message template to the corresponding message format in the configuration file according to the message format, and use the message template after the format conversion as the test message. For example, if the message format in the configuration file is the 8583 format, perform format conversion on the message template according to the encoding specification of the 8583 format to form the actual 8583 format message to be sent as the test message; if the message format in the configuration file is the host fixed-length message format, dynamically obtain the interface definition information corresponding to the API of the software system to be tested, and form the corresponding actual fixed-length message to be sent as the test message according to the interface definition information; if the message format in the configuration file is the XML format, perform format conversion on the message template according to the encoding specification of the XML format to form the actual XML format message to be sent as the test message.

[0097] Step S30: Adapt the test message according to the configuration file, and perform interface testing on the software system through the adapted test message;

[0098] In this embodiment, the interface test device adapts the test message according to the configuration file, uses the preset adaptation principle, calls the protocol information corresponding to the software system under test in the configuration file, and processes the communication message header of the test message so that the test message conforms to the protocol information of the software system under test, and then sends the adapted test message to the software system under test to perform interface testing on the software system.

[0099] Specifically, step S30 includes:

[0100] Step e: Obtain the protocol information in the configuration file, and adapt the test message according to the protocol information.

[0101] In this step, the interface testing device uses a preset adaptation principle to call the protocol information corresponding to the API of the software system under test in the configuration file, and processes the communication message header of the test message, so that the test message conforms to the protocol information of the API of the software system under test. It should be noted that the protocol information in the configuration file is the protocol information corresponding to the API of the software system under test. When configuring the test case, the tester sets the system name corresponding to the API of the software system under test in the adaptation file corresponding to the test case, sets the test transaction scenario and environment variables in the test case. When the interface testing device receives the test case, it determines the corresponding configuration file according to the system name, test transaction scenario and environment variables. The configuration file includes the protocol information corresponding to the API of the software system to be tested.

[0102] Step f: Packetize the adapted test message and send it to the software system to perform interface testing on the software system.

[0103] In this step, the interface testing device packetizes the adapted test message. For example, according to different functions corresponding to the software system to be tested, the test message is packetized to obtain the packetization of the test message corresponding to each function, and the packetized test message is sent to the software system to be tested to perform interface testing on the software system.

[0104] When the interface testing device of this embodiment receives the warehousing instruction, when the interface testing device receives the test instruction, it obtains the corresponding test case, environment variables and test transaction scenario in the test instruction, determines the configuration file according to the environment variables and test transaction scenario, and determines the message template according to the test transaction scenario; the interface testing device obtains the test message data and adaptation file in the test case, and replaces the message fields and message value data in the message template according to the test message data and adaptation file, obtains the message format in the configuration file and the default format corresponding to the replaced message template, compares the message format with the default format to obtain the first comparison result, and performs a preset operation on the replaced message template according to the first comparison result to generate a test message; the interface testing device obtains the protocol information in the configuration file, adapts the test message according to the protocol information, packetizes the adapted test message, and sends it to the software system to perform interface testing on the software system; improving the efficiency of software system interface testing and reducing the learning cost of testers.

[0105] Furthermore, based on the first embodiment of the interface testing method of the present invention, a second embodiment of the interface testing method of the present invention is proposed.

[0106] The second embodiment of the interface testing method is different from the first embodiment of the interface testing method in that after step S30, the interface testing method further includes:

[0107] Step g: Receive the response message sent by the software system and identify the message format corresponding to the response message;

[0108] Step h: If the message format corresponding to the response message is the default format, determine the test result based on the response message;

[0109] Step i: If the message format corresponding to the response message is not the default format, convert the message format corresponding to the response message into the default format and determine the test result based on the response message converted into the default format.

[0110] In this embodiment, after the interface testing device sends the test message to the software system to be tested, the software system to be tested will return the corresponding response message. When the performance testing device receives the response message, it identifies the message format corresponding to the response message. If the message format corresponding to the response message is the default format, it shows the response message in the default format to the tester, which is convenient for the tester to obtain the test result according to the response message in the default format. If the message format corresponding to the response message is not the default format, it converts the message format corresponding to the response message into the default format and shows the response message in the default format to the tester, which is convenient for the tester to obtain the test result according to the response message in the default format.

[0111] Step g: Receive the response message sent by the software system and identify the message format corresponding to the response message;

[0112] In this step, the interface testing device receives the response message sent by the software system and identifies the message format corresponding to the response message. The message format corresponding to the response message may be the 8583 format, the host fixed-length message format, the XML format, or the default format JSON format.

[0113] Step h: If the message format corresponding to the response message is the default format, determine the test result based on the response message;

[0114] In this step, if the interface testing device identifies that the message format corresponding to the response message is the default format, that is, the JSON format, it directly shows the response message in the JSON format to the tester. After the tester obtains the response message in the JSON format, by using the public JSON operation component provided by the interface testing device, operations such as message field extraction and message comparison can be conveniently performed to obtain the final test result.

[0115] Step i, if the message format corresponding to the response message is not the default format, convert the message format corresponding to the response message to the default format, and determine the test result based on the response message converted to the default format.

[0116] In this step, if the interface test device recognizes that the message format corresponding to the response message is not the default format, that is, the message format corresponding to the response message is one of the 8583 format, the host fixed-length message format, and the XML format, the interface test device unpacks the response message by calling the corresponding unpacking process according to the message format corresponding to the response message to obtain a response message in the JSON format, and displays the response message in the JSON format to the tester. After the tester obtains the response message in the JSON format, the tester can conveniently perform operations such as message field extraction and message comparison by using the public JSON operation component provided by the interface test device to obtain the final test result.

[0117] After the interface test device in this embodiment sends the test message to the software system to be tested, the software system to be tested will return the corresponding response message. When the performance test device receives the response message, it recognizes the message format corresponding to the response message. If the message format corresponding to the response message is the default format, the interface test device displays the response message in the default format to the tester, which is convenient for the tester to obtain the test result based on the response message in the default format. If the message format corresponding to the response message is not the default format, the interface test device converts the message format corresponding to the response message to the default format and displays the response message in the default format to the tester, which is convenient for the tester to obtain the test result based on the response message in the default format; this helps to improve the efficiency of software system interface testing and helps to reduce the learning cost of testers.

[0118] In specific implementation, the interface test device is designed in layers, including the RF layer, the Python layer, the cloud automation tool layer, and the financial transaction cloud platform service layer. This not only facilitates the tester to generate corresponding test cases according to the transaction scenario, but also facilitates the interface test device to perform corresponding operations according to the test cases, and perform interface testing on the software system to be tested through the test cases. The layered design of the interface test device is as Figure 3 shown, where:

[0119] The RF layer is mainly divided into a case layer, a service layer, and a data layer. The RF layer is mainly for testers, and testers use the keywords provided by the underlying layer to assemble corresponding test cases. Testers adopt a data-driven mode in the case layer, reuse the service scenarios of the service layer, and form different cases by obtaining different data in the data layer. Among them, the data in the data layer is managed in a tagged manner, and the cases use the corresponding data tags instead of specific data, which is convenient for maintenance and replacement. At the same time, it is also convenient to switch the data in different environments and classify and manage the data according to the actual business.

[0120] Python also includes three parts: configs, Transaction, and Business. Configs is used to store configuration information such as required database configuration information, message templates, and application system information; Transaction is used to handle data preparation and business logic for each interface, and provides a get_data method externally for the interface test device to dynamically call the corresponding interface data for preparation and processing; Business includes business logic, verification logic, etc. implemented by testers according to the business of business products. The Python layer also includes RFApi, and cmbautorf in RFApi is a method to call relevant services in the cloud automation tool layer to uniformly expose common keywords to the RF layer.

[0121] The cloud automation tool layer is a unified set of tools, components, and services provided by the interface test device to the outside world.

[0122] The financial transaction cloud platform service layer is used to implement self-service access to the development interface definition and message templates. The interface test device is connected to the traditional AS400 host and can self-service access the interface definition. In this way, testers only need to provide test messages in json format, and the interface test device automatically obtains the interface definition according to the configuration information for packet assembly.

[0123] In specific implementation, such as Figure 4As shown, relevant testers configure corresponding test cases through the RF layer in the interface test device to prepare test data. The interface test device reads the transaction configuration information in the corresponding configuration file according to the test transaction scenario in the test case, determines the message template in JSON format according to the test transaction scenario, replaces the message data in the JSON format message template with the JSON format message data transmitted in the test case, and reads the message data in the replaced JSON format message template. After the interface test device reads the message data in the replaced JSON format message template, it reads the message format information corresponding to the configuration information in the configuration file. If the message format is 8583 format, according to the UnionPay specification, it converts the message data in the replaced message template into an 8583 format message. If the message format is XML format, it converts the message data in the replaced message template into an XML format message. If the message format is a fixed-length message format, it automatically downloads the interface definition corresponding to the API of the software system to be tested, and packs the message data in the replaced message template into a fixed-length message format message according to the field length of the interface definition. After the interface test device converts the message format, it reads the protocol information corresponding to the configuration information in the configuration file, adapts the 8583 format message, XML format message or fixed-length message format message, and sends the corresponding message to the software system to be tested through the protocol adapter, and receives the response message of the software system to be tested. When the interface test device receives the response message, if the format of the response message is 8583 format, it parses the message according to the UnionPay specification and unpacks the 8583 format response message into a JSON format message. If the format of the response message is XML format, it converts the XML format response message into a JSON format message. If the format of the response message is a fixed-length message format, it unpacks the fixed-length message format response message into a JSON format message according to the interface definition, and feeds back the converted JSON format message to the tester. The tester verifies the JSON format message according to the interface return value, database, etc., and obtains the verification result.

[0124] In specific implementation, such as Figure 5As shown in the figure, in the data preparation stage, the tester prepares the test case data and sets the environment variables at the RF layer. The interface test device switches the environment according to the switching keyword in the environment variables in the cmbautorf layer of the RFApi layer in the Python layer, and sets the corresponding environment variables under configs in the Python layer through product libs. The interface test device also obtains the corresponding class (processing class) of the interface according to the transaction name in the cmbautorf layer of the RFApi layer in the Python layer, determines the corresponding get_data method, and replaces the message data according to the business rules by calling the processing class name and the get_data method through product libs; in the transaction processing stage, the interface test device sends transaction keywords including the transaction name and case data at the RF layer, and receives the request message or response message returned by the software system under test. The interface test device calls the corresponding packet assembly component to assemble the message according to the message type (message format) corresponding to the configuration information in the cmbautorf layer of the RFApi layer in the Python layer, and calls the corresponding communication component to send the message according to the protocol type (protocol information) in the configuration file. When receiving the response message returned by the software system under test, the interface test device disassembles the response message. The interface test device obtains the corresponding message template according to the transaction name through product libs; in the result processing stage, the tester compares the return code and return error message in the response message at the RF layer. When other services need to be verified through the interface content, database, etc., the verification method in the Python layer is called through product libs for verification.

[0125] The present invention also provides an interface test device. The interface test device of the present invention includes:

[0126] An acquisition module, configured to obtain the test case corresponding to the test instruction and determine the corresponding configuration file and message template when receiving the test instruction;

[0127] A determination module, configured to generate a test message according to the test case, the configuration file, and the message template;

[0128] A test module, configured to adapt the test message according to the configuration file and perform interface testing on the software system through the adapted test message.

[0129] Further, the acquisition module is further configured to:

[0130] Obtain environment variables and test transaction scenarios, determine a configuration file according to the environment variables and the test transaction scenarios, and determine a message template according to the test transaction scenarios.

[0131] Further, the determining module is further configured to:

[0132] Obtain the test message data and the adaptation file in the test case, and replace the message fields and message value data in the message template according to the test message data and the adaptation file;

[0133] Obtain the message format in the configuration file and the default format corresponding to the replaced message template, and compare the message format with the default format to obtain a first comparison result;

[0134] Perform a preset operation on the replaced message template according to the first comparison result to generate a test message.

[0135] Further, the determining module further includes a replacement module, and the replacement module is used for:

[0136] Obtain the test message fields and test message value data in the test message data, and obtain the message fields and message value data in the message template according to the processing class in the adaptation file;

[0137] Compare the message fields with the test message fields, compare the message value data with the test message value data to obtain a second comparison result, and replace the message fields and message value data in the message template according to the second comparison result.

[0138] Further, the determining module further includes a comparison module, and the comparison module is used for:

[0139] If the first comparison result is that the message format is the same as the default format, retain the default format corresponding to the replaced message template to generate a test message;

[0140] If the first comparison result is that the message format is different from the default format, perform format conversion on the replaced message template according to the message format to generate a test message.

[0141] Further, the testing module is further configured to:

[0142] Obtain the protocol information in the configuration file, and adapt the test message according to the protocol information;

[0143] Packetize the adapted test message and send it to the software system to perform interface testing on the software system.

[0144] Further, the testing module further includes a receiving module, and the receiving module is used for:

[0145] Receive the response message sent by the software system and identify the message format corresponding to the response message;

[0146] If the message format corresponding to the response message is the default format, determine the test result based on the response message;

[0147] If the message format corresponding to the response message is not the default format, convert the message format corresponding to the response message into the default format, and determine the test result based on the response message converted into the default format.

[0148] The present invention also provides an interface testing device.

[0149] The interface testing device includes: a memory, a processor, and an interface testing program stored on the memory and executable on the processor. When the interface testing program is executed by the processor, the steps of the interface testing method described above are implemented.

[0150] Among them, the method implemented when the interface testing program running on the processor is executed can refer to the various embodiments of the interface testing method of the present invention, which will not be elaborated here.

[0151] The present invention also provides a computer-readable storage medium.

[0152] An interface testing program is stored on the computer-readable storage medium. When the interface testing program is executed by the processor, the steps of the interface testing method described above are implemented.

[0153] Among them, the method implemented when the interface testing program running on the processor is executed can refer to the various embodiments of the interface testing method of the present invention, which will not be elaborated here.

[0154] It should be noted that in this article, the terms "include", "comprise" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or system. Without further limitation, an element defined by the statement "including one..." does not exclude the existence of additional identical elements in the process, method, article or system including that element.

[0155] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages and disadvantages of the embodiments.

[0156] Through the description of the above embodiments, those skilled in the art can clearly understand that the above-described example methods can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art can be embodied in the form of a software product. This computer software product is stored in a storage medium as described above (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions for causing a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in various embodiments of the present invention.

[0157] The above are only the preferred embodiments of the present invention, and do not limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made by using the specification and drawings of the present invention, or directly or indirectly applied in other related technical fields, shall be equally included in the patent protection scope of the present invention.

Claims

1. An interface testing method, characterized in that, the interface testing method includes the following steps: When receiving a test instruction, obtaining a test case corresponding to the test instruction, and determining a corresponding configuration file and message template; Generating a test message according to the test case, the configuration file, and the message template; Adapting the test message according to the configuration file, and performing an interface test on the software system through the adapted test message; The step of determining the corresponding configuration file and message template includes: obtaining an environment variable and a test transaction scenario, determining the configuration file according to the environment variable and the test transaction scenario, and determining the message template according to the test transaction scenario; The step of generating a test message according to the test case, the configuration file, and the message template includes: obtaining test message data and an adaptation file in the test case, and replacing message fields and message value data in the message template according to the test message data and the adaptation file; obtaining a message format in the configuration file and a default format corresponding to the replaced message template, and comparing the message format with the default format to obtain a first comparison result; performing a preset operation on the replaced message template according to the first comparison result to generate a test message.

2. The interface testing method according to claim 1, characterized in that, the step of replacing the message fields and message value data in the message template according to the test message data and the adaptation file includes: Obtaining test message fields and test message value data in the test message data, and obtaining message fields and message value data in the message template according to a processing class in the adaptation file; Comparing the message fields with the test message fields, comparing the message value data with the test message value data to obtain a second comparison result, and replacing the message fields and message value data in the message template according to the second comparison result.

3. The interface testing method according to claim 1, characterized in that, the step of performing a preset operation on the replaced message template according to the first comparison result to generate a test message includes: If the first comparison result is that the message format is the same as the default format, retaining the default format corresponding to the replaced message template to generate a test message; If the first comparison result is that the message format is different from the default format, performing format conversion on the replaced message template according to the message format to generate a test message.

4. The interface testing method according to claim 1, characterized in that, the step of adapting the test message according to the configuration file and performing an interface test on the software system through the adapted test message includes: Obtaining protocol information in the configuration file, and adapting the test message according to the protocol information; Packetizing the adapted test message and sending it to the software system to perform an interface test on the software system.

5. The interface test method according to claim 1, characterized in that, after the step of adapting the test message according to the configuration file and performing an interface test on the software system through the adapted test message, the interface test method further includes: receiving a response message sent by the software system and identifying the message format corresponding to the response message; if the message format corresponding to the response message is the default format, determining a test result based on the response message; if the message format corresponding to the response message is not the default format, converting the message format corresponding to the response message into the default format and determining a test result based on the response message converted into the default format.

6. An interface test device, characterized in that, the interface test device includes: an acquisition module, configured to acquire a test case corresponding to the test instruction and determine a corresponding configuration file and message template when receiving the test instruction; the acquisition module is further configured to the determination of the corresponding configuration file and message template includes: acquiring environmental variables and a test transaction scenario, determining a configuration file according to the environmental variables and the test transaction scenario, and determining a message template according to the test transaction scenario; a determination module, configured to generate a test message according to the test case, the configuration file, and the message template; the determination module is further configured to the generation of the test message according to the test case, the configuration file, and the message template includes: acquiring test message data and an adaptation file in the test case, and replacing message fields and message value data in the message template according to the test message data and the adaptation file; acquiring the message format in the configuration file and the default format corresponding to the replaced message template, and comparing the message format with the default format to obtain a first comparison result; performing a preset operation on the replaced message template according to the first comparison result to generate a test message; a test module, configured to adapt the test message according to the configuration file and perform an interface test on the software system through the adapted test message.

7. An interface test device, characterized in that, the interface test device includes: a memory, a processor, and an interface test program stored on the memory and executable on the processor, and when the interface test program is executed by the processor, the steps of the interface test method according to any one of claims 1 to 5 are implemented.

8. A computer-readable storage medium, characterized in that, an interface test program is stored on the computer-readable storage medium, and when the interface test program is executed by a processor, the steps of the interface test method according to any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Test script development method and device

    CN112988601A

  • Protocol interface test method, device, computer device and storage medium

    WO2020119430A1