CN110764996A - Contract testing method, system, storage medium and terminal equipment - Google Patents

Contract testing method, system, storage medium and terminal equipment Download PDF

Info

Publication number
CN110764996A
CN110764996A CN201910840239.2A CN201910840239A CN110764996A CN 110764996 A CN110764996 A CN 110764996A CN 201910840239 A CN201910840239 A CN 201910840239A CN 110764996 A CN110764996 A CN 110764996A
Authority
CN
China
Prior art keywords
test
contract
request
configuration item
interface
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910840239.2A
Other languages
Chinese (zh)
Inventor
吕三
胡鹏强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Puhui Enterprise Management Co Ltd
Original Assignee
Ping An Puhui Enterprise Management Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Puhui Enterprise Management Co Ltd filed Critical Ping An Puhui Enterprise Management Co Ltd
Priority to CN201910840239.2A priority Critical patent/CN110764996A/en
Publication of CN110764996A publication Critical patent/CN110764996A/en
Pending legal-status Critical Current

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

Landscapes

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

Abstract

The invention relates to the technical field of testing, in particular to a contract testing method, a contract testing system, a computer readable storage medium and terminal equipment. The contract testing method comprises the following steps: when a first test request for executing a contract test for a target provider is received, acquiring a test configuration item corresponding to the first test request; generating a contract file of the contract test based on the test configuration item, wherein the contract file comprises a corresponding test interface and an expected response; sending a second test request to the test interface according to the contract file, and acquiring an actual response returned by the test interface to the second test request; and determining a matching result between the actual response and the expected response, and outputting a test result of the contract test according to the matching result, so that integration of a contract test framework of a consumption end and a providing end is reduced, execution of the contract test is facilitated, the test efficiency of the contract test is improved, and the contract test is easier to popularize and use.

Description

Contract testing method, system, storage medium and terminal equipment
Technical Field
The invention relates to the technical field of testing, in particular to a contract testing method, a contract testing system, a computer readable storage medium and terminal equipment.
Background
In software development, in order to ensure performance such as stability of developed software, it is often necessary to test the developed software. The contract test is widely applied due to the advantage that the test between the consumption end and the providing end is decoupled, but the existing contract test can be executed only after the contract test frames are integrated at the consumption end and the providing end, that is, when the contract test is performed, the contract test frames are integrated at the consumption end and the providing end firstly, and then the contract test is executed based on the contract test frames of the consumption end and the providing end, so that the test efficiency is greatly influenced.
Disclosure of Invention
Embodiments of the present invention provide a contract testing method, system, computer-readable storage medium, and terminal device, which can reduce integration of a contract testing framework at a consuming side and a providing side, so as to facilitate execution of a contract test, improve testing efficiency of the contract test, and make the contract test easier to popularize and use.
In a first aspect of the embodiments of the present invention, a contract testing method is provided, including:
when a first test request for executing a contract test for a target provider is received, acquiring a test configuration item corresponding to the first test request;
generating a contract file of the contract test based on the test configuration item, wherein the contract file comprises a corresponding test interface and an expected response;
sending a second test request to the test interface according to the contract file, and acquiring an actual response returned by the test interface to the second test request;
and determining a matching result between the actual response and the expected response, and outputting a test result of the contract test according to the matching result.
In a second aspect of the embodiments of the present invention, there is provided a contract testing system, including:
the system comprises a configuration item acquisition module, a configuration item acquisition module and a test configuration item acquisition module, wherein the configuration item acquisition module is used for acquiring a test configuration item corresponding to a first test request when the first test request for executing a contract test on a target provider is received;
the contract file generating module is used for generating a contract file of the contract test based on the test configuration item, wherein the contract file comprises a corresponding test interface and an expected response;
the actual response acquisition module is used for sending a second test request to the test interface according to the contract file and acquiring an actual response returned by the test interface to the second test request;
and the test result output module is used for determining a matching result between the actual response and the expected response and outputting the test result of the contract test according to the matching result.
In a third aspect of embodiments of the present invention, a computer-readable storage medium is provided, which stores computer-readable instructions, and when executed by a processor, implements the steps of the contract testing method according to the first aspect.
In a fourth aspect of the embodiments of the present invention, there is provided a terminal device, including a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, where the processor executes the computer-readable instructions to implement the following steps:
when a first test request for executing a contract test for a target provider is received, acquiring a test configuration item corresponding to the first test request;
generating a contract file of the contract test based on the test configuration item, wherein the contract file comprises a corresponding test interface and an expected response;
sending a second test request to the test interface according to the contract file, and acquiring an actual response returned by the test interface to the second test request;
and determining a matching result between the actual response and the expected response, and outputting a test result of the contract test according to the matching result.
According to the technical scheme, the embodiment of the invention has the following advantages:
in the embodiment of the invention, when a first test request for executing a contract test for a target providing terminal is received, a test configuration item corresponding to the first test request is obtained; generating a contract file of the contract test based on the test configuration item, wherein the contract file comprises a corresponding test interface and an expected response; sending a second test request to the test interface according to the contract file, and acquiring an actual response returned by the test interface to the second test request; and determining a matching result between the actual response and the expected response, and outputting a test result of the contract test according to the matching result. In the embodiment of the invention, only the contract testing framework needs to be integrated in the contract testing system, and when the contract testing needs to be executed, the consumption end can send the testing request and input the testing configuration item to the contract testing system, and the contract testing system can automatically generate the corresponding contract file to execute the contract testing on the target providing end, so that the contract testing framework does not need to be integrated at each consumption end and each providing end, the execution of the contract testing is convenient, the testing efficiency of the contract testing is improved, and the contract testing is easier to popularize and use.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
FIG. 1 is a flowchart of an embodiment of a contract testing method according to the present invention;
FIG. 2 is a schematic flow chart illustrating a contract testing method outputting a test result in an application scenario according to an embodiment of the present invention;
FIG. 3 is a block diagram of an embodiment of a contract testing system according to an embodiment of the present invention;
fig. 4 is a schematic diagram of a terminal device according to an embodiment of the present invention.
Detailed Description
The embodiment of the invention provides a contract testing method, a contract testing system, a computer readable storage medium and terminal equipment, which are used for reducing the integration of a contract testing framework of a consumption end and a providing end, facilitating the execution of contract testing, improving the testing efficiency of the contract testing and enabling the contract testing to be easier to popularize and use.
In order to make the objects, features and advantages of the present invention more obvious and understandable, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is obvious that the embodiments described below are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, an embodiment of the present invention provides a contract testing method, where the contract testing method includes:
step S101, when a first test request for executing contract test on a target providing terminal is received, obtaining a test configuration item corresponding to the first test request;
the contract test is to test the correctness of the connection or interface call between services and to verify whether the function provided by the providing end can really meet the requirement of the consuming end. The existing contract test generally means that a consumption end generates a contract file according to needs, uploads the contract file to a publicly accessible address, and a providing end accesses the address to obtain the contract file to execute a test process during testing, that is, in the existing contract test, contract test frames need to be respectively integrated at the consumption end and the providing end to generate the contract file at the consumption end and execute the contract file at the providing end.
The embodiment of the invention can integrate the contract testing framework in the contract testing system and can use the contract testing system as an execution main body to execute the contract testing. Specifically, when a contract test needs to be performed on a certain target provider, the consumer may send a first test request for performing the contract test on the target provider to the contract test system, and may send a test configuration item for performing the contract test to the contract test system, where the test configuration item may include a name of a test interface to be tested, a type of each entry of the test interface, a specific value of each entry of the test interface, an expected response that the test interface should return, and so on.
Further, the obtaining of the test configuration item corresponding to the first test request may include: and acquiring a requirement document corresponding to the first test request, and extracting a test configuration item corresponding to the first test request from the requirement document.
In the embodiment of the invention, a tester can lead a requirement document or an interface document into the contract test system when contract test is required according to a functional design requirement document or the interface document and the like to be realized by a consumption end, and the contract test system can automatically extract a corresponding test configuration item from the requirement document or the interface document after acquiring the requirement document or the interface document, so that the input time of the test configuration item can be greatly saved, and the test efficiency is further improved.
Step S102, generating a contract file of the contract test based on the test configuration item, wherein the contract file comprises a corresponding test interface and an expected response;
it can be understood that, after the contract testing system obtains the test configuration item, the contract testing system may automatically generate a contract file for contract testing based on the test configuration item, for example, generate a contract file in a json format, where the generated contract file may include a test interface in the test configuration item and a corresponding expected response, and so on, so that the contract testing system automatically generates the contract file according to the test configuration item without a consumer side generating the contract file, and integration of a contract testing framework in the consumer side may be reduced.
Step S103, sending a second test request to the test interface according to the contract file, and acquiring an actual response returned by the test interface to the second test request;
after the contract file is generated, the contract testing system may automatically send a second test request to the test interface to be tested of the target provider according to the contract file, where the second test request may include the type and specific value of each entry corresponding to the test interface, an expected response expected to be obtained, and the like, and after the test interface receives the second test request, the test interface may automatically test based on the entry sent by the contract testing system and return a corresponding actual response to the contract testing system during the test, that is, after the contract testing system generates the contract file, the contract file may be automatically executed to test the test interface of the target provider, so that the integration of a contract testing framework in the target provider may be reduced.
Further, in this embodiment of the present invention, the first test request may be a request for testing a plurality of test interfaces.
The sending a second test request to the test interface according to the contract file comprises: receiving case configuration information input by a user, wherein the case configuration information is configured with test relationships among the test interfaces; determining a test sequence corresponding to each test interface according to the test relation; and respectively sending a second test request to each test interface according to the test sequence and the contract file.
In the embodiment of the present invention, when the contract test needs to test a plurality of test interfaces, that is, when the first test request is a request for testing a plurality of test interfaces, and a user inputs a test configuration item corresponding to each test interface, case configuration information corresponding to the contract test may also be input, where the case configuration information may include a test relationship between each test interface, and the like, and the test relationship may be a test association relationship between each test interface, and the like. After receiving the test configuration items corresponding to the test interfaces, the contract test system can firstly generate contract files corresponding to the test interfaces based on the test configuration items corresponding to each test interface, determine the test sequence corresponding to each test interface according to the test relationship among the test interfaces, and then respectively send second test requests to each test interface according to the test sequence corresponding to each test interface and each contract file so as to respectively perform contract test on each test interface according to the test sequence.
For example, in a specific application scenario, when the contract test requires contract tests on the test interface a, the test interface B, and the test interface C, and the test relationship configured in the case configuration information is that three test interfaces can simultaneously perform tests, after the contract test system generates the contract file a according to the test configuration item corresponding to the test interface a, generates the contract file B according to the test configuration item corresponding to the test interface B, and generates the contract file C according to the test configuration item corresponding to the test interface C, the contract test system may send a second test request to the test interface a according to the contract file a, may send a second test request to the test interface B according to the contract file B, and may send a second test request to the test interface C according to the contract file C, that is, send a second test request to the three test interfaces simultaneously, so that the three test interfaces can simultaneously perform contract tests.
For another example, in another specific application scenario, when the test relationship configured in the case configuration information is that the test interface C needs to be tested after the test interface a and the test interface B are tested, and the test interface B needs to be tested after the test interface a is tested, it can be determined that the test sequence corresponding to the test interface a, the test interface B, and the test interface C is the test interface a-the test interface B-the test interface C, after the contract test system generates the contract file a according to the test configuration item corresponding to the test interface a, generates the contract file B according to the test configuration item corresponding to the test interface B, and generates the contract file C according to the test configuration item corresponding to the test interface C, the second test request can be first sent to the test interface a according to the contract file a, and after an actual response returned by the test interface a is received, and then sending a second test request to the test interface B according to the contract file B, and after receiving an actual response returned by the test interface B, sending a second test request to the test interface C according to the contract file C so as to firstly perform the contract test of the test interface A, then perform the contract test of the test interface B, and finally perform the contract test of the test interface C.
Specifically, in the embodiment of the present invention, the receiving of the case configuration information input by the user may include:
step a, obtaining login information of the user, and carrying out identity authentication on the user according to the login information;
and b, receiving case configuration information input by the user when the user passes the identity authentication.
As for the above step a and step b, it can be understood that, in the embodiment of the present invention, an authority management function may be further set in the contract testing system, so that only a specific person with a corresponding management authority may perform setting and/or modification and the like on the case configuration information and the test configuration item, thereby ensuring that a developed program and an interface meet a service requirement given by a service and/or a test, avoiding malicious modification of the case configuration information and/or the test configuration item by a person without a management authority, and ensuring test accuracy and validity of the contract test.
Therefore, when a user needs to perform a contract test on a certain target provider through the contract test system, the user needs to perform login operation in the contract test system to send login information to the contract test system, and after receiving the login information of the user, the contract test system can perform identity verification on the user according to the login information, for example, information of a user with management authority can be stored in a database corresponding to the contract test system in advance, so that after acquiring the login information, the login information can be matched with information stored in the database to determine whether the user has the management authority, so as to determine whether the identity verification of the user passes. If the user passes the identity verification, the user is indicated to have the management authority, the setting and modification of the case configuration information and/or the test configuration items and the like can be carried out, and at the moment, the contract test system can receive the case configuration information and the like input by the user.
And step S104, determining a matching result between the actual response and the expected response, and outputting a test result of the contract test according to the matching result.
It can be understood that, after the test interface completes the test and returns the corresponding actual response to the contract test system, the contract test system may match the actual response with the expected response corresponding to the first test request, so as to output the test result of the contract test according to the matching result.
In a specific application scenario, as shown in fig. 2, the determining a matching result between the actual response and the expected response, and outputting a test result of the contract test according to the matching result may include:
step S201, acquiring an actual data type and/or an actual data format corresponding to the actual response;
step S202, judging whether the actual data type and/or the actual data format is matched with the expected data type and/or the expected data format corresponding to the expected response through contract check;
step S203, if the actual data type is not matched with the expected data type or the actual data format is not matched with the expected data format, obtaining a first test result with abnormal contract test, and sending the first test result to a corresponding client in a mail mode;
and step S204, if the actual data type is matched with the expected data type and the actual data format is matched with the expected data format, obtaining a second test result of successful contract test, and sending the second test result to the client in an email mode.
In this application scenario, the contract test may be used to test whether the data type or data format corresponding to the test interface provided by the target provider or whether the data type and data format satisfy the type and/or format required by the consumer, that is, the actual response returned by the test interface may include the corresponding actual data type and/or actual data type, and so on, and therefore, after receiving the actual response returned by the test interface, the contract test system may determine, through contract check, whether the actual data type and/or actual data format of the actual response matches the expected data type and/or expected data format corresponding to the expected response, that is, the actual response returned by the test interface matches the content in the contract file, thereby determining whether the test interface meets the service requirement of the consumer.
For example, when the actual data type matches the expected data type and the actual data format matches the expected data format, the test interface may be considered to meet the service requirement of the consumer, and at this time, the first test result that the test interface meets the service requirement of the consumer may be sent to the corresponding client by using a mail, for example, the first test result that the test interface meets the service requirement of the consumer may be sent to the corresponding developer and/or the client where the tester is located by using a mail; and when the actual data type is not matched with the expected data type or the actual data format is not matched with the expected data format, the test interface is considered to be abnormal, and the abnormal condition of the test interface is sent to a corresponding developer and/or a client side where the tester is located through a mail so as to facilitate related personnel to know the change condition of the test interface in time, thereby determining whether the change of the test interface meets the content of the contract file or not in time, meeting the business requirement of a consumer side or not, modifying the developed program and/or the test configuration item according to the change condition of the test interface, and the like.
Of course, when the consuming end only requires the data type to meet the service requirement, the actual data type is only matched with the expected data type, and the testing interface can be considered to meet the service requirement of the consuming end; and when the consumption end only requires the data format to meet the service requirement, the test interface can be considered to meet the service requirement of the consumption end only when the actual data format is matched with the expected data format.
It should be noted that the sending of the test result through the mail described in this scenario is only schematically illustrated, and should not be construed as a limitation to the embodiment of the present invention, in the embodiment of the present invention, it is needless to say that any other mode capable of realizing sending of the test result may also be used to send the test result, for example, the test result may also be sent through other modes such as a short message.
In the embodiment of the invention, when a first test request for executing a contract test for a target providing terminal is received, a test configuration item corresponding to the first test request is obtained; generating a contract file of the contract test based on the test configuration item, wherein the contract file comprises a corresponding test interface and an expected response; sending a second test request to the test interface according to the contract file, and acquiring an actual response returned by the test interface to the second test request; and determining a matching result between the actual response and the expected response, and outputting a test result of the contract test according to the matching result. In the embodiment of the invention, only the contract testing framework needs to be integrated in the contract testing system, and when the contract testing needs to be executed, the consumption end can send the testing request and input the testing configuration item to the contract testing system, and the contract testing system can automatically generate the corresponding contract file to execute the contract testing on the target providing end, so that the contract testing framework does not need to be integrated at each consumption end and each providing end, the execution of the contract testing is convenient, the testing efficiency of the contract testing is improved, and the contract testing is easier to popularize and use.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
A contract test method is mainly described above, and a contract test system will be described in detail below.
Fig. 3 is a diagram illustrating an embodiment of a contract testing system according to an embodiment of the present invention. As shown in fig. 3, the contract testing system includes:
a configuration item obtaining module 301, configured to, when a first test request for executing a contract test on a target provider is received, obtain a test configuration item corresponding to the first test request;
a contract file generation module 302, configured to generate a contract file of the contract test based on the test configuration item, where the contract file includes a corresponding test interface and an expected response;
an actual response obtaining module 303, configured to send a second test request to the test interface according to the contract file, and obtain an actual response returned by the test interface for the second test request;
a test result output module 304, configured to determine a matching result between the actual response and the expected response, and output a test result of the contract test according to the matching result.
Further, the first test request is a request for testing a plurality of test interfaces;
the actual response obtaining module 303 may include:
the configuration information receiving unit is used for receiving case configuration information input by a user, and the case configuration information is configured with test relationships among the test interfaces;
the test sequence determining unit is used for determining the test sequence corresponding to each test interface according to the test relation;
and the test request sending unit is used for respectively sending a second test request to each test interface according to the test sequence and the contract file.
Preferably, the configuration information receiving unit may include:
the identity authentication subunit is used for acquiring login information of the user and authenticating the identity of the user according to the login information;
and the configuration information receiving subunit is used for receiving the case configuration information input by the user when the user passes the authentication.
Further, the configuration item obtaining module 301 may be further configured to obtain a requirement document corresponding to the first test request, and extract the test configuration item corresponding to the first test request from the requirement document.
Preferably, the test result output module 304 may include:
an actual response obtaining unit, configured to obtain an actual data type and/or an actual data format corresponding to the actual response;
an actual response matching unit, configured to determine, through contract check, whether the actual data type and/or the actual data format matches an expected data type and/or an expected data format corresponding to the expected response;
the first test result output unit is used for obtaining a first test result with abnormal contract test if the actual data type is not matched with the expected data type or the actual data format is not matched with the expected data format, and sending the first test result to a corresponding client in a mail mode;
and the second test result output unit is used for obtaining a second test result of successful contract test and sending the second test result to the client in a mail mode if the actual data type is matched with the expected data type and the actual data format is matched with the expected data format.
Fig. 4 is a schematic diagram of a terminal device according to an embodiment of the present invention. As shown in fig. 4, the terminal device 4 of this embodiment includes: a processor 40, a memory 41, and computer readable instructions 42, such as a contract test program, stored in the memory 41 and executable on the processor 40. The processor 40, when executing the computer readable instructions 42, implements the steps in the various contract testing method embodiments described above, such as the steps S101-S104 shown in fig. 1. Alternatively, the processor 40 executes the computer readable instructions 42 to realize the functions of the modules/units in the system embodiments, such as the modules 301 to 304 shown in fig. 3.
Illustratively, the computer readable instructions 42 may be partitioned into one or more modules/units that are stored in the memory 41 and executed by the processor 40 to implement the present invention. The one or more modules/units may be a series of computer-readable instruction segments capable of performing specific functions, which are used for describing the execution process of the computer-readable instructions 42 in the terminal device 4.
The terminal device 4 may be a desktop computer, a notebook, a palm computer, a cloud server, or other computing devices. The terminal device may include, but is not limited to, a processor 40, a memory 41. Those skilled in the art will appreciate that fig. 4 is merely an example of a terminal device 4 and does not constitute a limitation of terminal device 4 and may include more or fewer components than shown, or some components may be combined, or different components, e.g., the terminal device may also include input-output devices, network access devices, buses, etc.
The Processor 40 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 41 may be an internal storage unit of the terminal device 4, such as a hard disk or a memory of the terminal device 4. The memory 41 may also be an external storage device of the terminal device 4, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the terminal device 4. Further, the memory 41 may also include both an internal storage unit and an external storage device of the terminal device 4. The memory 41 is used for storing the computer readable instructions and other programs and data required by the terminal device. The memory 41 may also be used to temporarily store data that has been output or is to be output.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. A contract testing method, comprising:
when a first test request for executing a contract test for a target provider is received, acquiring a test configuration item corresponding to the first test request;
generating a contract file of the contract test based on the test configuration item, wherein the contract file comprises a corresponding test interface and an expected response;
sending a second test request to the test interface according to the contract file, and acquiring an actual response returned by the test interface to the second test request;
and determining a matching result between the actual response and the expected response, and outputting a test result of the contract test according to the matching result.
2. The contract testing method according to claim 1, wherein the first test request is a request for testing a plurality of test interfaces;
the sending a second test request to the test interface according to the contract file comprises:
receiving case configuration information input by a user, wherein the case configuration information is configured with test relationships among the test interfaces;
determining a test sequence corresponding to each test interface according to the test relation;
and respectively sending a second test request to each test interface according to the test sequence and the contract file.
3. The contract testing method according to claim 2, wherein the receiving of the case configuration information input by the user comprises:
obtaining login information of the user, and performing identity authentication on the user according to the login information;
and when the user passes the authentication, receiving the case configuration information input by the user.
4. The contract testing method according to claim 1, wherein the obtaining of the test configuration item corresponding to the first test request includes:
and acquiring a requirement document corresponding to the first test request, and extracting a test configuration item corresponding to the first test request from the requirement document.
5. The contract testing method according to any one of claims 1 to 4, wherein the determining a matching result between the actual response and the expected response and outputting a test result of the contract test according to the matching result includes:
acquiring an actual data type and/or an actual data format corresponding to the actual response;
whether the actual data type and/or the actual data format is matched with the expected data type and/or the expected data format corresponding to the expected response is judged through contract checking;
if the actual data type is not matched with the expected data type or the actual data format is not matched with the expected data format, obtaining a first test result with abnormal contract test, and sending the first test result to a corresponding client side in a mail mode;
and if the actual data type is matched with the expected data type and the actual data format is matched with the expected data format, obtaining a second test result of successful contract test, and sending the second test result to the client in an email mode.
6. A contract testing system, comprising:
the system comprises a configuration item acquisition module, a configuration item acquisition module and a test configuration item acquisition module, wherein the configuration item acquisition module is used for acquiring a test configuration item corresponding to a first test request when the first test request for executing a contract test on a target provider is received;
the contract file generating module is used for generating a contract file of the contract test based on the test configuration item, wherein the contract file comprises a corresponding test interface and an expected response;
the actual response acquisition module is used for sending a second test request to the test interface according to the contract file and acquiring an actual response returned by the test interface to the second test request;
and the test result output module is used for determining a matching result between the actual response and the expected response and outputting the test result of the contract test according to the matching result.
7. A computer readable storage medium storing computer readable instructions, which when executed by a processor implement the steps of the contract testing method according to any one of claims 1 to 5.
8. A terminal device comprising a memory, a processor, and computer readable instructions stored in the memory and executable on the processor, wherein the processor when executing the computer readable instructions performs the steps of:
when a first test request for executing a contract test for a target provider is received, acquiring a test configuration item corresponding to the first test request;
generating a contract file of the contract test based on the test configuration item, wherein the contract file comprises a corresponding test interface and an expected response;
sending a second test request to the test interface according to the contract file, and acquiring an actual response returned by the test interface to the second test request;
and determining a matching result between the actual response and the expected response, and outputting a test result of the contract test according to the matching result.
9. The terminal device of claim 8, wherein the first test request is a request to test a plurality of test interfaces;
the sending a second test request to the test interface according to the contract file comprises:
receiving case configuration information input by a user, wherein the case configuration information is configured with test relationships among the test interfaces;
determining a test sequence corresponding to each test interface according to the test relation;
and respectively sending a second test request to each test interface according to the test sequence and the contract file.
10. The terminal device according to claim 8, wherein the obtaining of the test configuration item corresponding to the first test request includes:
and acquiring a requirement document corresponding to the first test request, and extracting a test configuration item corresponding to the first test request from the requirement document.
CN201910840239.2A 2019-09-06 2019-09-06 Contract testing method, system, storage medium and terminal equipment Pending CN110764996A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910840239.2A CN110764996A (en) 2019-09-06 2019-09-06 Contract testing method, system, storage medium and terminal equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910840239.2A CN110764996A (en) 2019-09-06 2019-09-06 Contract testing method, system, storage medium and terminal equipment

Publications (1)

Publication Number Publication Date
CN110764996A true CN110764996A (en) 2020-02-07

Family

ID=69330493

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910840239.2A Pending CN110764996A (en) 2019-09-06 2019-09-06 Contract testing method, system, storage medium and terminal equipment

Country Status (1)

Country Link
CN (1) CN110764996A (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112100058A (en) * 2020-08-19 2020-12-18 展讯半导体(南京)有限公司 Interface specification detection method and device
CN112905458A (en) * 2021-02-08 2021-06-04 中国工商银行股份有限公司 Interface automation contract testing method and device
CN115473832A (en) * 2022-08-12 2022-12-13 重庆长安汽车股份有限公司 Vehicle networking terminal cloud communication testing method, device, server, client and system
CN116166568A (en) * 2023-04-25 2023-05-26 安元科技股份有限公司 Method and system for automatically checking interface contract applied to functional test

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112100058A (en) * 2020-08-19 2020-12-18 展讯半导体(南京)有限公司 Interface specification detection method and device
CN112905458A (en) * 2021-02-08 2021-06-04 中国工商银行股份有限公司 Interface automation contract testing method and device
CN112905458B (en) * 2021-02-08 2024-05-07 中国工商银行股份有限公司 Interface automatic contract testing method and device
CN115473832A (en) * 2022-08-12 2022-12-13 重庆长安汽车股份有限公司 Vehicle networking terminal cloud communication testing method, device, server, client and system
CN115473832B (en) * 2022-08-12 2023-06-02 重庆长安汽车股份有限公司 Internet of vehicles end cloud communication testing method, device, server, client and system
CN116166568A (en) * 2023-04-25 2023-05-26 安元科技股份有限公司 Method and system for automatically checking interface contract applied to functional test

Similar Documents

Publication Publication Date Title
CN110764996A (en) Contract testing method, system, storage medium and terminal equipment
US11830001B2 (en) Blockchain consensus method, accounting node and node
CN109474578B (en) Message checking method, device, computer equipment and storage medium
CN111177005B (en) Service application testing method, device, server and storage medium
US20190386834A1 (en) Blockchain management apparatus, blockchain management method, and program
CN109726108B (en) Front-end code testing method, device, system and medium based on analog data
CN108255701B (en) Scene testing method and mobile terminal
CN111143087A (en) Interface calling method and device, storage medium and server
US10181024B2 (en) Method, device, and system for updating authentication information
CN110221948B (en) Test script generation method, test script generation device, computer device and storage medium
CN110633198A (en) Block chain-based software test data storage method and system
CN109815112B (en) Data debugging method and device based on functional test and terminal equipment
CN109145651B (en) Data processing method and device
CN111190551B (en) Redis data migration system, migration method, migration device and terminal
CN110046086B (en) Expected data generation method and device for test and electronic equipment
CN114266539A (en) File flow processing method, system, device and computer readable storage medium
CN110532186B (en) Method, device, electronic equipment and storage medium for testing by using verification code
CN115599652A (en) Method, device, equipment and storage medium for testing system performance parameters
CN115774584A (en) Data processing method and device, electronic equipment and storage medium
CN111190824B (en) Monitoring method, device, terminal equipment and storage medium
US11218479B2 (en) Authentication broker apparatus and non-transitory computer readable medium storing authentication broker program
CN112380128A (en) Automatic testing method and device of intelligent contract, computer equipment and storage medium
CN108243180B (en) Bank policy data docking method and policy data server
CN111427778A (en) Test method, test device, terminal equipment and storage medium
CN111240733A (en) Data acquisition method and device based on multiple third-party interfaces

Legal Events

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