CN115509904A - Assertion generation method and device of interface test case - Google Patents

Assertion generation method and device of interface test case Download PDF

Info

Publication number
CN115509904A
CN115509904A CN202211145971.6A CN202211145971A CN115509904A CN 115509904 A CN115509904 A CN 115509904A CN 202211145971 A CN202211145971 A CN 202211145971A CN 115509904 A CN115509904 A CN 115509904A
Authority
CN
China
Prior art keywords
assertion
test case
test
template
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
CN202211145971.6A
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 Bank Co Ltd
Original Assignee
Ping An Bank 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 Bank Co Ltd filed Critical Ping An Bank Co Ltd
Priority to CN202211145971.6A priority Critical patent/CN115509904A/en
Publication of CN115509904A publication Critical patent/CN115509904A/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/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases

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 application provides an assertion generating method and device of an interface test case, wherein the method comprises the following steps: acquiring a test case for interface test; determining an application scene of a test case; matching a target assertion template from a preset assertion template library according to the test case and the application scene; filling the assertion part of the test case according to the target assertion template to obtain a target test case; performing interface test by using the target test case to obtain a test result; and performing assertion judgment according to the test result. Therefore, the method can automatically generate the assertion without manual writing, thereby avoiding the problems of non-specification, large workload, incompleteness and the like, and further being beneficial to improving the universality of the test case.

Description

Assertion generation method and device of interface test case
Technical Field
The present application relates to the field of test technologies, and in particular, to a method and an apparatus for generating an assertion of an interface test case.
Background
At present, with the continuous increase of the complexity of the current system, the test cost of the traditional test method is increased sharply, the automated test is carried out by an interface automated test case, and the core elements of the interface automated test case comprise the design of the test steps and the judgment of the expected result. In an automatic test case, the interface result verification is an important link, the test interface assertion is used for checking whether the interface return conforms to an expected flow, checking the correctness of the behavior of a tested system, and judging whether the interface case passes the execution, thereby judging the correctness of the behavior of the system. In the prior art, assertions are usually written manually, so that the problems of non-specification, large workload, incompleteness and the like exist, a plurality of invalid use cases are increased, the universality of the use cases is reduced, and a plurality of redundant use cases are increased. Therefore, in the existing method, the manual writing assertion is not standard, the workload is large and incomplete, and the universality of the test case is reduced.
Disclosure of Invention
An object of the embodiments of the present application is to provide an assertion generating method and apparatus for an interface test case, which can automatically generate an assertion without manual writing, thereby avoiding the problems of non-specification, large workload, incompleteness, and the like, and further facilitating the improvement of the universality of the test case.
A first aspect of the embodiments of the present application provides a method for generating an assertion of an interface test case, including:
acquiring a test case for interface test;
determining an application scene of the test case;
matching a target assertion template from a preset assertion template library according to the test case and the application scene;
filling the assertion part of the test case according to the target assertion template to obtain a target test case;
performing interface test by using the target test case to obtain a test result;
and performing assertion judgment according to the test result.
In the implementation process, the method can preferentially acquire the test cases for interface test; determining an application scene of the test case; then, matching a target assertion template from a preset assertion template library according to the test case and the application scene; filling the assertion part of the test case according to the target assertion template to obtain a target test case; then, using the target test case to carry out interface test to obtain a test result; and finally, performing assertion judgment according to the test result. Therefore, by implementing the implementation mode, the assertion can be automatically generated without manual writing, so that the problems of non-specification, large workload, incompleteness and the like are avoided, and the universality of the test case is favorably improved.
Further, after the interface test is performed by using the target test case to obtain a test result, the method further includes:
judging whether an assertion supplement instruction aiming at the interrupt statement result of the test result is received;
and if so, performing predicate supplement according to the predicate supplement instruction and the predicate result.
Further, performing predicate complementation according to the predicate complementation instruction and the predicate result includes:
when the predicated supplementary instruction is a template supplementary instruction, supplementing the target predicated template according to the predicated supplementary instruction;
and when the predicated supplementary instruction is a template adding instruction, obtaining a new template according to the predicated supplementary instruction, and adding the new template into the predicated template library.
Further, the supplementing the target predicate template according to the predicate supplementing instruction includes:
determining the selected corresponding field according to the assertion supplement instruction;
and filling the corresponding field into the target assertion template.
Further, the assertion result at least comprises an interface test basic request field, a returned state check result, a field type, a field logic mutual exclusion result, a test request interface, and a corresponding path automatically generated according to a return body of the request interface.
A second aspect of the embodiments of the present application provides an assertion generating device for an interface test case, where the assertion generating device for an interface test case includes:
the device comprises an acquisition unit, a test unit and a test unit, wherein the acquisition unit is used for acquiring a test case for carrying out interface test;
the determining unit is used for determining the application scene of the test case;
the matching unit is used for matching a target assertion template from a preset assertion template library according to the test case and the application scene;
the filling unit is used for filling the assertion part of the test case according to the target assertion template to obtain a target test case;
the test unit is used for carrying out interface test by using the target test case to obtain a test result;
and the assertion unit is used for performing assertion judgment according to the test result.
In the implementation process, the device can acquire a test case for interface test through the acquisition unit; determining an application scene of the test case through a determining unit; matching a target assertion template from a preset assertion template library according to the test case and the application scene through a matching unit; filling the assertion part of the test case according to the target assertion template through a filling unit to obtain a target test case; performing interface test by using the target test case through a test unit to obtain a test result; and the assertion unit is used for performing assertion judgment according to the test result. Therefore, by implementing the implementation mode, the assertion can be automatically generated, and manual writing is not needed, so that the problems of lack of specification, large workload, incompleteness and the like are avoided, and the universality of the test case is favorably improved.
Further, the assertion generating device of the interface test case further includes:
the judging unit is used for judging whether an assertion supplement instruction aiming at the interrupt result of the test result is received or not after the interface test is carried out by using the target test case to obtain the test result;
and the supplement unit is used for performing assertion supplement according to the assertion supplement instruction and the assertion result when judging that the assertion supplement instruction is received.
Further, the supplement unit is specifically configured to, when it is determined that the predicated supplement instruction is received and the predicated supplement instruction is a template supplement instruction, supplement the target predicated template according to the predicated supplement instruction; and when the predicated supplementary instruction is judged to be received and is a template adding instruction, obtaining a new template according to the predicated supplementary instruction, and adding the new template into the predicated template library.
Further, the supplementary unit includes:
the determining subunit is used for determining the selected corresponding field according to the assertion supplement instruction when the assertion supplement instruction is judged to be received and is a template supplement instruction;
and the supplementary subunit is used for filling the corresponding field into the target assertion template.
Further, the assertion result at least comprises an interface test basic request field, a returned state check result, a field type, a field logic mutual exclusion result, a test request interface, and a corresponding path automatically generated according to a return body of the request interface.
A third aspect of the embodiments of the present application provides an electronic device, including a memory and a processor, where the memory is used to store a computer program, and the processor runs the computer program to enable the electronic device to execute the method for generating an assertion of an interface test case according to any one of the first aspect of the embodiments of the present application.
A fourth aspect of the present embodiment provides a computer-readable storage medium, which stores computer program instructions, where the computer program instructions, when read and executed by a processor, perform the method for generating an assertion for an interface test case according to any one of the first aspect of the present embodiment.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are required to be used in the embodiments of the present application will be briefly described below, it should be understood that the following drawings only illustrate some embodiments of the present application and therefore should not be considered as limiting the scope, and that those skilled in the art can also obtain other related drawings based on the drawings without inventive efforts.
Fig. 1 is a schematic flowchart of an assertion generating method of an interface test case according to an embodiment of the present application;
fig. 2 is a schematic flowchart of another assertion generating method of an interface test case according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of an assertion generating device for an interface test case according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of another assertion generating device for interface test cases according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined or explained in subsequent figures. Meanwhile, in the description of the present application, the terms "first", "second", and the like are used only for distinguishing the description, and are not construed as indicating or implying relative importance.
Example 1
Referring to fig. 1, fig. 1 is a schematic flowchart illustrating a method for generating an assertion of an interface test case according to an embodiment of the present application. The assertion generating method of the interface test case comprises the following steps:
s101, obtaining a test case for interface test.
S102, determining an application scene of the test case.
S103, matching a target assertion template from a preset assertion template library according to the test case and the application scene.
And S104, filling the assertion part of the test case according to the target assertion template to obtain the target test case.
And S105, carrying out interface test by using the target test case to obtain a test result.
And S106, performing assertion judgment according to the test result.
At present, in order to solve the problem of system complexity, the conventional test method is not used for testing, but an automatic test method is used, so that the test cost is reduced. The automated test needs to be executed through an interface automated test case, and the core elements of the interface automated test case include the design of the test steps and the judgment of the expected result. Specifically, in an automatic test case, the interface result verification is an important link, and the test interface assertion is used for checking whether the interface returns to conform to an expected flow, checking the correctness of the behavior of the tested system, and judging whether the interface case passes the execution, thereby judging the correctness of the behavior of the system. How to effectively and correctly judge whether the execution is in accordance with the expectation or not and whether the program return information is correct or not, and directly determine whether the program has the bug or not according to the result, thereby determining the quality of the automatic test. Therefore, how to generate complete and qualified assertions is important. However, the following problems still generally exist in the current method:
(1) the written test assertion caused by manually written assertion has the problems of non-specification, large workload, incompleteness and the like;
(2) problems caused by asserting too much or too little;
(3) the assertion effect is poor, more legacy scenes exist, only the interface return code is asserted, and only whether the interface can be smooth or not can be judged, but the service logic of the interface is not verified.
In the embodiment, the method can be applied to the field of financial science and technology, and is particularly used for automatically generating a large number of assertions to enrich cases, so that the time for testing and compiling cases by financial science and technology workers is reduced, and the financial science and technology workers can conveniently put more time into other aspects.
In this embodiment, the execution subject of the method may be a computing device such as a computer and a server, and is not limited in this embodiment.
In this embodiment, an execution subject of the method may also be an intelligent device such as a smart phone and a tablet computer, which is not limited in this embodiment.
Therefore, by implementing the assertion generating method of the interface test case described in this embodiment, the generation cases of different scenes can be automatically identified according to the interface, and the assertion generating templates of different scenes can be generated at the same time; the scene use case and the scene template have an incidence relation. Meanwhile, a use case can be generated based on the interface, and an assertion part of the corresponding use case can be generated according to the assertion template. In addition, for the service scene template or the condition that the upstream and downstream service scenes need to change, a path corresponding to jpath or xpath and the like can be quickly generated according to the returning body, and a result corresponding to the returning value obtained from the last call in the path can be provided, so that the condition of testing a large amount of manual compiling assertions can be avoided. Finally, foolproof assertion filling can be realized without the need of testing to know the syntax of xpath and the like, so that the time for testing and writing cases is greatly reduced, and more time can be put into other aspects for testing.
Example 2
Referring to fig. 2, fig. 2 is a schematic flowchart illustrating a method for generating an assertion of an interface test case according to an embodiment of the present application. The assertion generating method of the interface test case comprises the following steps:
s201, obtaining a test case for interface test.
S202, determining the application scene of the test case.
And S203, matching a target assertion template from a preset assertion template library according to the test case and the application scene.
And S204, filling the assertion part of the test case according to the target assertion template to obtain the target test case.
And S205, performing interface test by using the target test case to obtain a test result.
S206, judging whether an assertion supplement instruction aiming at the interrupt result of the test result is received, if so, executing the step S207 or S209; if not, the flow is ended.
In this embodiment, the assertion result at least includes an interface test basic request field, a returned check result, a field type, a field logical mutual exclusion result, a test request interface, and a corresponding path automatically generated according to a return body of the request interface.
And S207, when the predicated supplementary instruction is the template supplementary instruction, determining the selected corresponding field according to the predicated supplementary instruction.
And S208, filling the corresponding field into the target assertion template, and ending the process.
S209, when the assertion supplement instruction is the template adding instruction, obtaining the adding template according to the assertion supplement instruction, and adding the adding template into the assertion template library.
In this embodiment, currently, writing assertions in an interface test automation case requires to assert the fields by returning one by one, and currently, the jmeter writes json a json return body through a jpath and then performs matching. For xml, it is necessary to test the familiar jpath syntax or ui xpath syntax through xpath, and the assertion of each field needs to write xpath one by one, and if multiple fields need to be verified, the corresponding xpath needs to be written multiple times. Therefore, if too many assertions are made for the interface, the number of fields of the interface return value is often large, and the manual writing of the expected results one by one is often very labor-consuming. On the other hand, the interface assertion is too much for the use case itself. The universality is reduced, and the use cases are more rigid. If one use case is added to each interface scene situation, many invalid use cases are added, the universality of the use cases is reduced, many redundant use cases are added, and the test time and the test cost are wasted.
However, this approach can generate assertions of different scenarios based on the interface document; wherein, the assertion also has a plurality of public assertion templates. For example, the assertion template 1 only asserts the state of the return body, the template 2 asserts the character, and template assertions can be combined to perform an assertion module in the actual application process. The state is asserted first, by field type assertion.
For example, the method may comprise the steps of:
(1) initializing an assertion template of the interface according to the interface;
(2) the automated test cases corresponding to the interface have different scenes. Selecting different templates according to different scenes;
(3) selecting a template and then automatically filling the template to an assertion part of a use case;
(4) an interface request;
(5) returning the request;
(6) and (5) judging the assertion.
In the execution process of step (6), it may be found that assertions of use cases are not rich enough and need to be supplemented. Therefore, this method also proposes a method of complementing the assertion at this time. Specifically, the assertion can also selectively enter the assertion template.
In this embodiment, the above steps can avoid the assertions being written one by one.
In an actual scenario, except for the basic request field of the interface, the check of the return state, the field type and the field logic are mutually exclusive. For different service scenarios, different checks are also required for the returned data. The example flow is as follows:
(1) a request interface;
(2) automatically generating a corresponding path according to a return body of the request interface;
(3) the corresponding field is selected and the value is filled in with the assertion of the use case by one key.
In the embodiment, the method can be applied to the field of financial science and technology, and is particularly used for automatically generating a large number of assertions to enrich cases, so that the time for testing and compiling cases by financial science and technology workers is reduced, and the financial science and technology workers can put more time into other aspects.
In this embodiment, the execution subject of the method may be a computing device such as a computer and a server, and is not limited in this embodiment.
In this embodiment, an execution subject of the method may also be an intelligent device such as a smart phone and a tablet computer, which is not limited in this embodiment.
Therefore, by implementing the assertion generating method of the interface test case described in this embodiment, the generation cases of different scenes can be automatically identified according to the interface, and the assertion generating templates of different scenes can be generated at the same time; the scene use case and the scene template have an incidence relation. Meanwhile, a use case can be generated based on the interface, and an assertion part of the corresponding use case can be generated according to the assertion template. In addition, a path corresponding to a jpath or xpath and the like can be quickly generated according to a return body aiming at a service scene template or the condition that the upstream and downstream service scenes need to change, and a result corresponding to a return value obtained in the last call in a default value in the path can be provided, so that the condition of testing a large amount of manual writing assertions is avoided. Finally, foolproof assertion filling can be realized without the need of testing to know the syntax of xpath and the like, so that the time for testing and writing cases is greatly reduced, and more time can be put into other aspects for testing.
Example 3
Referring to fig. 3, fig. 3 is a schematic structural diagram of an assertion generating device for an interface test case according to an embodiment of the present application. As shown in fig. 3, the assertion generating device for the interface test case includes:
an obtaining unit 310, configured to obtain a test case for performing an interface test;
a determining unit 320, configured to determine an application scenario of the test case;
the matching unit 330 is configured to match a target assertion template from a preset assertion template library according to the test case and the application scenario;
the filling unit 340 is configured to fill the assertion part of the test case according to the target assertion template to obtain a target test case;
the test unit 350 is configured to perform an interface test using the target test case to obtain a test result;
and the assertion unit 360 is used for performing assertion judgment according to the test result.
In this embodiment, for the explanation of the assertion generating device of the interface test case, reference may be made to the description in embodiment 1 or embodiment 2, and details are not repeated in this embodiment.
Therefore, the assertion generating device for the interface test case described in this embodiment can automatically identify the generating cases of different scenes according to the interface, and generate assertion generating templates of different scenes at the same time; the scene use case and the scene template have an incidence relation. Meanwhile, a use case can be generated based on the interface, and an assertion part of the corresponding use case can be generated according to the assertion template. In addition, a path corresponding to a jpath or xpath and the like can be quickly generated according to a return body aiming at a service scene template or the condition that the upstream and downstream service scenes need to change, and a result corresponding to a return value obtained in the last call in a default value in the path can be provided, so that the condition of testing a large amount of manual writing assertions is avoided. Finally, foolproof assertion filling can be realized without knowing grammars such as xpath and the like through testing, time for testing and compiling cases is greatly reduced, and more time can be put into other aspects through testing.
Example 4
Referring to fig. 4, fig. 4 is a schematic structural diagram of an assertion generating device for an interface test case according to an embodiment of the present application. As shown in fig. 4, the assertion generating device for the interface test case includes:
an obtaining unit 310, configured to obtain a test case for performing an interface test;
a determining unit 320, configured to determine an application scenario of the test case;
the matching unit 330 is configured to match a target assertion template from a preset assertion template library according to the test case and the application scenario;
the filling unit 340 is used for filling the assertion part of the test case according to the target assertion template to obtain a target test case;
the test unit 350 is configured to perform an interface test using the target test case to obtain a test result;
and the assertion unit 360 is used for performing assertion judgment according to the test result.
As an optional implementation manner, the assertion generating device for the interface test case further includes:
a determining unit 370, configured to determine whether an assertion supplement instruction for the interrupt result of the test result is received after performing an interface test using the target test case to obtain the test result;
and the supplement unit 380 is configured to perform assertion supplement according to the assertion supplement instruction and the assertion result when it is determined that the assertion supplement instruction is received.
As an optional implementation manner, the supplementing unit 380 is specifically configured to, when it is determined that the predicated supplementing instruction is received and the predicated supplementing instruction is the template supplementing instruction, supplement the target predicated template according to the predicated supplementing instruction; and when the fact that the assertion supplement instruction is received and the assertion supplement instruction is the template adding instruction is judged, obtaining the adding template according to the assertion supplement instruction, and adding the adding template into the assertion template library.
As an alternative embodiment, the supplementary unit 380 includes:
the determining subunit 381 is configured to determine, when it is determined that the predicated supplementary instruction is received and the predicated supplementary instruction is the template supplementary instruction, the selected corresponding field according to the predicated supplementary instruction;
a complementary subunit 382 for populating the corresponding field into the target assertion template.
In this embodiment, the assertion result at least includes an interface test basic request field, a returned check result, a field type, a field logical mutual exclusion result, a test request interface, and a corresponding path automatically generated according to a return body of the request interface.
In this embodiment, the description in embodiment 1 or embodiment 2 may be referred to for an explanation of an assertion generating device of an interface test case, and details are not repeated in this embodiment.
Therefore, the assertion generating device for the interface test case described in this embodiment can automatically identify the generating cases of different scenes according to the interface, and generate assertion generating templates of different scenes at the same time; the scene use case and the scene template have an incidence relation. Meanwhile, a use case can be generated based on the interface, and an assertion part of the corresponding use case can be generated according to the assertion template. In addition, a path corresponding to a jpath or xpath and the like can be quickly generated according to a return body aiming at a service scene template or the condition that the upstream and downstream service scenes need to change, and a result corresponding to a return value obtained in the last call in a default value in the path can be provided, so that the condition of testing a large amount of manual writing assertions is avoided. Finally, foolproof assertion filling can be realized without the need of testing to know the syntax of xpath and the like, so that the time for testing and writing cases is greatly reduced, and more time can be put into other aspects for testing.
An embodiment of the present application provides an electronic device, including a memory and a processor, where the memory is used to store a computer program, and the processor runs the computer program to make the electronic device execute an assertion generation method of an interface test case in embodiment 1 or embodiment 2 of the present application.
An embodiment of the present application provides a computer-readable storage medium, which stores computer program instructions, where the computer program instructions, when read and executed by a processor, perform the assertion generating method of the interface test case in embodiment 1 or embodiment 2 of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented in other ways. The apparatus embodiments described above are merely illustrative, and for example, the flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
In addition, functional modules in the embodiments of the present application may be integrated together to form an independent part, or each module may exist alone, or two or more modules may be integrated to form an independent part.
The functions, if implemented in the form of software functional modules 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 application or portions thereof that substantially contribute to the prior art may be embodied in the form of a software product stored in a storage medium and including 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 application. 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 various media capable of storing program codes.
The above description is only an example of the present application and is not intended to limit the scope of the present application, and various modifications and changes may be made to the present application by those skilled in the art. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application shall be included in the protection scope of the present application. It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, it need not be further defined and explained in subsequent figures.
The above description is only for the specific embodiments of the present application, but the scope of the present application is not limited thereto, and any person skilled in the art can easily conceive of the changes or substitutions within the technical scope of the present application, and shall be covered by the scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
It is noted that, herein, relational terms such as first and second, and the like may be 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. Also, 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 phrases "comprising one of 8230; \8230;" 8230; "does not exclude the presence of additional like elements in a process, method, article, or apparatus that comprises the element.

Claims (10)

1. An assertion generating method of an interface test case is characterized by comprising the following steps:
acquiring a test case for interface test;
determining an application scene of the test case;
matching a target assertion template from a preset assertion template library according to the test case and the application scene;
filling the assertion part of the test case according to the target assertion template to obtain a target test case;
using the target test case to carry out interface test to obtain a test result;
and performing assertion judgment according to the test result.
2. The method for generating assertion of interface test case according to claim 1, wherein after the interface test using the target test case obtains a test result, the method further comprises:
judging whether an assertion supplement instruction aiming at the interrupt statement result of the test result is received;
and if so, performing predicate supplement according to the predicate supplement instruction and the predicate result.
3. The method for generating a predicate of an interface test case according to claim 2, wherein performing predicate supplementation according to the predicate supplementation instruction and the predicate result comprises:
when the predicated supplementary instruction is a template supplementary instruction, supplementing the target predicated template according to the predicated supplementary instruction;
and when the predicated supplementary instruction is a template adding instruction, obtaining a new template according to the predicated supplementary instruction, and adding the new template into the predicated template library.
4. The method for generating the assertion of the interface test case according to claim 3, wherein the supplementing the target assertion template according to the assertion supplementing instruction includes:
determining the selected corresponding field according to the assertion supplement instruction;
and filling the corresponding field into the target assertion template.
5. The method for generating assertion of interface test case as claimed in claim 2, wherein the assertion result at least includes an interface test basic request field, a returned check result, a field type, a field logical exclusion result, a test request interface, and a corresponding path automatically generated according to a returning body of the request interface.
6. An assertion generating device of an interface test case is characterized in that the assertion generating device of the interface test case comprises:
the device comprises an acquisition unit, a test unit and a test unit, wherein the acquisition unit is used for acquiring a test case for interface test;
the determining unit is used for determining the application scene of the test case;
the matching unit is used for matching a target assertion template from a preset assertion template library according to the test case and the application scene;
the filling unit is used for filling the assertion part of the test case according to the target assertion template to obtain a target test case;
the test unit is used for carrying out interface test by using the target test case to obtain a test result;
and the assertion unit is used for performing assertion judgment according to the test result.
7. The apparatus according to claim 6, wherein the apparatus further comprises:
the judging unit is used for judging whether an assertion supplement instruction aiming at the interrupt result of the test result is received or not after the target test case is used for carrying out interface test and obtaining the test result;
and the supplement unit is used for performing assertion supplement according to the assertion supplement instruction and the assertion result when judging that the assertion supplement instruction is received.
8. The apparatus according to claim 7, wherein the supplementation unit is specifically configured to, when it is determined that the complementary instruction for assertion is received and the complementary instruction for assertion is a template complementary instruction, supplement the target assertion template according to the complementary instruction for assertion; and when the predicated supplementary instruction is judged to be received and is a template adding instruction, obtaining a new template according to the predicated supplementary instruction, and adding the new template into the predicated template library.
9. An electronic device, comprising a memory for storing a computer program and a processor for executing the computer program to cause the electronic device to perform the assertion generating method of the interface test case according to any one of claims 1 to 5.
10. A readable storage medium having stored therein computer program instructions which, when read and executed by a processor, perform the method for generating assertions of interface test cases according to any one of claims 1-5.
CN202211145971.6A 2022-09-20 2022-09-20 Assertion generation method and device of interface test case Pending CN115509904A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211145971.6A CN115509904A (en) 2022-09-20 2022-09-20 Assertion generation method and device of interface test case

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211145971.6A CN115509904A (en) 2022-09-20 2022-09-20 Assertion generation method and device of interface test case

Publications (1)

Publication Number Publication Date
CN115509904A true CN115509904A (en) 2022-12-23

Family

ID=84504541

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211145971.6A Pending CN115509904A (en) 2022-09-20 2022-09-20 Assertion generation method and device of interface test case

Country Status (1)

Country Link
CN (1) CN115509904A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117724986A (en) * 2024-02-08 2024-03-19 云账户技术(天津)有限公司 Method and device for automatically operating kafka in use case execution
CN117762808A (en) * 2023-12-27 2024-03-26 青矩技术股份有限公司 Interface assertion testing method, device, equipment and storage medium

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117762808A (en) * 2023-12-27 2024-03-26 青矩技术股份有限公司 Interface assertion testing method, device, equipment and storage medium
CN117724986A (en) * 2024-02-08 2024-03-19 云账户技术(天津)有限公司 Method and device for automatically operating kafka in use case execution
CN117724986B (en) * 2024-02-08 2024-05-07 云账户技术(天津)有限公司 Method and device for automatically operating kafka in use case execution

Similar Documents

Publication Publication Date Title
CN115509904A (en) Assertion generation method and device of interface test case
CN109871326B (en) Script recording method and device
US20100180263A1 (en) Apparatus and method for detecting software error
US10019347B2 (en) Systems and methods for selection of test cases for payment terminals
US20110145799A1 (en) Path-sensitive dataflow analysis including path refinement
WO2016026328A1 (en) Information processing method and device and computer storage medium
WO2020237508A1 (en) Assertion validation code binding method and apparatus
JP3822044B2 (en) Design verification system, design verification method, and computer-readable recording medium storing design verification program
CN108846069B (en) Document execution method and device based on markup language
CN111427578B (en) Data conversion method, device and equipment
US8140315B2 (en) Test bench, method, and computer program product for performing a test case on an integrated circuit
CN115455166A (en) Method, device, medium and equipment for detecting abnormality of intelligent dialogue system
CN106874181B (en) Interface conversion verification method and device
CN109542785B (en) Invalid bug determination method and device
CN106201859A (en) A kind of regression testing method and system
CN106250755A (en) For generating the method and device of identifying code
CN111221690B (en) Model determination method and device for integrated circuit design and terminal
CN115033434B (en) Method and device for calculating kernel performance theoretical value and storage medium
CN110765008A (en) Data processing method and device
CN113805861B (en) Code generation method based on machine learning, code editing system and storage medium
CN112463633B (en) Method, device, equipment and medium for checking address decoding of on-chip memory
CN110471829B (en) Method and device for checking software code test coverage rate
CN109903165B (en) Model merging method and device
CN108255802B (en) Universal text parsing architecture and method and device for parsing text based on architecture
CN112596781A (en) Service execution and service configuration method and device

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