CN116756046A - Automatic interface testing method, device, equipment and storage medium - Google Patents

Automatic interface testing method, device, equipment and storage medium Download PDF

Info

Publication number
CN116756046A
CN116756046A CN202311027455.8A CN202311027455A CN116756046A CN 116756046 A CN116756046 A CN 116756046A CN 202311027455 A CN202311027455 A CN 202311027455A CN 116756046 A CN116756046 A CN 116756046A
Authority
CN
China
Prior art keywords
interface
data
test script
flag bit
expected data
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.)
Granted
Application number
CN202311027455.8A
Other languages
Chinese (zh)
Other versions
CN116756046B (en
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.)
Hunan Changyin May 8th Consumer Finance Co ltd
Original Assignee
Hunan Changyin May 8th Consumer Finance 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 Hunan Changyin May 8th Consumer Finance Co ltd filed Critical Hunan Changyin May 8th Consumer Finance Co ltd
Priority to CN202311027455.8A priority Critical patent/CN116756046B/en
Publication of CN116756046A publication Critical patent/CN116756046A/en
Application granted granted Critical
Publication of CN116756046B publication Critical patent/CN116756046B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The application discloses an automatic interface testing method, device, equipment and storage medium, relating to the field of automatic testing, comprising the following steps: creating a configuration file of an automatic test script and determining a current calling interface; configuring the zone bit of the configuration file according to the received zone bit configuration instruction, and running an automatic test script to generate expected data corresponding to the current calling interface; updating the expected data to an expected data table, updating the flag bit of the configuration file according to the flag bit updating instruction, and rerun the automatic test script to generate real-time data; comparing the real-time data with the expected data, determining whether a change interface exists, if so, updating the preset automatic test script based on the change interface, and jumping to the step of configuring the zone bit of the configuration file according to the received zone bit configuration instruction. Thus, when the interface is changed, the expected data of the changed interface can be automatically updated according to the configuration file.

Description

Automatic interface testing method, device, equipment and storage medium
Technical Field
The present invention relates to the field of automated testing, and in particular, to an interface automated testing method, apparatus, device, and storage medium.
Background
In an automated testing scenario for financial credit transactions, the transactions range from user credit, borrowing, to repayment, and the life cycle of a loan encompasses many flows, with relatively complex transaction logic. Taking repayment plan query as an example, the expected data through the repayment plan query interface are different in different repayment period numbers, different loan principal and different repayment modes. And aiming at different repayment scene combinations, for example, the user pays normally first, later overdue and finally overdue changes normally, the user loan related information in different periods can be changed, if the automatic test script is used for realizing one pass, more time and manpower are required to be consumed for combing and developing code logic, and the improvement of the test efficiency brought by the automatic test is difficult to see in a short time.
In the prior art, expected data generated at different stages of the interface is stored in a hard-coded mode, but the mode needs to maintain a large amount of expected data of the interface of a user at different repayment stages. In a complex test scenario and a large data volume scenario, the manner of manually storing expected data in a text form may result in reduced expansibility and maintainability of an automated test scenario, for example, a user may add a key field by referring to an information query interface, and if the interface is called when a plurality of positions are involved in the automated test scenario, the manner of manually replacing the expected data is particularly complicated.
Disclosure of Invention
Accordingly, the present application is directed to an automatic interface testing method, apparatus, device and storage medium, which can automatically update the expected data of the changed interface according to the configuration file when the interface is changed, so that the latest expected data can be used for verification in the repeated operation of the subsequent automatic test. The specific scheme is as follows:
in a first aspect, the application discloses an automated interface testing method, comprising the following steps:
creating a configuration file of a preset automatic test script, and determining a current calling interface in the preset automatic test script;
configuring a flag bit of the configuration file according to the received flag bit configuration instruction, and running the preset automatic test script based on the configured flag bit field to generate expected data corresponding to the current calling interface;
updating the expected data to an expected data table, updating the zone bit of the configuration file according to a zone bit updating instruction, and rerun the preset automatic test script based on the updated zone bit field to generate real-time data;
and comparing the real-time data with the expected data in the expected data table, determining whether a change interface exists or not based on a comparison result, if so, updating the preset automatic test script based on the change interface, jumping to the configuration of the zone bit of the configuration file according to the received zone bit configuration instruction, running the preset automatic test script based on the configured zone bit field, and generating expected data corresponding to the current calling interface.
Optionally, the creating a configuration file of the preset automation test script and determining a current call interface in the preset automation test script include:
creating a configuration file of a preset automatic test script, and determining an interface name of a current calling interface in the preset automatic test script;
and adding the interface name to the configuration file to determine the interface name as a parameter for running the preset automation test script.
Optionally, the configuring the flag bit of the configuration file according to the received flag bit configuration instruction, and running the preset automation test script based on the configured flag bit field, to generate the expected data corresponding to the current calling interface, includes:
judging whether a flag bit configuration instruction is received, if so, configuring the flag bit of the preset configuration file as an update field based on the flag bit configuration instruction;
and running the preset automatic test script, reading the update field to call a current user binding card interface to generate expected user data, calling a current borrowing interface to generate expected borrowing data based on the user data, and calling a current repayment interface to generate expected repayment data.
Optionally, the updating the expected data to the expected data table, updating the flag bit of the configuration file according to a flag bit updating instruction, and rerun the preset automation test script based on the updated flag bit field, to generate real-time data, including:
updating historical prospective data currently stored in the prospective data sheet based on the prospective user data, the prospective borrowing data, and the prospective repayment data;
judging whether a flag bit updating instruction is received, if so, updating the flag bit of the configuration file into a check field based on the flag bit updating instruction, and rerun the preset automatic test script based on the check field to generate real-time data.
Optionally, the comparing the real-time data with the expected data in the expected data table, determining whether a change interface exists based on a comparison result, if so, updating the preset automation test script based on the change interface, jumping to the configuration of the flag bit of the configuration file according to the received flag bit configuration instruction, and running the preset automation test script based on the configured flag bit field, so as to generate the expected data corresponding to the current calling interface, and the step includes:
Reading the expected data stored in the expected data table, and performing data comparison operation on the expected data and the real-time data to determine whether a data difference exists between the expected data and the real-time data based on a comparison result;
if the comparison result represents that the data difference exists, determining a change interface based on the comparison result, and determining an interface name of the change interface;
and writing the interface name into the configuration file to finish updating the preset automatic test script, and re-jumping to the step of configuring the flag bit of the configuration file according to the received flag bit configuration instruction, and running the preset automatic test script based on the configured flag bit field to generate expected data corresponding to the current calling interface.
Optionally, after the reading the expected data stored in the expected data table and performing a data comparison operation on the expected data and the real-time data to determine whether a data difference exists between the expected data and the real-time data based on a comparison result, the method further includes:
if the comparison result represents that the data difference exists and a change interface does not exist, judging whether a script updating instruction is received or not;
And if the script updating instruction is received to update the preset automatic test script, re-jumping to the step of configuring the flag bit of the configuration file according to the received flag bit configuration instruction, and running the preset automatic test script based on the configured flag bit field to generate expected data corresponding to the current calling interface.
Optionally, after the reading the expected data stored in the expected data table and performing a data comparison operation on the expected data and the real-time data to determine whether a data difference exists between the expected data and the real-time data based on a comparison result, the method further includes:
and if the comparison result indicates that the data difference does not exist, performing regression testing on the current calling interface in the automatic test script so as to rerun the preset automatic test script based on a preset frequency.
In a second aspect, the present application discloses an automated interface testing apparatus, comprising:
the interface determining module is used for creating a configuration file of a preset automatic test script and determining a current calling interface in the preset automatic test script;
The first data generation module is used for configuring the zone bit of the configuration file according to the received zone bit configuration instruction, running the preset automatic test script based on the configured zone bit field and generating expected data corresponding to the current calling interface;
the second data generation module is used for updating the expected data to an expected data table, updating the zone bit of the configuration file according to a zone bit updating instruction, and rerun the preset automatic test script based on the updated zone bit field to generate real-time data;
the data comparison module is used for comparing the real-time data with the expected data in the expected data table, determining whether a change interface exists or not based on a comparison result, and updating the preset automatic test script based on the change interface if the change interface exists;
the step jump module is used for jumping to the step of configuring the zone bit of the configuration file according to the received zone bit configuration instruction, running the preset automatic test script based on the configured zone bit field and generating expected data corresponding to the current calling interface.
In a third aspect, the present application discloses an electronic device, comprising:
a memory for storing a computer program;
and the processor is used for executing the computer program to realize the interface automation test method.
In a fourth aspect, the present application discloses a computer readable storage medium storing a computer program which, when executed by a processor, implements the aforementioned interface automation test method.
In the method, a configuration file of a preset automatic test script is firstly created, a current calling interface in the preset automatic test script is determined, a flag bit of the configuration file is configured according to a received flag bit configuration instruction, the preset automatic test script is operated based on a configured flag bit field, expected data corresponding to the current calling interface is generated, then the expected data is updated to an expected data table, the flag bit of the configuration file is updated according to a flag bit updating instruction, the preset automatic test script is rerun based on an updated flag bit field, real-time data is generated, finally the real-time data and the expected data in the expected data table are subjected to comparison operation, whether a change interface exists or not is determined based on a comparison result, if yes, the preset automatic test script is updated based on the change interface, the flag bit of the configuration file is configured according to the received flag bit configuration instruction, the preset automatic test script is operated based on the configured flag bit field, and the preset automatic test script is generated, and the expected data corresponding to the current calling interface is generated. Therefore, by the interface automation test method, the configuration file of the preset automation test script can be configured, the determined interface name required to be called by the preset automation test script is written into the configuration file, the flag bit in the configuration file is configured, the preset automation test script is operated, expected data is generated, the flag bit is updated, the preset automation test script is rerun, real-time data is generated, the difference between the real-time data and the expected data is determined, the changed interface is determined through the determined difference, the preset automation test script is updated through the changed interface, the flag bit is configured again after the update is completed, and new round of expected data is generated. In this way, when the interface is changed, the expected data of the changed interface can be automatically updated according to the configuration file, so that the latest expected data can be used for verification in the repeated operation of the subsequent automatic test.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings that are required to be used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only embodiments of the present application, and that other drawings can be obtained according to the provided drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of an automated interface testing method provided by the application;
FIG. 2 is a timing diagram of an automated interface test method according to the present application;
FIG. 3 is a schematic diagram of an automated interface testing apparatus according to the present application;
fig. 4 is a block diagram of an electronic device according to the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
In the prior art, expected data generated at different stages of the interface is stored in a hard-coded mode, but the mode needs to maintain a large amount of expected data of the interface of a user at different repayment stages. In a complex test scenario and a large data volume scenario, the manner of manually storing expected data in a text form may result in reduced expansibility and maintainability of an automated test scenario, for example, a user may add a key field by referring to an information query interface, and if the interface is called when a plurality of positions are involved in the automated test scenario, the manner of manually replacing the expected data is particularly complicated.
In order to solve the technical problems, the invention aims to provide an automatic interface testing method, device, equipment and storage medium, which can automatically update expected data of a changed interface according to a configuration file when the interface is changed, so that the latest expected data can be used for verification in repeated operation of subsequent automatic tests.
Referring to fig. 1, the embodiment of the invention discloses an automatic interface testing method, which comprises the following steps:
and S11, creating a configuration file of a preset automatic test script, and determining a current calling interface in the preset automatic test script.
In this embodiment, creating a configuration file of a preset automation test script, and determining a current call interface in the preset automation test script includes: creating a configuration file of a preset automatic test script, and determining an interface name of a current calling interface in the preset automatic test script; and adding the interface name to the configuration file to determine the interface name as a parameter for running the preset automation test script. That is, if an automated test is required, an automated test script is first required to be written, in this embodiment, a pytest framework is written by using a Python language, after the automated test script is successfully written, a configuration file is required to be created for the automated test script, the automated test script is run according to parameters in the created configuration file, the automated test script is taken as an example of a credit-borrowing and repayment full-service link automated test script, multiple types of repayment interfaces, such as a credit-borrowing and repayment credit limit interface, a query borrowing and repayment information interface, a query repayment plan interface, a query repayment history interface, and the like, are required to be determined, and the interface name of the current calling interface of the credit-borrowing and repayment full-service link automated test script is required to be written into the configuration file, so that after the interface name is read in the script running process, a corresponding interface can be called according to the interface name.
And step S12, configuring the zone bit of the configuration file according to the received zone bit configuration instruction, and running the preset automatic test script based on the configured zone bit field to generate expected data corresponding to the current calling interface.
In this embodiment, configuring the flag bit of the configuration file according to the received flag bit configuration instruction, and running the preset automation test script based on the configured flag bit field, to generate the expected data corresponding to the current call interface, including: judging whether a flag bit configuration instruction is received, if so, configuring the flag bit of the preset configuration file as an update field based on the flag bit configuration instruction; and running the preset automatic test script, reading the update field to call a current user binding card interface to generate expected user data, calling a current borrowing interface to generate expected borrowing data based on the user data, and calling a current repayment interface to generate expected repayment data. That is, different operations can be performed according to different flag bits of the configuration file in the running process of the preset automatic test script, when a flag bit configuration instruction is received, that is, an instruction for setting the flag bit in the configuration file by the user side is received, the flag bit of the configuration file can be set as an update field according to the received flag bit configuration instruction, and when the preset automatic test script detects that the flag bit of the configuration file is update in the running process, expected data are required to be generated to update the expected data currently stored in the preset expected data table, so that after the flag bit of the configuration file is read by the preset automatic test script, a relevant interface can be called through an interface name stored in the configuration file to generate corresponding expected data. Taking a repayment service as an example, the preset automatic test script can call a current user binding card interface to generate expected user data, call a current borrowing interface to generate expected borrowing data according to the expected user data, simulate a plurality of day cutting operations of an account and call the current repayment interface to generate the expected repayment data. The date switching operation is an operation of switching the accounting date in the financial accounting system.
And step S13, updating the expected data to an expected data table, updating the zone bit of the configuration file according to a zone bit updating instruction, and rerun the preset automatic test script based on the updated zone bit field to generate real-time data.
In this embodiment, updating the expected data to an expected data table, updating the flag bit of the configuration file according to a flag bit update instruction, and rerun the preset automation test script based on the updated flag bit field, to generate real-time data, including: updating historical prospective data currently stored in the prospective data sheet based on the prospective user data, the prospective borrowing data, and the prospective repayment data; judging whether a flag bit updating instruction is received, if so, updating the flag bit of the configuration file into a check field based on the flag bit updating instruction, and rerun the preset automatic test script based on the check field to generate real-time data. That is, when the expected data is generated, the expected data needs to be updated into the expected data table, it should be noted that the expected data table stores the generated expected data, and the expected data stored in the expected data table is the expected data generated in the previous round before the expected data of the current round is generated, so after the expected data of the current round is generated, the expected data table needs to be updated according to the generated expected data. And due to the difference of calling interfaces, the data stored in the expected data table comprises fields including, but not limited to, a newly added primary key id, a client name, a borrowing flag, an interface name, expected data, a version number, creation time, creator, update time, updater and the like. Taking the borrowing and repayment service as an example, after expected user data, expected borrowing data and expected repayment data are generated, the expected user data, the expected borrowing data and the expected repayment data of the previous round need to be updated through the expected user data, the expected borrowing data and the expected repayment data. It should be further noted that, updating the data in the expected data table stores the expected data of the current generation round into the expected data table, and does not overwrite the expected data of the previous round stored in the expected data table, and the expected data of each round records the version number of the expected data when stored, so as to trace the data by differentiating the version numbers.
After the expected data table is updated successfully, whether a flag bit updating instruction is received needs to be judged, if the flag bit updating instruction is received, the flag bit needs to be updated based on the received flag bit updating instruction, the flag bit in the configuration file is updated from an update field to a check field, it needs to be explained that after the flag bit is updated successfully, a preset automatic test script needs to be rerun, and in the process of running the automatic test script this time, if the flag bit in the configuration file is detected to be the check field, the interface needs to be recalled to generate real-time data, and the real-time data is generated for comparing the real-time data with the expected data stored in the expected data table so as to judge whether a data difference exists between the expected data and the real-time data.
And S14, comparing the real-time data with the expected data in the expected data table, determining whether a change interface exists or not based on a comparison result, if so, updating the preset automatic test script based on the change interface, jumping to the configuration of the zone bit of the configuration file according to the received zone bit configuration instruction, and running the preset automatic test script based on the configured zone bit field to generate expected data corresponding to the current calling interface.
In this embodiment, comparing the real-time data with the expected data in the expected data table, determining whether a change interface exists based on a comparison result, if so, updating the preset automation test script based on the change interface, jumping to the configuration of the flag bit of the configuration file according to the received flag bit configuration instruction, and running the preset automation test script based on the configured flag bit field, so as to generate the expected data corresponding to the current calling interface, including: reading the expected data stored in the expected data table, and performing data comparison operation on the expected data and the real-time data to determine whether a data difference exists between the expected data and the real-time data based on a comparison result; if the comparison result represents that the data difference exists, determining a change interface based on the comparison result, and determining an interface name of the change interface; and writing the interface name into the configuration file to finish updating the preset automatic test script, and re-jumping to the step of configuring the flag bit of the configuration file according to the received flag bit configuration instruction, and running the preset automatic test script based on the configured flag bit field to generate expected data corresponding to the current calling interface. That is, after the flag bit in the configuration file is read by the preset automation script as the check field and the real-time data is generated, the real-time data and the expected data stored in the expected data table are required to be compared, and corresponding comparison results are generated, if the generated comparison results represent that data differences exist between the expected data and the real-time data, and the interface called by the preset automation script changes in the running process, a changed interface which is changed is required to be determined, the changed interface name of the changed interface is determined, the interface name in the configuration file is updated based on the determined changed interface name, and then the preset automation test script is updated.
It should be noted that, after the reading the expected data stored in the expected data table and performing a data comparison operation on the expected data and the real-time data to determine whether there is a data difference between the expected data and the real-time data based on the comparison result, the method further includes: if the comparison result represents that the data difference exists and a change interface does not exist, judging whether a script updating instruction is received or not; and if the script updating instruction is received to update the preset automatic test script, re-jumping to the step of configuring the flag bit of the configuration file according to the received flag bit configuration instruction, and running the preset automatic test script based on the configured flag bit field to generate expected data corresponding to the current calling interface. That is, if the generated comparison result indicates that there is a data difference between the expected data and the real-time data, and the interface called by the preset automation script in the running process is not changed, then the interface BUG may exist, after the manual judgment is needed, a corresponding script update instruction is input, so that the preset automation test script is updated correspondingly based on the script update instruction, after the updating is completed, the step of re-jumping to the configuration of the flag bit of the configuration file according to the received flag bit configuration instruction, and running the preset automation test script based on the configured flag bit field, so as to generate the expected data corresponding to the current calling interface.
Further, after the update of the preset automatic test script is completed, the step of jumping to configure the flag bit of the configuration file according to the received flag bit configuration instruction, running the preset automatic test script based on the configured flag bit field, and generating expected data corresponding to the current calling interface is needed, so that the updated automatic test script is rerun, expected data of the next round is generated according to the updated interface, and the expected data in the expected data table is updated according to the generated expected data of the next round.
It should be noted that, after the reading the expected data stored in the expected data table and performing a data comparison operation on the expected data and the real-time data to determine whether there is a data difference between the expected data and the real-time data based on the comparison result, the method further includes: and if the comparison result indicates that the data difference does not exist, performing regression testing on the current calling interface in the automatic test script so as to rerun the preset automatic test script based on a preset frequency. That is, if the comparison result of the real-time data and the expected data indicates that there is no data difference between the real-time data and the expected data, that is, the expected data and the real-time data stored in the expected data table are completely consistent, the indication is that there is no interface change, the configuration file flag bit can be kept unchanged as a check field, and the automatic test script is rerun based on a preset frequency, so that regression test is performed, and consistency of the expected data and the real-time data is ensured. It should be noted that, the preset frequency may be set by itself according to a requirement of the user side, which is not limited in this embodiment.
It can be seen that, in this embodiment, a configuration file of a preset automatic test script is first created, a current call interface in the preset automatic test script is determined, a flag bit of the configuration file is configured according to a received flag bit configuration instruction, the preset automatic test script is operated based on a configured flag bit field, expected data corresponding to the current call interface is generated, then the expected data is updated to an expected data table, a flag bit of the configuration file is updated according to a flag bit update instruction, the preset automatic test script is rerun based on an updated flag bit field, real-time data is generated, finally, a comparison operation is performed on the real-time data and the expected data in the expected data table, whether a change interface exists or not is determined based on a comparison result, if yes, the preset automatic test script is updated based on the change interface, the flag bit of the configuration file is configured according to the received flag bit configuration instruction, the preset automatic test script is operated based on the configured flag bit field, and the step of the preset automatic test script is generated corresponding to the current call interface is performed. Therefore, by the interface automation test method, the configuration file of the preset automation test script can be configured, the determined interface name required to be called by the preset automation test script is written into the configuration file, the flag bit in the configuration file is configured, the preset automation test script is operated, expected data is generated, the flag bit is updated, the preset automation test script is rerun, real-time data is generated, the difference between the real-time data and the expected data is determined, the changed interface is determined through the determined difference, the preset automation test script is updated through the changed interface, the flag bit is configured again after the update is completed, and new round of expected data is generated. Therefore, on one hand, if the expected data of the interface changes due to the existence of a newly added interface or interface change, the expected data does not need to be manually replaced, so that the maintenance cost of an automatic test script can be reduced, and the test efficiency of the automatic test of the interface is improved; on the other hand, the repeated change records of the expected data are stored in the data table, and the backtracking can be carried out by distinguishing the version numbers, so that whether the execution result of the automatic test is accurate or not can be conveniently checked, and the effectiveness of the automatic test of the interface is ensured; on the other hand, the regression test can be performed by executing the same set of automatic test script to verify the generated expected data, so that the reliability of the automatic test of the interface is ensured.
Referring to fig. 2, the application discloses an automatic interface testing method, which comprises the following steps:
writing an automatic test script by using a pytest frame, creating a configuration file for the generated automatic test script, writing an interface name of an interface to be called into the configuration file, so that after the interface name is read in the script operation process, a corresponding interface can be called according to the interface name, a flag bit of the configuration file is set to be update, when the automatic test script detects that the flag bit of the configuration file is an update field in the operation process, expected data is generated by calling the corresponding interface, the expected data currently stored in a preset expected data table is updated based on the generated expected data, the flag bit of the configuration file is updated to be a check field, and in the process of running the automatic test script, if the flag bit in the configuration file is detected to be a check field, the interface is recalled to generate real-time data to compare the real-time data with expected data stored in an expected data table, if the generated comparison result represents that data difference exists between the expected data and the real-time data, and the interface called by the preset automation script is changed in the running process, a changed interface which is changed is required to be determined, the changed interface name of the changed interface is determined, the interface name in the configuration file is updated based on the determined changed interface name, the preset automation test script is updated, and after the updating is completed, the flag bit of the configuration file is reset to be the update field, and the interface automation test flow is rerun. If the generated comparison result represents that the expected data and the real-time data have data difference, and the interface called by the preset automation script in the running process is not changed, the interface BUG possibly exists, after the manual judgment is needed, a corresponding script updating instruction is input, so that the preset automation test script is correspondingly updated through the script updating instruction, after the updating is finished, the configuration file is re-jumped to the flag bit according to the received flag bit configuration instruction, and the preset automation test script is run based on the configured flag bit field, so that the expected data corresponding to the current calling interface is generated. If no data difference exists between the expected data and the real-time data, the fact that no interface change exists is characterized, and regression testing is conducted on the interface to ensure the consistency of the expected data and the real-time data.
Referring to fig. 3, an embodiment of the present invention discloses an automatic interface testing device, which includes:
the interface determining module 11 is used for creating a configuration file of a preset automatic test script and determining a current calling interface in the preset automatic test script;
the first data generating module 12 is configured to configure a flag bit of the configuration file according to the received flag bit configuration instruction, and run the preset automatic test script based on the configured flag bit field to generate expected data corresponding to the current calling interface;
the second data generating module 13 is configured to update the expected data to an expected data table, update the flag bit of the configuration file according to a flag bit update instruction, and rerun the preset automatic test script based on the updated flag bit field to generate real-time data;
the data comparison module 14 is configured to perform a comparison operation on the real-time data and the expected data in the expected data table, determine whether a change interface exists based on a comparison result, and update the preset automation test script based on the change interface if the change interface exists;
and the step jump module 15 is used for jumping to the step of configuring the flag bit of the configuration file according to the received flag bit configuration instruction, running the preset automatic test script based on the configured flag bit field and generating expected data corresponding to the current calling interface.
It can be seen that, in this embodiment, a configuration file of a preset automatic test script is first created, a current call interface in the preset automatic test script is determined, a flag bit of the configuration file is configured according to a received flag bit configuration instruction, the preset automatic test script is operated based on a configured flag bit field, expected data corresponding to the current call interface is generated, then the expected data is updated to an expected data table, a flag bit of the configuration file is updated according to a flag bit update instruction, the preset automatic test script is rerun based on an updated flag bit field, real-time data is generated, finally, a comparison operation is performed on the real-time data and the expected data in the expected data table, whether a change interface exists or not is determined based on a comparison result, if yes, the preset automatic test script is updated based on the change interface, the flag bit of the configuration file is configured according to the received flag bit configuration instruction, the preset automatic test script is operated based on the configured flag bit field, and the step of the preset automatic test script is generated corresponding to the current call interface is performed. Therefore, by the interface automation test method, the configuration file of the preset automation test script can be configured, the determined interface name required to be called by the preset automation test script is written into the configuration file, the flag bit in the configuration file is configured, the preset automation test script is operated, expected data is generated, the flag bit is updated, the preset automation test script is rerun, real-time data is generated, the difference between the real-time data and the expected data is determined, the changed interface is determined through the determined difference, the preset automation test script is updated through the changed interface, the flag bit is configured again after the update is completed, and new round of expected data is generated. Therefore, on one hand, if the expected data of the interface changes due to the existence of a newly added interface or interface change, the expected data does not need to be manually replaced, so that the maintenance cost of an automatic test script can be reduced, and the test efficiency of the automatic test of the interface is improved; on the other hand, the repeated change records of the expected data are stored in the data table, and the backtracking can be carried out by distinguishing the version numbers, so that whether the execution result of the automatic test is accurate or not can be conveniently checked, and the effectiveness of the automatic test of the interface is ensured; on the other hand, the regression test can be performed by executing the same set of automatic test script to verify the generated expected data, so that the reliability of the automatic test of the interface is ensured.
In some embodiments, the interface determining module 11 may specifically include:
the interface name determining unit is used for creating a configuration file of a preset automatic test script and determining the interface name of a current calling interface in the preset automatic test script;
and the parameter determining unit is used for adding the interface name to the configuration file so as to determine the interface name as a parameter for running the preset automatic test script.
In some embodiments, the first data generating module 12 may specifically include:
the first flag bit configuration unit is used for judging whether a flag bit configuration instruction is received, and if the flag bit configuration instruction is received, the flag bit of the preset configuration file is configured into an update field based on the flag bit configuration instruction;
the expected data generating unit is used for running the preset automatic test script, reading the update field, calling the current user binding card interface to generate expected user data, generating expected borrowing data based on the user data and calling the current borrowing interface, and calling the current repayment interface to generate expected repayment data.
In some embodiments, the second data generating module 13 may specifically include:
An expected data updating unit configured to update historical expected data currently held in the expected data table based on the expected user data, the expected borrowing data, and the expected repayment data;
the second flag bit updating unit is used for judging whether a flag bit updating instruction is received or not, and if so, updating the flag bit of the configuration file into a check field based on the flag bit updating instruction;
and the real-time data generation unit is used for rerun the preset automatic test script based on the check field so as to generate real-time data.
In some embodiments, the data comparison module 14 may specifically include:
the data comparison unit is used for reading the expected data stored in the expected data table, and carrying out data comparison operation on the expected data and the real-time data so as to determine whether data difference exists between the expected data and the real-time data or not based on comparison results;
and the change interface determining unit is used for determining a change interface based on the comparison result if the comparison result represents that the data difference exists, and determining the interface name of the change interface.
In some embodiments, the step jump module 15 may specifically include:
and the first script updating unit is used for writing the interface name into the configuration file to finish updating the preset automatic test script, and re-jumping to the step of configuring the flag bit of the configuration file according to the received flag bit configuration instruction, running the preset automatic test script based on the configured flag bit field and generating expected data corresponding to the current calling interface.
In some embodiments, the interface automated test equipment may further include:
the instruction receiving judging unit is used for judging whether a script updating instruction is received or not if the comparison result represents that the data difference exists and a change interface does not exist;
and the second script updating unit is used for updating the preset automatic test script if the script updating instruction is received, re-jumping to the step of configuring the flag bit of the configuration file according to the received flag bit configuration instruction, running the preset automatic test script based on the configured flag bit field and generating expected data corresponding to the current calling interface.
In some embodiments, the interface automated test equipment may further include:
and the regression testing unit is used for carrying out regression testing on the current calling interface in the automatic testing script if the comparison result indicates that the data difference does not exist, so as to rerun the preset automatic testing script based on a preset frequency.
Further, the embodiment of the present application further discloses an electronic device, and fig. 4 is a block diagram of an electronic device 20 according to an exemplary embodiment, where the content of the diagram is not to be considered as any limitation on the scope of use of the present application.
Fig. 4 is a schematic structural diagram of an electronic device 20 according to an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input output interface 25, and a communication bus 26. Wherein the memory 22 is used for storing a computer program, and the computer program is loaded and executed by the processor 21 to implement relevant steps in the interface automation test method disclosed in any of the foregoing embodiments. In addition, the electronic device 20 in the present embodiment may be specifically an electronic computer.
In this embodiment, the power supply 23 is configured to provide an operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and an external device, and the communication protocol in which the communication interface is in compliance is any communication protocol applicable to the technical solution of the present application, which is not specifically limited herein; the input/output interface 25 is used for acquiring external input data or outputting external output data, and the specific interface type thereof may be selected according to the specific application requirement, which is not limited herein.
The memory 22 may be a carrier for storing resources, such as a read-only memory, a random access memory, a magnetic disk, or an optical disk, and the resources stored thereon may include an operating system 221, a computer program 222, and the like, and the storage may be temporary storage or permanent storage.
The operating system 221 is used for managing and controlling various hardware devices on the electronic device 20 and computer programs 222, which may be Windows Server, netware, unix, linux, etc. The computer program 222 may further comprise a computer program capable of performing other specific tasks in addition to the computer program capable of performing the interface automated test method performed by the electronic device 20 as disclosed in any of the previous embodiments.
Further, the application also discloses a computer readable storage medium for storing a computer program; wherein the computer program, when executed by the processor, implements the previously disclosed interface automation test method. For specific steps of the method, reference may be made to the corresponding contents disclosed in the foregoing embodiments, and no further description is given here.
In this specification, each embodiment is described in a progressive manner, and each embodiment is mainly described in a different point from other embodiments, so that the same or similar parts between the embodiments are referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant points refer to the description of the method section.
Those of skill would further appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both, and that the various illustrative elements and steps are described above generally in terms of functionality in order to clearly illustrate the interchangeability of hardware and software. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. The software modules may be disposed in Random Access Memory (RAM), memory, read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
Finally, it is further noted that relational terms such as first and second, and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
The foregoing has outlined rather broadly the more detailed description of the application in order that the detailed description of the application that follows may be better understood, and in order that the present principles and embodiments may be better understood; meanwhile, as those skilled in the art will have variations in the specific embodiments and application scope in accordance with the ideas of the present application, the present description should not be construed as limiting the present application in view of the above.

Claims (10)

1. An automated interface testing method, comprising:
creating a configuration file of a preset automatic test script, and determining a current calling interface in the preset automatic test script;
configuring a flag bit of the configuration file according to the received flag bit configuration instruction, and running the preset automatic test script based on the configured flag bit field to generate expected data corresponding to the current calling interface;
updating the expected data to an expected data table, updating the zone bit of the configuration file according to a zone bit updating instruction, and rerun the preset automatic test script based on the updated zone bit field to generate real-time data;
And comparing the real-time data with the expected data in the expected data table, determining whether a change interface exists or not based on a comparison result, if so, updating the preset automatic test script based on the change interface, jumping to the configuration of the zone bit of the configuration file according to the received zone bit configuration instruction, running the preset automatic test script based on the configured zone bit field, and generating expected data corresponding to the current calling interface.
2. The method according to claim 1, wherein creating a configuration file of a preset automation test script and determining a current call interface in the preset automation test script comprises:
creating a configuration file of a preset automatic test script, and determining an interface name of a current calling interface in the preset automatic test script;
and adding the interface name to the configuration file to determine the interface name as a parameter for running the preset automation test script.
3. The method according to claim 1, wherein the configuring the flag bit of the configuration file according to the received flag bit configuration instruction, and running the preset automation test script based on the configured flag bit field, generating the expected data corresponding to the current call interface, includes:
Judging whether a flag bit configuration instruction is received, if so, configuring the flag bit of the preset configuration file as an update field based on the flag bit configuration instruction;
and running the preset automatic test script, reading the update field to call a current user binding card interface to generate expected user data, calling a current borrowing interface to generate expected borrowing data based on the user data, and calling a current repayment interface to generate expected repayment data.
4. The method of claim 3, wherein updating the expected data to an expected data table, updating the flag bit of the configuration file according to a flag bit update instruction, and rerun the preset automatic test script based on the updated flag bit field, and generating real-time data comprises:
updating historical prospective data currently stored in the prospective data sheet based on the prospective user data, the prospective borrowing data, and the prospective repayment data;
judging whether a flag bit updating instruction is received, if so, updating the flag bit of the configuration file into a check field based on the flag bit updating instruction, and rerun the preset automatic test script based on the check field to generate real-time data.
5. The method according to any one of claims 1 to 4, wherein the steps of comparing the real-time data with the expected data in the expected data table, determining whether a change interface exists based on a comparison result, if so, updating the preset automation test script based on the change interface, jumping to the flag bit of the configuration file configured according to the received flag bit configuration instruction, and running the preset automation test script based on the configured flag bit field, and generating the expected data corresponding to the current call interface include:
reading the expected data stored in the expected data table, and performing data comparison operation on the expected data and the real-time data to determine whether a data difference exists between the expected data and the real-time data based on a comparison result;
if the comparison result represents that the data difference exists, determining a change interface based on the comparison result, and determining an interface name of the change interface;
and writing the interface name into the configuration file to finish updating the preset automatic test script, and re-jumping to the step of configuring the flag bit of the configuration file according to the received flag bit configuration instruction, and running the preset automatic test script based on the configured flag bit field to generate expected data corresponding to the current calling interface.
6. The method according to claim 1, wherein after the step of reading the expected data stored in the expected data table and performing a data comparison operation on the expected data and the real-time data to determine whether there is a data difference between the expected data and the real-time data based on a comparison result, further comprising:
if the comparison result represents that the data difference exists and a change interface does not exist, judging whether a script updating instruction is received or not;
and if the script updating instruction is received to update the preset automatic test script, re-jumping to the step of configuring the flag bit of the configuration file according to the received flag bit configuration instruction, and running the preset automatic test script based on the configured flag bit field to generate expected data corresponding to the current calling interface.
7. The method according to claim 5, wherein after the step of reading the expected data stored in the expected data table and performing a data comparison operation on the expected data and the real-time data to determine whether there is a data difference between the expected data and the real-time data based on a comparison result, further comprising:
And if the comparison result indicates that the data difference does not exist, performing regression testing on the current calling interface in the automatic test script so as to rerun the preset automatic test script based on a preset frequency.
8. An automated interface testing apparatus, comprising:
the interface determining module is used for creating a configuration file of a preset automatic test script and determining a current calling interface in the preset automatic test script;
the first data generation module is used for configuring the zone bit of the configuration file according to the received zone bit configuration instruction, running the preset automatic test script based on the configured zone bit field and generating expected data corresponding to the current calling interface;
the second data generation module is used for updating the expected data to an expected data table, updating the zone bit of the configuration file according to a zone bit updating instruction, and rerun the preset automatic test script based on the updated zone bit field to generate real-time data;
the data comparison module is used for comparing the real-time data with the expected data in the expected data table, determining whether a change interface exists or not based on a comparison result, and updating the preset automatic test script based on the change interface if the change interface exists;
The step jump module is used for jumping to the step of configuring the zone bit of the configuration file according to the received zone bit configuration instruction, running the preset automatic test script based on the configured zone bit field and generating expected data corresponding to the current calling interface.
9. An electronic device, comprising:
a memory for storing a computer program;
a processor for executing the computer program to implement the interface automation test method of any one of claims 1 to 7.
10. A computer readable storage medium for storing a computer program which when executed by a processor implements the interface automation test method of any of claims 1 to 7.
CN202311027455.8A 2023-08-16 2023-08-16 Automatic interface testing method, device, equipment and storage medium Active CN116756046B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311027455.8A CN116756046B (en) 2023-08-16 2023-08-16 Automatic interface testing method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311027455.8A CN116756046B (en) 2023-08-16 2023-08-16 Automatic interface testing method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN116756046A true CN116756046A (en) 2023-09-15
CN116756046B CN116756046B (en) 2023-11-03

Family

ID=87953584

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311027455.8A Active CN116756046B (en) 2023-08-16 2023-08-16 Automatic interface testing method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116756046B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117149820A (en) * 2023-09-25 2023-12-01 湖南长银五八消费金融股份有限公司 Borrowing operation detection method, device, equipment and storage medium

Citations (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120066548A1 (en) * 2010-09-09 2012-03-15 International Business Machines Corporation Automated Operating System Test Framework
CN109032612A (en) * 2018-07-02 2018-12-18 平安科技(深圳)有限公司 Interface calling method and device of hybrid application and computer readable storage medium
CN109558290A (en) * 2018-11-12 2019-04-02 平安科技(深圳)有限公司 Server, automatic interface testing method and storage medium
CN112416762A (en) * 2020-11-16 2021-02-26 中信银行股份有限公司 API test method and device, equipment and computer readable storage medium
CN112486811A (en) * 2020-11-26 2021-03-12 杭州安恒信息技术股份有限公司 Interface test method, device, equipment and medium
CN112732563A (en) * 2020-12-31 2021-04-30 深圳赛安特技术服务有限公司 Interface script test log extraction method and device, terminal and storage medium
CN114610635A (en) * 2022-03-22 2022-06-10 平安健康保险股份有限公司 Interface test case generation method and device, computer equipment and storage medium
CN115080398A (en) * 2022-06-21 2022-09-20 徐工汉云技术股份有限公司 Automatic interface test system and method
CN115237759A (en) * 2022-07-08 2022-10-25 上海轩田工业设备有限公司 Method and system for automatic API performance test
US11516100B1 (en) * 2021-06-09 2022-11-29 T-Mobile Usa, Inc. Cloud-to-cloud integration of vendor device testing automation and carrier performance analytics
CN115878443A (en) * 2021-09-26 2023-03-31 青岛海尔科技有限公司 Interface test script generation method and device, storage medium and electronic device
CN116257438A (en) * 2023-01-05 2023-06-13 中国电信股份有限公司 Updating method of interface test case and related equipment
CN116340180A (en) * 2023-03-27 2023-06-27 平安银行股份有限公司 Interface parameter updating method and device, electronic equipment and storage medium
WO2023123943A1 (en) * 2021-12-27 2023-07-06 深圳前海微众银行股份有限公司 Interface automation testing method and apparatus, and medium, device and program

Patent Citations (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20120066548A1 (en) * 2010-09-09 2012-03-15 International Business Machines Corporation Automated Operating System Test Framework
CN109032612A (en) * 2018-07-02 2018-12-18 平安科技(深圳)有限公司 Interface calling method and device of hybrid application and computer readable storage medium
CN109558290A (en) * 2018-11-12 2019-04-02 平安科技(深圳)有限公司 Server, automatic interface testing method and storage medium
CN112416762A (en) * 2020-11-16 2021-02-26 中信银行股份有限公司 API test method and device, equipment and computer readable storage medium
CN112486811A (en) * 2020-11-26 2021-03-12 杭州安恒信息技术股份有限公司 Interface test method, device, equipment and medium
CN112732563A (en) * 2020-12-31 2021-04-30 深圳赛安特技术服务有限公司 Interface script test log extraction method and device, terminal and storage medium
US11516100B1 (en) * 2021-06-09 2022-11-29 T-Mobile Usa, Inc. Cloud-to-cloud integration of vendor device testing automation and carrier performance analytics
CN115878443A (en) * 2021-09-26 2023-03-31 青岛海尔科技有限公司 Interface test script generation method and device, storage medium and electronic device
WO2023123943A1 (en) * 2021-12-27 2023-07-06 深圳前海微众银行股份有限公司 Interface automation testing method and apparatus, and medium, device and program
CN114610635A (en) * 2022-03-22 2022-06-10 平安健康保险股份有限公司 Interface test case generation method and device, computer equipment and storage medium
CN115080398A (en) * 2022-06-21 2022-09-20 徐工汉云技术股份有限公司 Automatic interface test system and method
CN115237759A (en) * 2022-07-08 2022-10-25 上海轩田工业设备有限公司 Method and system for automatic API performance test
CN116257438A (en) * 2023-01-05 2023-06-13 中国电信股份有限公司 Updating method of interface test case and related equipment
CN116340180A (en) * 2023-03-27 2023-06-27 平安银行股份有限公司 Interface parameter updating method and device, electronic equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117149820A (en) * 2023-09-25 2023-12-01 湖南长银五八消费金融股份有限公司 Borrowing operation detection method, device, equipment and storage medium
CN117149820B (en) * 2023-09-25 2024-05-14 湖南长银五八消费金融股份有限公司 Borrowing operation detection method, device, equipment and storage medium

Also Published As

Publication number Publication date
CN116756046B (en) 2023-11-03

Similar Documents

Publication Publication Date Title
US9524230B2 (en) Testing coordinator
CN107861871B (en) Gray scale publishing method, device, server and storage medium
US9411575B2 (en) Systems and methods for quality assurance automation
CN108509344B (en) Daily cutting batch test method, equipment and readable storage medium
CN116756046B (en) Automatic interface testing method, device, equipment and storage medium
US7797680B2 (en) Method and framework for test case management
CN112380255A (en) Service processing method, device, equipment and storage medium
CN113706022A (en) Business process execution method and device, storage medium and electronic equipment
EP4195108A1 (en) Method and apparatus for generating and applying deep learning model based on deep learning framework
CN115964272A (en) Transaction data automatic testing method, device, equipment and readable storage medium
CN112817843A (en) Project management method and system
CN114170006A (en) Information data acquisition method, device, equipment and medium based on state machine
CN114328257A (en) Automatic test case execution method and system and electronic equipment
CN114185772A (en) Software testing method and device, storage medium and computer equipment
CN114663070A (en) Project flow management method and device, computer equipment and storage medium
CN113515452A (en) Automatic test method and system for application, electronic equipment and storage medium
CN109634865B (en) Code transfer testing method and device and transfer testing terminal
CN112598383A (en) Approval method, device, equipment and medium
CN112579455B (en) Automatic interface testing method and device, electronic equipment and storage medium
CN116932414B (en) Method and equipment for generating interface test case and computer readable storage medium
US20080066005A1 (en) Systems and Methods of Interfacing with Enterprise Resource Planning Systems
CN116225441B (en) Code hosting method and system for online coding system
CN117971702A (en) Response test method and device for service platform, medium and electronic equipment
CN117971701A (en) Method, device, equipment and storage medium for testing funds transaction business
CN116126689A (en) Web automation test method based on data drive

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
GR01 Patent grant
GR01 Patent grant