CN117687914A - Test case generation method, device, equipment and medium based on contract file - Google Patents

Test case generation method, device, equipment and medium based on contract file Download PDF

Info

Publication number
CN117687914A
CN117687914A CN202311708098.1A CN202311708098A CN117687914A CN 117687914 A CN117687914 A CN 117687914A CN 202311708098 A CN202311708098 A CN 202311708098A CN 117687914 A CN117687914 A CN 117687914A
Authority
CN
China
Prior art keywords
contract
call link
target call
transaction
field
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
CN202311708098.1A
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.)
Agricultural Bank of China
Original Assignee
Agricultural Bank of China
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 Agricultural Bank of China filed Critical Agricultural Bank of China
Priority to CN202311708098.1A priority Critical patent/CN117687914A/en
Publication of CN117687914A publication Critical patent/CN117687914A/en
Pending legal-status Critical Current

Links

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application discloses a contract file-based test case generation method, device, equipment and medium; the method comprises the following steps: receiving a test granularity selection instruction of a micro-service system sent by a tester; the test granularity selection instruction comprises the number of micro services of the shortest call link; extracting each target call link from a pre-generated call link set in response to the test granularity selection instruction; and generating test cases of the micro service system based on the contract files corresponding to the pre-acquired target call links. According to the embodiment of the application, the test case can be automatically generated based on the contract file, so that the writing efficiency of the test case can be effectively improved, the granularity of the generation of the test case can be flexibly adjusted, and the test requirement under different backgrounds can be met.

Description

Test case generation method, device, equipment and medium based on contract file
Technical Field
The embodiment of the application relates to the technical field of software testing, in particular to a test case generation method, device, equipment and medium based on contract files.
Background
With the continuous penetration of digital transformation and the increasingly competitive situation of the financial industry, the application architecture of the products in the financial industry has gradually changed from the traditional single service architecture to the micro service architecture. The software test of the micro-service architecture should also adjust the test method and tool, so as to improve the test efficiency and the test coverage rate and ensure that all micro-services meet the test quality requirement.
Essentially, a micro-Service is a variant of Service-oriented architecture (SOA) that advocates the division of a single application into several small services. In the micro-service architecture, all services are mutually accessed through a lightweight communication mechanism, and meanwhile, not all services are necessarily interacted with the front end directly, so that the testing of the micro-service architecture system needs to be compatible with the front end interface testing and the interaction testing among the services.
In the development and test process of the current system using the micro-service architecture, testers still stay at the stage of writing test cases based on test scenes, requirement specifications and test experience, but the traditional test case writing mode has the following two problems: 1) The test case writing efficiency is low. The traditional test case writing mode depends on the familiarity degree of a tester to a system and the detail degree of a demand specification, and if the experience of the tester is insufficient, the situations of long time consumption, low efficiency and the like of case design can occur; 2) The coverage scene of the test case is not comprehensive. Because the traditional use cases are designed according to the software requirement specification, the focus is more on the correctness of the overall interface functions of the software, the calling correctness among the micro services is not verified, the scene design is isolated, the service cannot be positioned by the execution of the use cases, and the risks of incomplete coverage scene and incomplete function test of the test use cases exist.
Disclosure of Invention
The method, the device, the equipment and the medium for generating the test case based on the contract file can automatically generate the test case based on the contract file, so that the writing efficiency of the test case can be effectively improved, the granularity of the generation of the test case can be flexibly adjusted, and the method, the device, the equipment and the medium are suitable for test requirements under different backgrounds.
In a first aspect, an embodiment of the present application provides a method for generating a test case based on a contract file, where the method includes:
receiving a test granularity selection instruction of a micro-service system sent by a tester; wherein the test granularity selection instruction comprises the number of micro services of the shortest call link;
extracting each target call link from a pre-generated call link set in response to the test granularity selection instruction;
and generating the test case of the micro service system based on the contract file corresponding to each target call link obtained in advance.
In a second aspect, an embodiment of the present application further provides a test case generating device based on a contract file, where the device includes: the device comprises a receiving module, an extracting module and a generating module; wherein,
the receiving module is used for receiving a test granularity selection instruction of the micro-service system sent by a tester; wherein the test granularity selection instruction comprises the number of micro services of the shortest call link;
The extraction module is used for responding to the test granularity selection instruction and extracting each target call link from a pre-generated call link set;
the generation module is used for generating the test case of the micro-service system based on the contract files corresponding to the target call links obtained in advance.
In a third aspect, an embodiment of the present application provides an electronic device, including:
one or more processors;
a memory for storing one or more programs,
and when the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the test case generation method based on the contract file according to any embodiment of the application.
In a fourth aspect, embodiments of the present application provide a storage medium having stored thereon a computer program that, when executed by a processor, implements the contract file-based test case generation method according to any embodiment of the present application.
The embodiment of the application provides a test case generation method, device, equipment and medium based on contract files, which are used for receiving test granularity selection instructions of a micro-service system sent by a tester; then, each target call link is extracted from a pre-generated call link set in response to the test granularity selection instruction; and generating test cases of the micro-service system based on the contract files corresponding to the target call links obtained in advance. That is, in the technical solution of the present application, a test case of the micro service system may be generated based on the contract file corresponding to each target call link. In the prior art, the testers still stay at the stage of compiling test cases based on test scenes, requirement specifications and test experiences, so that not only is the efficiency of compiling the test cases low, but also the coverage scenes of the test cases are not comprehensive. Therefore, compared with the prior art, the test case generation method, the device, the equipment and the medium of the contract file provided by the embodiment of the invention can automatically generate the test case based on the contract file, thereby effectively improving the writing efficiency of the test case, flexibly adjusting the granularity of the generation of the test case and adapting to the test requirements under different backgrounds; in addition, the technical scheme of the embodiment of the application is simple and convenient to realize, convenient to popularize and wider in application range.
Drawings
FIG. 1 is a first flow chart of a method for generating test cases based on contract files according to an embodiment of the present application;
fig. 2 is a schematic structural diagram of a micro service system according to an embodiment of the present application;
FIG. 3 is a second flow chart of a method for generating test cases based on contract files according to an embodiment of the present application;
FIG. 4 is a first flow chart of a chained transaction extraction method according to an embodiment of the present disclosure;
FIG. 5 is a second flow chart of a chained transaction extraction method according to an embodiment of the present disclosure;
fig. 6 is a schematic structural diagram of a test case generating device based on a contract file according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The present application is described in further detail below with reference to the drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the application and not limiting thereof. It should be further noted that, for convenience of description, only some, but not all of the structures related to the present application are shown in the drawings.
Example 1
Fig. 1 is a schematic flow chart of a test case generating method based on a contract file according to an embodiment of the present application, where the method may be performed by a test case generating device or an electronic device based on a contract file, where the device or the electronic device may be implemented by software and/or hardware, and the device or the electronic device may be integrated into any intelligent device with a network communication function. As shown in fig. 1, the test case generation method based on the contract file may include the following steps:
S101, receiving a test granularity selection instruction of a micro-service system sent by a tester; wherein the test granularity selection instruction includes a number of micro services of the shortest call link.
In this step, the tester may select the number of micro services of the shortest call link on the user operation interface, for example, the number of micro services of the shortest call link may be 2, 3, 4, etc., so as to generate a test granularity selection instruction of the micro service system.
S102, each target call link is extracted from a pre-generated call link set in response to the test granularity selection instruction.
In this step, the electronic device may extract a call link from the call link set generated in advance as the current call link; if the number of micro services of the current call link is greater than or equal to the number of micro services of the shortest call link, the electronic device may extract the current call link from the call link set as a target call link; and repeatedly executing the operation until each target call link is extracted from the call link set.
S103, generating test cases of the micro service system based on contract files corresponding to the target call links obtained in advance.
In this step, the electronic device may determine, according to the number of micro services in each target call link, that the transaction extraction mode of each target call link is a chained transaction extraction mode or a paired transaction extraction mode; then generating a transaction set corresponding to each target call link according to a chained transaction extraction mode or a opposite transaction extraction mode based on a contract file corresponding to each target call link which is acquired in advance; and generating test cases of the micro-service system based on the transaction sets corresponding to the target call links.
Fig. 2 is a schematic structural diagram of a micro service system according to an embodiment of the present application. As shown in fig. 2, the system may include four micro services, respectively: micro service a, micro service B, micro service C, and micro service D; wherein arrows between micro services represent calls and dependencies. The micro service A has a plurality of data structures, and the micro service B calls partial data in the micro service A, namely the micro service A is a service provider, and the micro service B is a service consumer. At this time, a contract file is generated between the micro service a and the micro service B, and attributes such as field name, field type, value range and the like are defined. As shown in FIG. 2, this contract file may be defined as Con AB . Similarly, there are four other contract files in the system, respectively: con (Con) AC 、Con BC 、Con CD Con DC
In a specific embodiment of the present application, the request information in the contract file may be first converted into a specified format, where each field and its related attribute are stored separately as a plurality of groups, where the related attribute may include: absolute path, field type, matching rules. The converted contract file is composed of a plurality of arrays: con (Con) MN = [ [ field 1 absolute path, field type, r MN1 ]… [ field n absolute path, field type, r MNn ]]Wherein M is a service party, N is a consumer party, r MNn Is a contract file Con MN The verification rule of the nth field is used for verifying the validity and correctness of the value of the field n, and the general specification is a regular expression. As shown in FIG. 2, a contract exists between the micro service A and the micro service C, and name, salary, phone three fields are contracted, and the converted Con is converted AC =[["name",string,r AC1 ],["salary",float,r AC2 ],["contact.phone",string,r AC3 ]]。
In a specific embodiment of the present application, the set { Con ] of contract files is passed MN Identifying all micro-service call links with direct or indirect dependency and forming a call link set { link } xyz… Where xyz, etc., represents a micro-service node in a link. The specific operation is as follows: 1) Sequentially traversing contract file set { Con MN Assume that the currently traversed contract file is Con ij . 2) Calling link set to add link ij Because the micro-services in all contract files have a direct call relationship. 3) Comparison Con ij { Con } MN If Con is present } jk So that Con ij [m]=Con jk [n]That is, the two contract files contain the same fields and related attributes, and at the moment, the nodes i, j and k have indirect dependency relationships, and the link set is called to add link ijk ,link ijk ={Con ij ,Con jk }. 4) Contract File set { Con } MN Complete traversal, generate call link set { link } xyz… }。
The test case generation method based on the contract file provided by the embodiment of the application firstly receives a test granularity selection instruction of a micro-service system sent by a tester; then, each target call link is extracted from a pre-generated call link set in response to the test granularity selection instruction; and generating test cases of the micro-service system based on the contract files corresponding to the target call links obtained in advance. That is, in the technical solution of the present application, a test case of the micro service system may be generated based on the contract file corresponding to each target call link. In the prior art, the testers still stay at the stage of compiling test cases based on test scenes, requirement specifications and test experiences, so that not only is the efficiency of compiling the test cases low, but also the coverage scenes of the test cases are not comprehensive. Therefore, compared with the prior art, the test case generation method of the contract file provided by the embodiment of the application can automatically generate the test case based on the contract file, so that the writing efficiency of the test case can be effectively improved, the granularity of the generation of the test case can be flexibly adjusted, and the test case generation method is suitable for test requirements under different backgrounds; in addition, the technical scheme of the embodiment of the application is simple and convenient to realize, convenient to popularize and wider in application range.
Example two
Fig. 3 is a second flow chart of a test case generating method based on a contract file according to an embodiment of the present application. Further optimization and expansion based on the above technical solution can be combined with the above various alternative embodiments. As shown in fig. 3, the test case generation method based on the contract file may include the following steps:
s301, receiving a test granularity selection instruction of a micro-service system sent by a tester; wherein the test granularity selection instruction includes a number of micro services of the shortest call link.
S302, each target call link is extracted from a pre-generated call link set in response to the test granularity selection instruction.
S303, determining that the transaction extraction mode of each target call link is a chained transaction extraction mode or a opposite transaction extraction mode according to the number of micro services of the shortest call link.
In the step, if the number of micro services of the shortest call link is equal to 2, determining that the transaction extraction mode of each target call link is a opposite transaction extraction mode; if the number of micro services of the shortest call link is greater than 2, determining that the transaction extraction mode of each target call link is a chained transaction extraction mode.
S304, generating a transaction set corresponding to each target call link according to a chained transaction extraction mode or a opposite transaction extraction mode based on a contract file corresponding to each target call link which is acquired in advance.
In this step, the electronic device may generate, according to a chained transaction extraction manner or a pair-type transaction extraction manner, a transaction set corresponding to each target call link based on a contract file corresponding to each target call link obtained in advance. Specifically, when generating the transaction set corresponding to each target call link according to the chained transaction extraction mode, each field array in each contract file corresponding to each target call link can be disassembled first to obtain each field array corresponding to each contract file; then comparing the field arrays corresponding to each two contract files of each target call link one by one to obtain the comparison result of the field arrays corresponding to each two contract files of each target call link; and generating transaction sets corresponding to the target call links according to the comparison results of the field arrays corresponding to each two contract files of the target call links. When generating the transaction set corresponding to each target call link according to the opposite transaction extraction mode, each transaction corresponding to each target call link and the connection state of each target call link in each transaction can be constructed according to the value of each target field array in the contract file corresponding to each target call link; wherein, the value of the target field array comprises legal or illegal; the connection state includes a passage or a blockage; and then generating a transaction set corresponding to each target call link according to each transaction corresponding to each target call link and the connection state of each target call link in each transaction.
S305, generating test cases of the micro service system based on transaction sets corresponding to all target call links.
In this step, by reading the transaction set transaction, all transactions 1, 2, …, transaction in the transaction set transaction are obtained, each transaction representing a single possibility of value of all fields of the corresponding service link or service object. And reading the field values of the trans1, trans2, … and trans i in sequence, filling the field values into a test case template according to the field rules, and automatically generating a test case.
The test case generation method based on the contract file provided by the embodiment of the application firstly receives a test granularity selection instruction of a micro-service system sent by a tester; then, each target call link is extracted from a pre-generated call link set in response to the test granularity selection instruction; and generating test cases of the micro-service system based on the contract files corresponding to the target call links obtained in advance. That is, in the technical solution of the present application, a test case of the micro service system may be generated based on the contract file corresponding to each target call link. In the prior art, the testers still stay at the stage of compiling test cases based on test scenes, requirement specifications and test experiences, so that not only is the efficiency of compiling the test cases low, but also the coverage scenes of the test cases are not comprehensive. Therefore, compared with the prior art, the test case generation method of the contract file provided by the embodiment of the application can automatically generate the test case based on the contract file, so that the writing efficiency of the test case can be effectively improved, the granularity of the generation of the test case can be flexibly adjusted, and the test case generation method is suitable for test requirements under different backgrounds; in addition, the technical scheme of the embodiment of the application is simple and convenient to realize, convenient to popularize and wider in application range.
Example III
Fig. 4 is a first flowchart of a chained transaction extraction method according to an embodiment of the present application. Further optimization and expansion based on the above technical solution can be combined with the above various alternative embodiments. As shown in fig. 4, the chained transaction extraction method may include the steps of:
s401, disassembling each field array in each contract file corresponding to each target call link to obtain each field array corresponding to each contract file.
In this step, the electronic device may disassemble each field array in each contract file corresponding to each target call link, to obtain each field array corresponding to each contract file. Assume that the target invokes the link ACD The corresponding contract file includes Con AC And Con CD I.e. link ACD ={Con AC ,Con CD By traversing link ACD Con can be obtained AC =[["name",string,r AC1 ],["salary",float,r Ac2 ],["contact.phone",string,r AC3 ]],Con cd =[["name",string,r CD1 ],["contact.phone",string,r CD2 ]]. To Con AC The field array in the file is disassembled to obtain the filtered AC1 =["name",string,r AC1 ],filed AC2 =["salary",float,r AC2 ],filed AC3 =["contact.phone",string,r AC3 ]. To Con CD The field array in the file is disassembled to obtain the filtered CD1 =["name",string,r CD1 ],filed CD2 =["contact.phone",string,r CD2 ]。
S402, comparing each field array corresponding to every two contract files of each target call link one by one to obtain a comparison result of each field array corresponding to every two contract files of each target call link.
In this step, the electronic device may compare each field array corresponding to each two contract files of each target call link one by one, to obtain a comparison result of each field array corresponding to each two contract files of each target call link. Specifically, the electronic device may be configured to AC1 And filled with CD1 And filled up CD2 Respectively comparing the obtained materials AC2 And filled with CD1 And filled up CD2 Respectively comparing the obtained materials AC3 And filled with CD1 And filled up CD2 And respectively carrying out comparison. By comparison, find that the film is CD1 、filed CD2 And filled with AC1 、filed AC3 The absolute path, the field type and the matching rule in the data are completely consistent, and then a conclusion can be drawn that the data are filtered CD1 、filed CD2 And filled up AC1 、filed AC3 Identical, and filled with CD1 、filed CD2 From filled AC1 、filed AC3
S403, generating transaction sets corresponding to all target call links according to comparison results of all field arrays corresponding to every two contract files of all target call links.
In this step, the electronic device may generate the transaction set corresponding to each target call link according to the comparison result of each field array corresponding to each two contract files of each target call link. Specifically, according to the filled AC1 、filed AC2 、filed AC3 Respectively with the filed CD1 And filled up CD2 Four types of transactions can be abstracted, and the transaction results are respectively: 1) When filled with AC1 、filed AC3 The value of (2) accords with the check rule r of the corresponding field AC1 、r AC3 And Con AC Unique filed AC2 Also satisfies the check rule r AC2 Link when ACD For the path, the three fields are completely in accordance with the check rule and link ACD The possibilities for the path are abstracted as transaction 1: trans s 1 = { legal name, legal salary, legal phone }. 2) When filled with AC1 When the value is illegal, but the value is filtered AC2 And filled up AC3 The value accords with the check rule r AC2 、r AC3 Link when ACD Blocking, such a link possibility can be abstracted as transaction 2: trans s 2 = { illegal name, legal salary, legal phone }. 3) When filled with AC3 When the value is illegal, but the value is filtered AC1 And filled up AC2 The value accords with the check rule r AC1 、r AC2 Link when ACD Blocking, the mid-link likelihood may be abstracted as transaction 3: trans s 3 = { legal name, legal salary, illegal phone }. 4) When filled with AC2 When the value is illegal, but the value is filtered AC1 And filled up AC3 The value accords with the check rule r AC1 、r AC3 Link when ACD Link blocking may result from communication anomalies between AC transactions. This link possibility can be abstracted as transaction 4: trans s 4 = { legal name, illegal salary, legal phone }.
The test case generation method based on the contract file provided by the embodiment of the application firstly receives a test granularity selection instruction of a micro-service system sent by a tester; then, each target call link is extracted from a pre-generated call link set in response to the test granularity selection instruction; and generating test cases of the micro-service system based on the contract files corresponding to the target call links obtained in advance. That is, in the technical solution of the present application, a test case of the micro service system may be generated based on the contract file corresponding to each target call link. In the prior art, the testers still stay at the stage of compiling test cases based on test scenes, requirement specifications and test experiences, so that not only is the efficiency of compiling the test cases low, but also the coverage scenes of the test cases are not comprehensive. Therefore, compared with the prior art, the test case generation method of the contract file provided by the embodiment of the application can automatically generate the test case based on the contract file, so that the writing efficiency of the test case can be effectively improved, the granularity of the generation of the test case can be flexibly adjusted, and the test case generation method is suitable for test requirements under different backgrounds; in addition, the technical scheme of the embodiment of the application is simple and convenient to realize, convenient to popularize and wider in application range.
Example IV
Fig. 5 is a second flow chart of a chained transaction extraction method according to an embodiment of the present application. Further optimization and expansion based on the above technical solution can be combined with the above various alternative embodiments. As shown in fig. 5, the chained transaction extraction method may include the steps of:
s501, disassembling each field array in each contract file corresponding to each target call link to obtain each field array corresponding to each contract file.
In this step, the electronic device may disassemble each field array in each contract file corresponding to each target call link, to obtain each field array corresponding to each contract file. Assume that the target invokes the link ACD The corresponding contract file includes Con AC And Con CD I.e. link ACD ={Con AC ,Con CD By traversing link ACD Con can be obtained AC And Con CD The method comprises the steps of carrying out a first treatment on the surface of the Wherein Con AC =["name",string,r AC1 ],["salary",float,r AC2 ],["contact.phone",string,r AC3 ],Con CD =[["name",string,r CD1 ],["contact.phone",string,r CD2 ]]. To Con AC The field array in the file is disassembled to obtain the filtered AC1 =["name",string,r AC1 ],filed AC2 =["salary",float,r AC2 ],filed AC3 =["contact.phone",string,r AC3 ]. To Con CD Number of fields in (b)Disassembling the group to obtain a filtered CD1 =["name",string,r CD1 ],filed CD2 =["contact.phone",string,r CD2 ]。
S502, taking each two contract files of each target call link as a first contract file and a second contract file respectively, and extracting a field array from the first contract file and the second contract file respectively to serve as a current first field array and a current second field array.
In this step, the electronic device may use each two contract files of each target call link as a first contract file and a second contract file, and extract a field array from the first contract file and the second contract file as a current first field array and a current second field array, respectively. Specifically, the electronic device may be at Con AC And Con CD Extracting field array filtered AC1 And filled up CD1 As a current first field array and a current second field array.
S503, respectively extracting each field attribute from the current first field array and the current second field array according to the data format of the predetermined contract file; wherein, the field attribute includes: field name, absolute path, field type, and matching rules.
In this step, the electronic device may extract each field attribute from the current first field array and the current second field array according to the data format of the predetermined contract file. Specifically, the electronic device may be in a filled state AC1 The following field attributes are extracted: "name", string, r AC1 The method comprises the steps of carrying out a first treatment on the surface of the At the time of filling CD1 The following field attributes are extracted: "name", string, r CD1
S504, if each field attribute in the current first field array is consistent with the corresponding field attribute in the current second field array, judging that the current first field array is consistent with the current second field array; if any one field attribute in the current first field array is inconsistent with the corresponding field attribute in the current second field array, judging that the current first field array is inconsistent with the current second field array; and repeatedly executing the operation until the comparison result of the field arrays corresponding to each two contract files is obtained.
In this step, if each field attribute in the current first field array is consistent with the corresponding field attribute in the current second field array, the electronic device may determine that the current first field array is consistent with the current second field array; if any one of the field attributes in the current first field array is inconsistent with the corresponding field attribute in the current second field array, the electronic device can determine that the current first field array is inconsistent with the current second field array; and repeatedly executing the operation until the comparison result of the field arrays corresponding to each two contract files is obtained. Specifically, if it is shaped AC1 "name", string, r AC1 And filled with CD1 "name", string, r CD1 Respectively corresponding to the obtained values, the electronic device can determine the filtered AC1 And filled with CD1 Consistent; if it is filled with AC1 "name", string, r AC1 Any one of field attributes and filtered CD1 The corresponding field attributes in the file are inconsistent, the electronic device can determine the file AC1 And filled with CD1 And is inconsistent.
S505, generating transaction sets corresponding to all target call links according to comparison results of all field arrays corresponding to every two contract files of all target call links.
In this step, the electronic device may generate the transaction set corresponding to each target call link according to the comparison result of each field array corresponding to each two contract files of each target call link. Specifically, the electronic device may extract, according to a comparison result of each field array corresponding to each two contract files of each target call link, each target field array from field arrays corresponding to all contract files of each target call link; then constructing each transaction corresponding to each target call link and the connection state of each target call link in each transaction according to the value of each target field array; wherein, the value of the target field array comprises legal or illegal; the connection state includes a passage or a blockage; and generating a transaction set corresponding to each target call link according to each transaction corresponding to each target call link and the connection state of each target call link in each transaction.
In a specific embodiment of the present application, a method for generating a transaction set corresponding to each target call link according to a peer-to-peer transaction extraction manner may include the following steps: firstly, constructing each transaction corresponding to each target call link and the connection state of each target call link in each transaction according to the value of each target field array in the contract file corresponding to each target call link; wherein, the value of the target field array comprises legal or illegal; the connection state includes a passage or a blockage; and then generating a transaction set corresponding to each target call link according to each transaction corresponding to each target call link and the connection state of each target call link in each transaction. The granularity set by the user is link AC =(Con AC ) For example, for Con AC The field array in (1) is extracted due to Con AC Each field array in the array has both legal and illegal possibilities, so that a number of 2 can be obtained by a full permutation mode n Transaction set Translist AC ,translist AC ={trans 1 ,trans 2 ,…,trans i },i≤2 n N is Con AC The number of fields in (a); wherein trans i = { legal field 1, legal field 2, …, illegal field i }.
The test case generation method based on the contract file provided by the embodiment of the application firstly receives a test granularity selection instruction of a micro-service system sent by a tester; then, each target call link is extracted from a pre-generated call link set in response to the test granularity selection instruction; and generating test cases of the micro-service system based on the contract files corresponding to the target call links obtained in advance. That is, in the technical solution of the present application, a test case of the micro service system may be generated based on the contract file corresponding to each target call link. In the prior art, the testers still stay at the stage of compiling test cases based on test scenes, requirement specifications and test experiences, so that not only is the efficiency of compiling the test cases low, but also the coverage scenes of the test cases are not comprehensive. Therefore, compared with the prior art, the test case generation method of the contract file provided by the embodiment of the application can automatically generate the test case based on the contract file, so that the writing efficiency of the test case can be effectively improved, the granularity of the generation of the test case can be flexibly adjusted, and the test case generation method is suitable for test requirements under different backgrounds; in addition, the technical scheme of the embodiment of the application is simple and convenient to realize, convenient to popularize and wider in application range.
Example five
Fig. 6 is a schematic structural diagram of a test case generating device based on a contract file according to an embodiment of the present application. As shown in fig. 6, the test case generating device based on the contract file includes: a receiving module 601, an extracting module 602 and a generating module 603; wherein,
the receiving module 601 is configured to receive a test granularity selection instruction of a micro service system sent by a tester; wherein the test granularity selection instruction comprises the number of micro services of the shortest call link;
the extracting module 602 is configured to extract each target call link from a pre-generated call link set in response to the test granularity selection instruction;
the generating module 603 is configured to generate a test case of the micro service system based on a contract file corresponding to each target call link obtained in advance.
The contract file-based test case generating device can execute the method provided by any embodiment of the application, and has the corresponding functional modules and beneficial effects of the executing method. Technical details which are not described in detail in the present embodiment may refer to the test case generation method based on the contract file provided in any embodiment of the present application.
Example six
Fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present application. Fig. 7 illustrates a block diagram of an exemplary electronic device suitable for use in implementing embodiments of the present application. The electronic device 12 shown in fig. 7 is merely an example and should not be construed as limiting the functionality and scope of use of embodiments of the present application.
As shown in fig. 7, the electronic device 12 is in the form of a general purpose computing device. Components of the electronic device 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, a bus 18 that connects the various system components, including the system memory 28 and the processing units 16.
Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, and a local bus using any of a variety of bus architectures. By way of example, and not limitation, such architectures include Industry Standard Architecture (ISA) bus, micro channel architecture (MAC) bus, enhanced ISA bus, video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.
Electronic device 12 typically includes a variety of computer system readable media. Such media can be any available media that is accessible by electronic device 12 and includes both volatile and nonvolatile media, removable and non-removable media.
The system memory 28 may include computer system readable media in the form of volatile memory, such as Random Access Memory (RAM) 30 and/or cache memory 32. The electronic device 12 may further include other removable/non-removable, volatile/nonvolatile computer system storage media. By way of example only, storage system 34 may be used to read from or write to non-removable, nonvolatile magnetic media (not shown in FIG. 7, commonly referred to as a "hard disk drive"). Although not shown in fig. 7, a magnetic disk drive for reading from and writing to a removable non-volatile magnetic disk (e.g., a "floppy disk"), and an optical disk drive for reading from or writing to a removable non-volatile optical disk (e.g., a CD-ROM, DVD-ROM, or other optical media) may be provided. In such cases, each drive may be coupled to bus 18 through one or more data medium interfaces. Memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to carry out the functions of the embodiments of the present application.
A program/utility 40 having a set (at least one) of program modules 42 may be stored in, for example, memory 28, such program modules 42 including, but not limited to, an operating system, one or more application programs, other program modules, and program data, each or some combination of which may include an implementation of a network environment. Program modules 42 generally perform the functions and/or methods in the embodiments described herein.
The electronic device 12 may also communicate with one or more external devices 14 (e.g., keyboard, pointing device, display 24, etc.), one or more devices that enable a user to interact with the electronic device 12, and/or any devices (e.g., network card, modem, etc.) that enable the electronic device 12 to communicate with one or more other computing devices. Such communication may occur through an input/output (I/O) interface 22. Also, the electronic device 12 may communicate with one or more networks such as a Local Area Network (LAN), a Wide Area Network (WAN) and/or a public network, such as the Internet, through a network adapter 20. As shown, the network adapter 20 communicates with other modules of the electronic device 12 over the bus 18. It should be appreciated that although not shown in fig. 7, other hardware and/or software modules may be used in connection with electronic device 12, including, but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, data backup storage systems, and the like.
The processing unit 16 executes programs stored in the system memory 28 to perform various functional applications and data processing, for example, to implement the contract file-based test case generation method provided in the embodiment of the present application.
Example seven
Embodiments of the present application provide a computer storage medium.
Any combination of one or more computer readable media may be employed in the computer readable storage media of the embodiments herein. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In this document, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device.
The computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
Computer program code for carrying out operations of the present application may be written in one or more programming languages, including an object oriented programming language such as Java, smalltalk, C ++ and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
Note that the above is only a preferred embodiment of the present application and the technical principle applied. Those skilled in the art will appreciate that the present application is not limited to the particular embodiments described herein, but is capable of numerous obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the present application. Therefore, while the present application has been described in connection with the above embodiments, the present application is not limited to the above embodiments, but may include many other equivalent embodiments without departing from the spirit of the present application, the scope of which is defined by the scope of the appended claims.

Claims (10)

1. A test case generation method based on contract files is characterized by comprising the following steps:
receiving a test granularity selection instruction of a micro-service system sent by a tester; wherein the test granularity selection instruction comprises the number of micro services of the shortest call link;
extracting each target call link from a pre-generated call link set in response to the test granularity selection instruction;
and generating the test case of the micro service system based on the contract file corresponding to each target call link obtained in advance.
2. The method of claim 1, wherein generating test cases for the micro-service system based on pre-acquired contract files corresponding to respective target call links comprises:
determining that the transaction extraction mode of each target call link is a chained transaction extraction mode or a opposite transaction extraction mode according to the number of micro services of the shortest call link;
based on contract files corresponding to all the target call links obtained in advance, generating a transaction set corresponding to all the target call links according to a chained transaction extraction mode or a opposite transaction extraction mode;
and generating the test case of the micro service system based on the transaction set corresponding to each target call link.
3. The method of claim 2, wherein generating the transaction set corresponding to each target call link in a chained transaction extraction manner based on the contract file corresponding to each target call link obtained in advance, comprises:
disassembling all field arrays in all contract files corresponding to all target call links to obtain all field arrays corresponding to all contract files;
comparing each field array corresponding to each two contract files of each target call link one by one to obtain a comparison result of each field array corresponding to each two contract files of each target call link;
And generating transaction sets corresponding to the target call links according to the comparison results of the field arrays corresponding to each two contract files of the target call links.
4. The method of claim 3, wherein comparing each field array corresponding to each two contract files of each target call link one by one to obtain a comparison result of each field array corresponding to each two contract files of each target call link, comprises:
taking each two contract files of each target call link as a first contract file and a second contract file respectively, and extracting a field array from the first contract file and the second contract file respectively to serve as a current first field array and a current second field array;
extracting each field attribute from the current first field array and the current second field array according to a data format of a predetermined contract file; wherein the field attributes include: field name, absolute path, field type, and matching rules;
if each field attribute in the current first field array is consistent with the corresponding field attribute in the current second field array, judging that the current first field array is consistent with the current second field array; if any one field attribute in the current first field array is inconsistent with the corresponding field attribute in the current second field array, judging that the current first field array is inconsistent with the current second field array; and repeatedly executing the operation until the comparison result of the field arrays corresponding to each two contract files is obtained.
5. The method of claim 3, wherein generating the transaction set corresponding to each target call link according to the comparison result of the field arrays corresponding to each two contract files of each target call link comprises:
extracting each target field array from the field arrays corresponding to all contract files of each target call link according to the comparison result of each field array corresponding to each two contract files of each target call link;
constructing each transaction corresponding to each target call link and the connection state of each target call link in each transaction according to the value of each target field array; wherein, the value of the target field array comprises legal or illegal; the connection state includes a passage or a blockage;
and generating a transaction set corresponding to each target call link according to each transaction corresponding to each target call link and the connection state of each target call link in each transaction.
6. The method of claim 2, wherein generating the transaction set corresponding to each target call link in the on-pair transaction extraction manner based on the contract file corresponding to each target call link acquired in advance, comprises:
Constructing each transaction corresponding to each target call link and the connection state of each target call link in each transaction according to the value of each target field array in the contract file corresponding to each target call link; wherein, the value of the target field array comprises legal or illegal; the connection state includes a passage or a blockage;
and generating a transaction set corresponding to each target call link according to each transaction corresponding to each target call link and the connection state of each target call link in each transaction.
7. The method of claim 1, wherein prior to receiving test granularity selection instructions for the micro-service system sent by the tester, the method further comprises:
extracting a contract file from a pre-constructed contract file set to serve as a current contract file;
comparing the current contract file with other contract files except the current contract file in the contract file set to obtain a comparison result of the current contract file and the contract files except the current contract file in the contract file set; repeatedly executing the operations until the comparison result of each contract file and other contract files is obtained;
And generating the calling link set according to the comparison result of each contract file and other contract files.
8. A contract file-based test case generation apparatus, the apparatus comprising: the device comprises a receiving module, an extracting module and a generating module; wherein,
the receiving module is used for receiving a test granularity selection instruction of the micro-service system sent by a tester; wherein the test granularity selection instruction comprises the number of micro services of the shortest call link;
the extraction module is used for responding to the test granularity selection instruction and extracting each target call link from a pre-generated call link set;
the generation module is used for generating the test case of the micro-service system based on the contract files corresponding to the target call links obtained in advance.
9. An electronic device, comprising:
one or more processors;
a memory for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors implement the contract file-based test case generation method of any of claims 1 to 7.
10. A storage medium having stored thereon a computer program, which when executed by a processor implements the contract file-based test case generation method according to any one of claims 1 to 7.
CN202311708098.1A 2023-12-12 2023-12-12 Test case generation method, device, equipment and medium based on contract file Pending CN117687914A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311708098.1A CN117687914A (en) 2023-12-12 2023-12-12 Test case generation method, device, equipment and medium based on contract file

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311708098.1A CN117687914A (en) 2023-12-12 2023-12-12 Test case generation method, device, equipment and medium based on contract file

Publications (1)

Publication Number Publication Date
CN117687914A true CN117687914A (en) 2024-03-12

Family

ID=90138628

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311708098.1A Pending CN117687914A (en) 2023-12-12 2023-12-12 Test case generation method, device, equipment and medium based on contract file

Country Status (1)

Country Link
CN (1) CN117687914A (en)

Similar Documents

Publication Publication Date Title
US11847438B2 (en) Offline capabilities for live applications in a cloud collaboration platform
CN110008045B (en) Method, device and equipment for aggregating microservices and storage medium
CA3051762A1 (en) Data isolation in a blockchain network
CN111427971B (en) Business modeling method, device, system and medium for computer system
US20120278353A1 (en) Searching with topic maps of a model for canonical model based integration
US10083398B2 (en) Framework for annotated-text search using indexed parallel fields
CN110134702A (en) Data flow joining method, device, equipment and storage medium
US20210090182A1 (en) Tensor-based predictions from analysis of time-varying graphs
CN114862656A (en) Method for acquiring training cost of distributed deep learning model based on multiple GPUs
CN104714942A (en) Method and system for usablility of content to natural language processing tasks.
US20210124752A1 (en) System for Data Collection, Aggregation, Storage, Verification and Analytics with User Interface
CN111339743B (en) Account number generation method and device
CN115510249A (en) Knowledge graph construction method and device, electronic equipment and storage medium
CN116244387A (en) Entity relationship construction method, device, electronic equipment and storage medium
CN113962597A (en) Data analysis method and device, electronic equipment and storage medium
US11403338B2 (en) Data module creation from images
CN117687914A (en) Test case generation method, device, equipment and medium based on contract file
US10691418B1 (en) Process modeling on small resource constraint devices
US9910890B2 (en) Synthetic events to chain queries against structured data
CN113608688A (en) Data migration method, device, equipment and storage medium
US11372704B2 (en) Advanced java dump analysis
US11989234B1 (en) Rule engine implementing a rule graph for record matching
CN110221827A (en) Data processing method and relevant apparatus
US11636391B2 (en) Automatic combinatoric feature generation for enhanced machine learning
CN111177183B (en) Method and device for generating database access statement

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