An automatic correction method for interface test cases
By using git code submission records to obtain interface change mapping relationships, the interface test cases are automatically corrected, which solves the problem of poor timeliness and accuracy of test cases caused by frequent interface changes, and realizes automatic correction and automatic change identification of interface test cases.
Patent Information
- Application Number
- CN202111440771.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-30
- Publication Date
- 2025-05-23
- Estimated Expiration
- 2041-11-30
AI Technical Summary
During the software development process, frequent interface changes lead to poor timeliness and accuracy in test cases corrections. The existing technology requires testers to manually change test cases, and the notification of interface changes is not timely and inaccurate.
By establishing a connection between development projects and test projects, using git code submission records to obtain interface change mapping relationships, automatically correct interface test cases, and realize automatic identification of interface changes and automatic correction of test cases.
It realizes automatic correction of interface test cases, improves the timeliness and accuracy of test case corrections after interface changes, and avoids the cumbersome and possible errors of manual changes by testers.
Smart Images

Figure SMS_1
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of software development, and in particular to an automatic correction method for an interface test case. Background Art
[0002] During software development, software interfaces often change, such as adding new interfaces, deleting interfaces, changing interface addresses, changing interface request methods, changing interface request parameters, etc. For changes to interfaces, developers notify testers, and then modify the test case of the test project after testing. However, currently, after the interface is changed, testers are required to manually change the corresponding test cases, which often results in untimely and inaccurate notification of interface changes to testers, resulting in poor timeliness and accuracy in the modification of interface test cases.
[0003] Therefore, it is imperative to develop a method that can establish a connection between development projects and test projects, realize automatic identification of interface changes, and automatically correct interface test cases according to changes in development projects. Summary of the invention
[0004] The present invention provides an automatic correction method for interface test cases, which can realize automatic identification of interface changes by establishing a connection between a development project and a test project, and can automatically correct the interface test cases according to the changes of the development project.
[0005] The purpose of the present invention is achieved through the following technical solutions:
[0006] An automatic correction method for an interface test case comprises the following steps:
[0007] Step S1: The system uses commands to capture the change information in the two git versions and stores the captured information in file1;
[0008] Step S2: Use keywords to determine whether there is an interface change in the change information in file1. If yes, filter out the change points and go to step S3; if no, the correction ends.
[0009] Step S3: Establish a mapping relationship between the request URL, request method, and request parameter data before and after the change point obtained in step S2, and encapsulate the established mapping relationship into a message body and send it to the automated test project;
[0010] Step S4: The automated test project performs content parsing on the received message body, automatically modifies the test case of the interface according to the mapping relationship, and finally obtains a new interface test case.
[0011] The fetching command in step S1 is git diff <commita> <commitb>>>file1.
[0012] When screening in step S2, the change points in the change information are screened through the SpringMVC keywords @RequestMapping, @RequestParams, and @RequestBody at the location of the code where the web project interface is located.
[0013] The encapsulation into the message body in step S3 is as follows:
[0014] {"bizType":"changeInterface","changeList":[{"srcUrl": " / api / test1","srcMethod":"get","srcParameters":["pageSize","curPage","epId"],"destUrl":" / api / wms / test1","destMethod":"post","destParameters":["pageSize","curPage","whId", "epId"],"changeFlag":"alter"},{"srcUrl":"","srcMethod":"", "srcParameters":[],"destUrl":" / api / wms / test2","destMethod":"post", "destParameters":["whId","epId","customerId"],"changeFlag":"add"}]};
[0015] The modification of the test case of the interface in step S4 includes replacing the change point and establishing a new identifier, wherein the replacement method of the request URL, request method, and request parameter change point identifier is as follows:
[0016] Request replacement of URL change point identifier: obtain the change identifier of the URL change point, that is, the modification identifier, use the URL data before the change as a condition to retrieve the content in the test case file, find the test case of the corresponding interface, and replace the identifier in the case with the identifier after the change through regular matching;
[0017] Replacement of request method change point identifier: Get the change identifier of the request method change point, that is, the modification identifier, use the request method identifier before the change as a condition to search the content in the test case file, find the test case of the corresponding interface, and replace the identifier in the case with the identifier after the change through regular matching;
[0018] Replacement of request parameter change point identifier: Get the change identifier of the request parameter change point, that is, the modification identifier, use the request method identifier before the change as a condition to retrieve the content in the test case file, find the test case of the corresponding interface, and replace the identifier in the case with the identifier after the change through regular matching.
[0019] The establishment of the new identifier is to establish an interface test case. According to the template of the interface test case, an interface test case is assembled and written into a new file case_fileM. The interface test case includes a request url, a request method, and request parameters.
[0020] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0021] The present invention obtains the interface change mapping relationship by grabbing the git code submission record, and then automatically corrects the test case of the corresponding interface according to the mapping relationship, thereby realizing automatic correction of the interface test case, and effectively solves the problem that the interface change notification to the tester is not timely and accurate, and the tester needs to manually change the corresponding test case after the interface is changed, resulting in poor timeliness and accuracy of the correction of the interface test case. DETAILED DESCRIPTION
[0022] The present invention will be further described in detail below in conjunction with examples, but the embodiments of the present invention are not limited thereto.
[0023] Example
[0024] An automatic correction method for an interface test case of the present invention comprises the following steps:
[0025] Step S1: The system captures the change information in the two git versions through commands and stores the captured information in file file1.
[0026] Among them, the fetch command uses git diff in this embodiment. <commita> <commitb>>>file1 to achieve this.
[0027] Step S2: Determine whether there is an interface change in the change information in file1 by using keywords. If yes, filter out the change points and go to step S3; if no, the correction ends. The change points in the change information are filtered by using the SpringMVC keywords, SpringMVC @RequestMapping, @RequestParams, and @RequestBody, in the code location of the web project interface.
[0028] Step S3: Establish a mapping relationship between the request URL, request method, and request parameter data before and after the change point obtained in step S2, and encapsulate the established mapping relationship into a message body and send it to the automated test project. The encapsulation message body is as follows:
[0029] {"bizType":"changeInterface","changeList":[{"srcUrl": " / api / test1","srcMethod":"get","srcParameters":["pageSize","curPage","epId"],"destUrl":" / api / wms / test1","destMethod":"post","destParameters":["pageSize","curPage","whId", "epId"],"changeFlag":"alter"},{"srcUrl":"","srcMethod":"", "srcParameters":[],"destUrl":" / api / wms / test2","destMethod":"post", "destParameters":["whId","epId","customerId"],"changeFlag":"add"}]}.
[0030] Step S4: The automated test project performs content parsing on the received message body, automatically modifies the interface test case according to the mapping relationship, and finally obtains a new interface test case. The modification of the interface test case in this step includes the replacement of the change point and the establishment of a new identifier, wherein the replacement method of the request URL, request method, and request parameter change point identifier is as follows:
[0031] Replace the change point identifier of the request URL: Get the change identifier of the URL change point, that is, the modification identifier, use the URL data before the change as a condition to retrieve the content in the test case file, find the test case of the corresponding interface, and replace the identifier in the case with the identifier after the change through regular matching. For example, the identifier of the request URL before the change is: / api / test1, and the identifier of the URL after the change is: / api / wms / test1. When modifying, the identifier of the request URL / api / test1 is automatically replaced with / api / wms / test1.
[0032] Replacement of request method change point identifier: Get the change identifier of the request method change point, that is, the modification identifier, use the request method identifier before the change as a condition to search the content in the test case file, find the test case of the corresponding interface, and replace the identifier in the case with the identifier after the change through regular matching. For example, the request method identifier before the change is: get, and the request method identifier after the change is: post. When modifying, the request method identifier get is automatically replaced with post.
[0033] Replacement of request parameter change point identifier: Get the change identifier of the request parameter change point, that is, the modification identifier, use the request method identifier before the change as a condition to search the content in the test case file, find the test case of the corresponding interface, and replace the identifier in the case with the identifier after the change through regular matching. For example, the identifiers of the request parameters before the change are: pageSize, curPage, epId, and the identifiers of the request parameters after the change are: pageSize, curPage, whId, epId. When modifying, the identifiers of the request parameters pageSize, curPage, epId are automatically replaced with pageSize, curPage, whId, epId.
[0034] The relationship between the request URL, request method, and request parameter interface before and after the change is as follows:
[0035]
[0036] Furthermore, the establishment of the new identifier is to establish an interface test case, and according to the template of the interface test case, an interface test case is assembled and written into a new file case_fileM, and the interface test case includes a request url, a request method, and a request parameter. As above: if the change identifier is "add", that is, a new identifier is added, then according to the template of the interface test case, an interface test case is assembled and written into a new file case_fileM, wherein, as shown in the change number 2 in the above table, the request url: / api / wms / test2, the request method: post, and the request parameters: whId, epId, customerId.
[0037] As described above, the present invention can be well implemented.< / commitb> < / commita> < / commitb> < / commita>
Claims
1. An automatic correction method for interface test cases, It is characterized in that The following steps are involved: Step S1: The system uses commands to capture the change information in the two git versions and stores the captured information in file1; Step S2: Determine whether there is an interface change in the change information in file1 by using keywords. If yes, filter out the change points and proceed to step S3; No, the amendment is over; Step S3: Establish a mapping relationship between the request URL, request method, and request parameter data before and after the change point obtained in step S2, and encapsulate the established mapping relationship into a message body and send it to the automated test project; Step S4: The automated test project performs content parsing on the received message body, automatically modifies the test case of the interface according to the mapping relationship, and finally obtains a new interface test case.
2. The automatic correction method for interface test cases according to claim 1, It is characterized in that The fetch command in step S1 is "git diff <commita> <commitb> >>file1".< / commitb> < / commita> 3. The automatic correction method for interface test cases according to claim 1, It is characterized in that When screening in step S2, the change points in the change information are screened through the SpringMVC keywords @RequestMapping, @RequestParams, and @RequestBody at the location of the code where the web project interface is located.
4. The automatic correction method for interface test cases according to claim 1, It is characterized in that The modification of the test case of the interface in step S4 includes replacing the change point and establishing a new identifier, wherein the replacement method of the request URL, request method, and request parameter change point identifier is as follows: Request replacement of URL change point identifier: obtain the change identifier of the URL change point, that is, the modification identifier, use the URL data before the change as a condition to retrieve the content in the test case file, find the test case of the corresponding interface, and replace the identifier in the case with the identifier after the change through regular matching; Replacement of request method change point identifier: Get the change identifier of the request method change point, that is, the modification identifier, use the request method identifier before the change as a condition to search the content in the test case file, find the test case of the corresponding interface, and replace the identifier in the case with the identifier after the change through regular matching; Replacement of request parameter change point identifier: Get the change identifier of the request parameter change point, that is, the modification identifier, use the request parameter identifier before the change as a condition to search the content in the test case file, find the test case of the corresponding interface, and replace the identifier in the case with the identifier after the change through regular matching; The establishment of the new identifier is to establish an interface test case. According to the template of the interface test case, an interface test case is assembled and written into a new file case_fileM. The interface test case includes a request url, a request method, and request parameters.
Citation Information
Patent Citations
Method for processing information change of user interface and system
CN101727385A
Interface test script determination method, device and equipment, and storage medium
CN111881024A