CN111881024A - Method, device, equipment and storage medium for determining interface test script - Google Patents

Method, device, equipment and storage medium for determining interface test script Download PDF

Info

Publication number
CN111881024A
CN111881024A CN202010670377.3A CN202010670377A CN111881024A CN 111881024 A CN111881024 A CN 111881024A CN 202010670377 A CN202010670377 A CN 202010670377A CN 111881024 A CN111881024 A CN 111881024A
Authority
CN
China
Prior art keywords
interface
test
data
test case
information
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
CN202010670377.3A
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.)
Glodon Co Ltd
Original Assignee
Glodon 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 Glodon Co Ltd filed Critical Glodon Co Ltd
Priority to CN202010670377.3A priority Critical patent/CN111881024A/en
Publication of CN111881024A publication Critical patent/CN111881024A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Landscapes

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

Abstract

The invention discloses a method, a device, equipment and a storage medium for determining an interface test script, wherein the method comprises the following steps: the interface test case data and the test data are obtained, and the interface test case data and the test data are written into an information template, wherein the information template comprises a plurality of areas, and the interface test case data and the test data corresponding to the interfaces configured in the areas are different; acquiring range configuration data of an interface test case; and determining the interface test case script according to the information template, the interface test case data, the test data and the range configuration data. By implementing the invention, zero programming is realized, the test script code which accords with the TestNG standard can be configured and automatically generated in batch, the CICD can be directly accessed, the test script is separated from the test case and the test data, the reusability is high, various different test scenes of the interface can be covered, and the interface test efficiency is improved.

Description

Method, device, equipment and storage medium for determining interface test script
Technical Field
The invention relates to the technical field of test development, in particular to a method, a device, equipment and a storage medium for determining an interface test script.
Background
The interface test is a test for testing interfaces among components of the system, and is mainly used for detecting interaction points between an external system and the system and between each internal subsystem. The key point of the test is to check the exchange of data, transfer and control management processes, mutual logic dependency relationship between systems and the like. In the implementation process of the interface test case, the test case and the test data are directly written in the test code, so that other interface tests cannot be multiplexed, and the limitation that various different test scenes cannot be covered exists.
Disclosure of Invention
Therefore, the technical problem to be solved by the present invention is to overcome the defects in the prior art that the interface test case script cannot be reused and the manual encoding task is heavy, thereby providing a method, an apparatus, a device and a storage medium for determining the interface test script.
According to a first aspect, an embodiment of the present invention provides a method for determining an interface test script, including: acquiring interface test case data and test data, and writing the interface test case data and the test data into an information template, wherein the information template comprises a plurality of areas, and the interface test case data and the test data corresponding to the interface configured in each area are different; acquiring range configuration data of the interface test case; and determining an interface test case script according to the information template, the interface test case data, the test data and the range configuration data.
With reference to the first aspect, in a first implementation manner of the first aspect, the determining an interface test case script according to the information template, the interface test case data, the test data, and the range configuration data includes: acquiring interface basic information, test information and interface parameter information corresponding to the interface; determining actual test data of the interface test case to the dependent variables according to the interface basic information, the test information and the interface parameter information; and calling a preset tool class to generate an interface test case script corresponding to the interface according to the actual test data and the range configuration data.
With reference to the first aspect, in a second implementation manner of the first aspect, the testing method further includes: setting an association identifier between the interface test cases; and when the interface test case data and/or the test data are/is changed, updating the interface test case data and/or the test data of the associated test case corresponding to the interface according to the associated identification.
With reference to the first embodiment of the first aspect, in a third embodiment of the first aspect, the testing method further includes: acquiring configuration information corresponding to the interface test case; and determining the grouping of the interface test cases, the packet path of the interface test cases and the class names of the interface test cases according to the configuration information.
With reference to the third implementation manner of the first aspect, in a fourth implementation manner of the first aspect, invoking a preset tool class to generate an interface test case script corresponding to the interface according to the actual test data includes: and calling a preset tool class to generate an interface test case script corresponding to the interface according to the actual test data, the grouping of the interface test cases, the packet path of the interface test cases and the class name of the interface test cases.
With reference to the fourth implementation manner of the first aspect, in a fifth implementation manner of the first aspect, if the generated interface test case script includes a script range, the method further includes: and configuring index numbers corresponding to the information template and each area of the information template in the configuration information.
With reference to the first implementation manner of the first aspect, in a sixth implementation manner of the first aspect, the interface basic information includes: any one or more of interface description, interface request method, interface request address and interface request path; the test information includes: any one or more of test case identification, incidence relation, data flow and database operation verification information; the interface parameter information includes: any one of a request path parameter, a request body parameter, and a request header parameter.
According to a second aspect, an embodiment of the present invention provides an apparatus for determining an interface test script, including: the first acquisition module is used for acquiring interface test case data and test data and writing the interface test case data and the test data into an information template; the second acquisition module is used for acquiring the range configuration data of the interface test case; and the determining module is used for determining the interface test case script according to the information template, the interface test case data, the test data and the range configuration data.
According to a third aspect, an embodiment of the present invention provides a computer apparatus, including: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing therein computer instructions, and the processor executing the computer instructions to perform the method for determining an interface test script according to the first aspect or any embodiment of the first aspect.
According to a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, where computer instructions are stored, and the computer instructions are configured to cause the computer to execute the method for determining an interface test script according to the first aspect or any implementation manner of the first aspect.
The technical scheme of the invention has the following advantages:
1. according to the interface test script determining method, the interface test script determining device and the computer equipment, the test cases and the test data are configured in the information template, so that the test scripts are separated from the test cases and the test data, and the reusability is high; the interface test case script is determined according to the information template, the interface test case data, the test data and the range configuration data of the interface test case, the test script codes which can be automatically generated in a range can be configured in a zero programming mode, and then the interface test is carried out on the system to be tested according to the generated interface test case script, so that the automatic test development of the interface is realized, the test development efficiency is improved, the information template can comprise a plurality of areas, the interface test case data and the test data which correspond to the configured interface in each area are different, various different test scenes covering the interface are realized, and the limitation that the automatic execution test of a single interface cannot cover various test scenes is overcome.
2. According to the method, the device and the computer equipment for determining the interface test script, the association identifier is arranged among the interface test cases, and when the interface test case data and/or the test data are changed, the interface test case data and/or the test data of the associated test case corresponding to the interface are updated according to the association identifier. The incidence relation and the data transmission between the interface test cases are embodied through simple marks, when the interface test case data and/or the test data with complex incidence relation are changed, the associated test case data and/or the associated test data can be automatically changed in a linkage mode, therefore, the coverage of incidence logic between the interfaces is achieved, the influence range generated by the change can be easily filtered and identified, the regression range is effectively reduced, and the maintenance cost is reduced.
3. According to the method, the device and the computer equipment for determining the interface test script, provided by the invention, if the generated interface test case script contains the script range, the corresponding information template file and the index numbers of all the areas are configured in the configuration information, and the test case range of the self-defined automatically generated codes can be realized by simply configuring the script range in the configuration information, so that the interface test implementation and the scene maintenance can be flexibly coped with.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained by those skilled in the art without creative efforts.
FIG. 1 is a flow chart illustrating a method for determining an interface test script according to an embodiment of the present invention;
FIG. 2 is another flowchart of a method for determining an interface test script according to an embodiment of the present invention;
FIG. 3 is a diagram illustrating interface basic information in an information template according to an embodiment of the present invention;
FIG. 4 is a diagram illustrating test information in an information template according to an embodiment of the present invention;
FIG. 5 is a diagram illustrating interface parameter information in an information template according to an embodiment of the present invention;
FIG. 6 is a diagram illustrating interface authentication information in an information template according to an embodiment of the present invention;
FIG. 7 is a block diagram of interface testing in an embodiment of the present invention;
FIG. 8 is a diagram illustrating an implementation scenario of interface testing of a test script according to an embodiment of the present invention;
FIG. 9 is a schematic block diagram of an apparatus for determining an interface test script according to an embodiment of the present invention;
fig. 10 is a schematic structural diagram of a computer device in an embodiment of the present invention.
Detailed Description
The technical solutions of the present invention will be described clearly and completely with reference to the accompanying drawings, and it should be understood that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings, and are only for convenience of description and simplicity of description, but do not indicate or imply that the device or element being referred to must have a particular orientation, be constructed and operated in a particular orientation, and thus, should not be construed as limiting the present invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance.
In the description of the present invention, it should be noted that, unless otherwise explicitly specified or limited, the terms "mounted," "connected," and "connected" are to be construed broadly, e.g., as meaning either a fixed connection, a removable connection, or an integral connection; can be mechanically or electrically connected; the two elements may be directly connected or indirectly connected through an intermediate medium, or may be communicated with each other inside the two elements, or may be wirelessly connected or wired connected. The specific meanings of the above terms in the present invention can be understood in specific cases to those skilled in the art.
In addition, the technical features involved in the different embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other.
Example 1
The embodiment provides a method for determining an interface test script, which can be applied to an interface automation test of a system, as shown in fig. 1, and includes the following steps:
and S11, acquiring interface test case data and test data, and writing the interface test case data and the test data into an information template, wherein the information template comprises a plurality of areas, and the interface test case data and the test data corresponding to the interfaces configured in the areas are different.
Illustratively, the interface test case and test data refer to a description of a test task performed on an interface to verify whether the interface meets a certain functional requirement of the system. The information template is used for providing interface test cases and configuration information thereof, and comprises the interface test cases and an interface test case configuration template. Interface association and data circulation can be configured in the interface test case configuration template. If one interface corresponds to a plurality of interface test cases, the information template can be divided into a plurality of areas based on different interface test case data and different test data, and the different interface test cases and the different test data corresponding to the interface are configured in different areas in the information template.
In the embodiment of the invention, the information template can be, for example, an Excel template file, the interface test case data is recorded by using a template defined by Excel macros, the interface test case Excel template file can take a function module as a unit, all interface test cases of one function module are recorded in one Excel template file, all interface test cases of the same interface service of the function module are recorded in the same sheet, when the function module is composed of a plurality of interface services, a plurality of sheets are recorded, the sheet names can be distinguished by the names of the interface services, and the naming mode can adopt a hump rule English naming mode. The information template can also adopt a database form, which is not limited in the application and can be determined by a person skilled in the art according to actual needs.
And S12, acquiring the range configuration data of the interface test case.
Illustratively, the scope configuration data is the corresponding location of the interface test case in the information template, e.g., line 3 in form 1. According to the interface test case data and the test data, the range configuration data of a plurality of interface test cases corresponding to each interface can be determined.
And S13, determining the interface test case script according to the information template, the interface test case data, the test data and the range configuration data.
Illustratively, according to the information template, the interface test case data and the test data configured in the information template and the range configuration data corresponding to the interface test case, a tool for automatically generating codes is called to automatically generate the interface test case script Java code. For example, the automatic generation of the Java code of the interface test case script is realized by using Java poet, and based on the interface test case data, the test data, and the range configuration data configured in the information template, the test case script and the organization structure of the script file are automatically generated. The present application is not limited to the Java language, and is not limited to a tool for automatically generating code.
Taking an example of automatically generating interface test case scripts Java codes, a test case base class and a toolkit are background supports for automatically generating scripts, basic test case functions are all realized in the background, and when the test scripts are automatically generated, components and methods in the background are called to construct each test case script corresponding to the interface according to analysis of test case data configured in an information template by using JavaPoet grammar.
Basic tool packages required by interface testing are provided in the utils toolkit, for example, excel basic operation packages, http request related operation packages, packages of various configuration file analysis functions, packages of various object type tools, test report interception function packages, and the like.
The BaseTestCases class is used as the base class of the test case, the interface request executor, the interface return result verification and the related implementation encapsulation are realized, the base class is inherited by the test case generator, and the test case code is generated automatically, conveniently, efficiently and easily maintained.
The BaseAssert is used as a base class of the assertion method, various types of assertion methods are realized, the class is inherited by BaseTestCases, and different methods in the BaseAssert are called according to different types of verification conditions and results in the analysis test case template when the verification of the interface return value is realized.
The testcasegenerrator is a core tool class for automatically generating test scripts, and mainly realizes the analysis of an interface test case template, and then generates Java test case codes conforming to the TestNG framework specification by using JavaPoet grammar based on the realized functions and tools in the BaseTestcases and utils tool packages.
The automatically generated test script code has testNG frame key attribute annotation, accords with java coding specification, has clear structure and good readability, and the test case script can be directly operated without manual debugging. After the generated test case scripts are combined into test suites with any granularity such as package, test, group, class, method and the like, tool chains such as integrated Git, Jenkins and the like can directly enter a continuous integrated deployment/continuous deployment (CICD) pipeline. And running the generated interface test case script codes, carrying out interface test on each interface function of the system to be tested, detecting whether each developed interface meets each specific function requirement of the system, and if a certain interface does not meet the specific function requirement of the system, informing technicians to modify and adjust the interface.
According to the method for determining the interface test script, the test case and the test data are configured in the information template, so that the test script is separated from the test case and the test data, and the reusability is high; the interface test case script is determined according to the information template, the interface test case data, the test data and the range configuration data of the interface test case, the test script codes which can be automatically generated in a range can be configured in a zero programming mode, and then the interface test is carried out on the system to be tested according to the generated interface test case script, so that the automatic test development of the interface is realized, the test development efficiency is improved, the information template can comprise a plurality of areas, the interface test case data and the test data which correspond to the configured interface in each area are different, various different test scenes covering the interface are realized, and the limitation that the automatic execution test of a single interface cannot cover various test scenes is overcome.
As an alternative implementation, as shown in fig. 2, the step S13 includes:
s131, acquiring interface basic information, test information and interface parameter information corresponding to the interface.
Illustratively, the interface basic information is information such as interface description and interface request corresponding to the interface; the test information is the relevant information of the interface test case; the interface parameter information is interface request information. In order to accurately generate the test case corresponding to the interface, the interface basic information, the test information, and the interface parameter information corresponding to the interface need to be acquired.
And S132, determining the actual test data of the interface test case to the dependent variable according to the interface basic information, the test information and the interface parameter information.
Illustratively, the actual test data is a specific assignment of an interface parameter in an interface test case corresponding to the interface. For example, a data flow value of the test information is set. And determining the parameter assignment of the interface test case to the dependent variable according to the acquired interface basic information, test information and interface parameter information corresponding to the interface, namely generating actual test data required by the interface test case.
And S133, calling a preset tool class to generate an interface test case script corresponding to the interface according to the actual test data and the range configuration data.
Illustratively, the preset tool class is a test case base class and an automatic code generation tool, the automatic code generation tool and the test case base class are called, and the interface test case script code corresponding to the interface is automatically generated according to actual test data and range configuration data determined by interface basic information, test information and interface parameter information corresponding to the interface.
As an optional implementation manner, the interface basic information in step S132 includes: any one or more of an interface description, an interface request method, an interface request address, and an interface request path. As shown in fig. 3, the interface description is a brief description identifier of the function and test case of the interface, and a brief description of a positive example and a brief description of a negative example are performed to enhance the readability of the log and the test report; the interface request method is the request method type of the interface, including GET method and POST method; the interface request address is the request address of the interface; the interface request path is a request path of a connection of an interface request address.
The test information comprises any one or more of test case identification, incidence relation, data circulation and database operation verification information. As shown in fig. 4, the template column name GroupID is an interface test case grouping information identifier, which is used to combine the running test cases and also to configure interface dependency information. The template column name testcase id is the unique identifier of the test case, the unique identifier of the test case can be automatically generated through a macro function defined by an information template (for example: CONCATENATE (INDEX (sheetName, doc), "_ TC _", ROW () -2)), and the unique identifier is formed by automatically combining the name of an information template form and the line number of the line where the test case is located, wherein the line number of the line where the test case is located has the meaning of execution order, and when the information template multiplexes and modifies the test case, or adds and deletes the test case in the information template, the testcase id in the template can realize self-adaptation. The template column name DependsOnType is an identifier of a dependency relationship between interfaces and is composed of two dependency types of TestNg, and drop-down box options of deppendsOnmethods and deppendsOngroups are defined in the template. The template column name DependsOnObject is an object of an interface dependency relationship, namely the TestCaseID of a depended test case is filled in a relative reference cell mode, so that when the position of the depended test case is changed (the TestCaseID changes the execution sequence), the reference value in the column can realize linkage. The template column name DataTransfer is an identifier of data transfer between interfaces, is used for identifying a test case for generating the data transfer, and fills in the TestCaseID of the corresponding data provider in a relative reference mode. The template column name DataTransferParameter is the parameter field identification for data flow between interfaces. And the template column name DBVerifyWith is a database operation verification identifier of the interface, and a test case ID for realizing the database operation verification is filled in a relative reference mode. And the template column name DBVerifyExpected is a verification content identifier for database operation verification of the interface, and JSON format is used for describing verification content and verification conditions.
The interface parameter information includes any one of a request path parameter, a request body parameter, and a request header parameter. As shown in fig. 5, the template column name PathParameter is set for the path parameter value requested by the interface. The template column name QueryParameter is set for the URL parameter value of the interface request. The template column name BodyParameter is set for the interface request body parameter value. The template column name HeaderParameter is set for the parameter value of the interface request header. The setting of the interface parameters supports the following two types:
(1) the JSON format describes: the method is suitable for setting parameter values in test case design as fixed values;
(2) relative citation: the method is suitable for data flow scenes in test cases, for example: the parameter id of the Get request test case is to use the id value, XXX _ TC _1.id, in the POST request return value.
Optionally, the information template may further include interface verification information, and the content and the condition of interface verification are described according to a rule set in the interface verification information, so that the test case script code can be automatically analyzed, and the assertion can be automatically completed. As shown in fig. 6, the template column name ExpectedResult is the verification identifier of the interface, and the setting rule is described as follows:
describing verification content and verification conditions by using a JSON format; when the verification field is a number, the decision condition is expressed by a mathematical logical operator, e.g.,! (ii) <, >; when the verification field is a string, refer to the following example:
(1) fuzzy matching, including;
(2) | A Fuzzy matching, not containing;
(3) not null, where the string is not empty, corresponding (| = null & & | = ");
(4) no matching symbol, and accurate matching.
An example of calling an automatic code generation tool and a test case base class to generate a test case script Java code according to the information template and the test case data and the test data set in the information template is as follows:
Figure BDA0002582064070000131
Figure BDA0002582064070000141
in the above-described automatically generated Java code file structure, the Package name of the test case script is automatically represented by the name of the function module to which it belongs, and the Java class name of the test case script corresponds to the name of the form to which it belongs. In the automatically generated Java class, the method not only comprises all test cases of the interface, but also comprises detailed comments and a testNG annotation and a testNG method which are automatically generated according to template information, thereby realizing the readability and normalization of equivalent manual code writing. Therefore, the method for determining the interface test script provided by the embodiment can realize complex case codes such as the execution sequence, the association relation, the data flow, the database operation verification and the like of the interface test case only by simply identifying in the template.
As an optional implementation, the method for determining the interface test script further includes:
firstly, setting an association identifier between interface test cases.
For example, if there is a dependency relationship between different interfaces and interface test cases corresponding to different interfaces, interface association identifiers may be set in the information template for the interfaces and the interface test cases corresponding to the interfaces thereof, and an interface dependency relationship object, that is, an interface test case on which an interface depends, may be determined according to the association identifiers.
Secondly, when the interface test case data and/or the test data are changed, the interface test case data and/or the test data of the associated test case corresponding to the interface are updated according to the associated identification.
Illustratively, the interface test case data on which the interface depends may be filled in a relative reference manner, so that when the interface test case data and/or the test data change, that is, the execution order of the unique identifier testcase id of the interface test case changes, at this time, the reference value in the column corresponding to the interface test case can realize linkage change, and thus, the interface test case data and/or the test data of the associated test case corresponding to the interface is updated.
In the method for determining the interface test script provided by this embodiment, by setting the association identifier between the interface test cases, when the interface test case data and/or the test data are changed, the interface test case data and/or the test data of the associated test case corresponding to the interface are updated according to the association identifier. When the test case data and/or the test data of the interface with complex incidence relation are changed, the associated test case data and/or the associated test data can be automatically changed in a linkage manner, so that the coverage of the incidence logic between the interfaces is realized, the influence range generated by the change can be easily filtered and identified, the regression range is effectively reduced, and the maintenance cost is reduced.
As an optional implementation manner, before automatically generating an interface test case script, the test method according to the embodiment of the present invention further includes:
firstly, configuration information corresponding to an interface test case is obtained.
For example, the configuration information corresponding to the interface test case may adopt a YAML file, a JSON file, or an XML file, which is not limited in this application. Taking YAML file as an example, the YAML configuration file of the interface test case may provide configuration information of the interface test case, where the configuration information of the interface test case includes: interface service component configuration information, such as Token information acquisition components; interface function module service list configuration information; and automatically generating the range configuration information of the interface test case.
Secondly, determining the grouping of the interface test cases, the packet path of the interface test cases and the class names of the interface test cases according to the configuration information.
Illustratively, based on that the interface test tasks are grouped according to the interface function modules, the function groups corresponding to the interface test cases can be determined according to the configuration information in the configuration file. When the interface test case scripts of a plurality of functional modules are automatically generated in batches, the interface test case information template files of the functional modules can be listed in the interface test configuration file. And obtaining a packet path of the interface test case and a class name of the interface test case according to the configuration information, namely analyzing the configuration information in the configuration file to obtain a test case package name corresponding to the name (name field) of the interface test case and a class name corresponding to the interface test case.
As an optional implementation, according to the actual test data, invoking a preset tool class to generate an interface test case script corresponding to the interface, including: and calling a preset tool class to generate an interface test case script corresponding to the interface according to the actual test data, the grouping of the interface test cases, the packet path of the interface test cases and the class name of the interface test cases.
Illustratively, according to the obtained actual test data, the grouping of the interface test cases, the packet path of the interface test cases, and the class names of the interface test cases, a preset tool class is called to generate an interface test case script corresponding to the interface. For the detailed contents of the interface test case script corresponding to the preset tool class generation interface, reference is made to the relevant description corresponding to the above embodiment, which is not described herein again.
As an optional implementation manner, if the generated interface test case script contains a script range, the method further includes: the configuration information is provided with index numbers corresponding to the information templates and the areas of the information templates.
Illustratively, the configuration information may be divided into two levels, one level being an apiservices level and the second level being a sheeetindex level. When a test case range for automatically generating a test script needs to be specified, an information template required to be included may be configured in a configuration file corresponding to an interface, and an index number of an area required to be included may be specified, as an example below:
Figure BDA0002582064070000171
Figure BDA0002582064070000181
in the method for determining the interface test script provided in this embodiment, if the generated interface test case script includes a script range, the corresponding information template is configured in the configuration information, the index number of each region in the template may be specified, and by simply configuring the script range in the configuration information, the test case range in which the code is automatically generated by user-definition may be implemented, and the interface test implementation and the scene maintenance may be flexibly handled.
FIG. 7 is a framework diagram of interface testing, wherein templates are used to provide test cases and their configuration information, including interface case templates and their configuration information templates; the main components describe the technology component members, including the open source tool class framework, the plug-in tools, and the self-implementation components: the test system comprises a general object tool class (String \ Json \ Yaml \ Http), a configuration file tool class (excelUtils \ FileUtils), a test case base class (BaseTestCases \ BaseAssert), a test script class generator tool (TestCaseGenerator), a related tool class (TestListener \ TestReporter) for generating a test report corresponding to a test case and the like. Meanwhile, the scheduling module in the framework describes that the framework integrates tool chains and supports the scheduling execution of the interface test cases in the CICD pipeline.
Fig. 8 is a diagram illustrating an implementation scenario of an interface test of a test script, and the following effects can be obtained by implementing the interface test method:
(1) the test development efficiency is improved: taking 30 interface test cases as an example, a skilled test developer needs more than 60 minutes for manually compiling test case codes, and when the interface is used for testing, interface test data and test case data can be recorded into an Excel macro definition template in only 5-6 minutes, and a relevant tool class is called to generate the test case codes by one key, so that the communication cost between the tester and the developer is reduced. The automatically generated test script can be directly submitted to a git library, and then the test script can enter a CICD assembly line by means of a Jenkins tool, so that the labor input in the test development process is reduced, and the test development productivity is improved.
(2) The test maintenance efficiency is improved: when the interface test case data or the interface test data are changed, the test codes do not need to be updated manually, after the interface test case data or the interface test data are updated in the information template library of the test cases, the relevant interface test cases in the information template are automatically updated, the test case scripts are regenerated, and the test case script codes are automatically updated. The correlation between the test cases in the information template has clear identification, and the changed interface test case data or interface test data can be positioned by utilizing the correlation identification, so that the influence range of the changed interface test case is positioned, the accurate test is realized, and the maintenance cost of the interface test is reduced.
Example 2
In this embodiment, an interface test script determining apparatus is provided, which is applicable to an interface automation test of a system, and as shown in fig. 9, the interface test apparatus of the test script includes:
the first obtaining module 21 is configured to obtain the interface test case data and the test data, and write the interface test case data and the test data into the information template. For details, refer to the related description of step S11 corresponding to the above method embodiment, and are not repeated herein.
The second obtaining module 22 is configured to obtain range configuration data of the interface test case. For details, refer to the related description of step S12 corresponding to the above method embodiment, and are not repeated herein.
And the determining module 23 is configured to generate an interface test case script according to the information template, the test case data, and the test data. For details, refer to the related description of step S13 corresponding to the above method embodiment, and are not repeated herein.
According to the interface test script determining device provided by the embodiment, the test case and the test data are configured in the information template, so that the test script is separated from the test case and the test data, and the reusability is high; the interface test case script is determined according to the information template, the test case data and the test data, the test script codes which are automatically generated in a zero programming mode are realized, and then the interface test is performed on the system to be tested according to the generated interface test case script, the automatic interface test development is realized, the test development efficiency is improved, a plurality of areas can be included in the information template, the interface test case data and the test data which correspond to the interfaces configured in the areas are different, therefore, various different test scenes covering the interfaces are realized, and the limitation that the automatic execution test of a single interface cannot cover various test scenes is overcome.
As an optional implementation, the generating module 23 includes:
and the first acquisition submodule is used for acquiring the interface basic information, the test information and the interface parameter information corresponding to the interface. The interface basic information includes: any one or more of interface description, interface request method, interface request address and interface request path; the test information includes: any one or more of test case identification, incidence relation, data flow and database operation verification information; the interface parameter information includes: any one of a request path parameter, a request body parameter, and a request header parameter. For details, refer to the related description of step S131 corresponding to the above method embodiment, and are not repeated herein.
And the first determining submodule is used for determining the actual test data of the test case to the dependent variable according to the interface basic information, the test information and the interface parameter information. For details, refer to the related description of step S132 corresponding to the above method embodiment, and are not repeated herein.
And the generating submodule is used for calling a preset tool class to generate an interface test case script corresponding to the interface according to the actual test data and the range configuration data. For details, refer to the related description of step S133 corresponding to the above method embodiment, and are not repeated herein.
As an optional implementation manner, the interface testing apparatus of the test script further includes:
and the setting module is used for setting the association identification between the interface test cases. For details, refer to the corresponding related description of the above method embodiments, and are not repeated herein.
And the updating module is used for updating the interface test case data and/or the test data of the associated test case corresponding to the interface according to the associated identification when the interface test case data and/or the test data are changed. For details, refer to the corresponding related description of the above method embodiments, and are not repeated herein.
In the determining apparatus for the interface test script provided in this embodiment, by setting the association identifier between the interface test cases, when the interface test case data and/or the test data are changed, the interface test case data and/or the test data of the associated test case corresponding to the interface are updated according to the association identifier. The incidence relation and the data transmission between the interface test cases are embodied through simple marks, when the interface test case data and/or the test data with complex incidence relation are changed, the associated test case data and/or the associated test data can be automatically changed in a linkage mode, therefore, the coverage of incidence logic between the interfaces is achieved, the influence range generated by the change can be easily filtered and identified, the regression range is effectively reduced, and the maintenance cost is reduced.
As an optional implementation manner, the interface testing apparatus of the test script further includes:
and the configuration information acquisition module is used for acquiring the configuration information corresponding to the interface test case. For details, refer to the corresponding related description of the above method embodiments, and are not repeated herein.
And the determining module is used for determining the grouping of the interface test cases, the packet path of the interface test cases and the class names of the interface test cases according to the configuration information. For details, refer to the corresponding related description of the above method embodiments, and are not repeated herein.
As an optional implementation, the generating sub-module includes:
and the calling subunit is used for calling a preset tool class to generate an interface test case script corresponding to the interface according to the actual test data, the grouping of the interface test cases, the packet path of the interface test cases and the class name of the interface test cases. For details, refer to the corresponding related description of the above method embodiments, and are not repeated herein.
As an optional implementation manner, if the generated interface test case script contains a script range, the interface testing apparatus of the test script further includes:
and the configuration module is used for configuring the corresponding information template and the index number of each area of the information template in the configuration information. For details, refer to the corresponding related description of the above method embodiments, and are not repeated herein.
In the interface test script determining apparatus provided in this embodiment, if the generated interface test case script includes the script range, the index numbers of the regions corresponding to the information templates are configured in the configuration information, and by simply configuring the script range in the configuration information, the test case range in which the code is automatically generated by user-definition can be implemented, and the interface test implementation and the scene maintenance can be flexibly handled.
Example 3
An embodiment of the present invention further provides a computer device, as shown in fig. 10, the computer device includes a processor 31 and a memory 32, where the processor 31 and the memory 32 may be connected by a bus or in another manner, and fig. 10 takes the connection by the bus as an example.
The processor 31 may be a Central Processing Unit (CPU). The Processor 31 may also be other general-purpose processors, Digital Signal Processors (DSPs), Graphics Processing Units (GPUs), embedded Neural Network Processors (NPUs), or other dedicated deep learning coprocessors, Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs), or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, or any combination thereof.
The memory 32 is a non-transitory computer readable storage medium, and can be used to store non-transitory software programs, non-transitory computer executable programs, and modules, such as program instructions/modules (e.g., the first obtaining module 21, the second obtaining module 22, and the determining module 23 shown in fig. 9) corresponding to the interface test script determination method in the embodiment of the present invention. The processor 31 executes various functional applications and data processing of the processor by running non-transitory software programs, instructions and modules stored in the memory 32, that is, implements the determination method of the interface test script in the above method embodiment.
The memory 32 may include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function; the storage data area may store data created by the processor 31, and the like. Further, the memory 32 may include high speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, the memory 32 may optionally include memory located remotely from the processor 31, and these remote memories may be connected to the processor 31 via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The one or more modules are stored in the memory 32 and, when executed by the processor 31, perform the method of determining an interface test script as in the embodiment of fig. 1-8.
The test case and the test data are configured in the information template, so that the separation of the test script from the test case and the test data is realized, and the reusability is high; the interface test case script is generated according to the information template, the test case data, the test data and the range configuration data of the interface test case, the test script codes which can be automatically generated in a range can be configured in a zero programming mode, and then the interface test is carried out on the system to be tested according to the generated interface test case script, the automatic test development of the interface is realized, the test development efficiency is improved, the information template can comprise a plurality of areas, the interface test case data and the test data which correspond to the configured interface in each area are different, therefore, various different test scenes covering the interface are realized, and the limitation that the automatic execution test of a single interface can not cover various test scenes is overcome.
The details of the computer device can be understood by referring to the corresponding descriptions and effects in the embodiments shown in fig. 1 to 9, which are not described herein again.
The embodiment of the invention also provides a non-transitory computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions can execute the method for determining the interface test script in any method embodiment. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a Flash Memory (Flash Memory), a hard disk (hard disk Drive, abbreviated as HDD), a Solid State Drive (SSD), or the like; the storage medium may also comprise a combination of memories of the kind described above.
It should be understood that the above examples are only for clarity of illustration and are not intended to limit the embodiments. Other variations and modifications will be apparent to persons skilled in the art in light of the above description. And are neither required nor exhaustive of all embodiments. And obvious variations or modifications therefrom are within the scope of the invention.

Claims (10)

1. A method for determining an interface test script, comprising:
acquiring interface test case data and test data, and writing the interface test case data and the test data into an information template, wherein the information template comprises a plurality of areas, and the interface test case data and the test data corresponding to the interface configured in each area are different;
acquiring range configuration data of an interface test case;
and determining an interface test case script according to the information template, the interface test case data, the test data and the range configuration data.
2. The method of claim 1, wherein determining an interface test case script based on the information template, the interface test case data and the test data, and the scope configuration data comprises:
acquiring interface basic information, test information and interface parameter information corresponding to the interface;
determining actual test data of the interface test case to the dependent variables according to the interface basic information, the test information and the interface parameter information;
and calling a preset tool class to generate an interface test case script corresponding to the interface according to the actual test data and the range configuration data.
3. The method of claim 1, further comprising:
setting an association identifier between the interface test cases;
and when the interface test case data and/or the test data are/is changed, updating the interface test case data and/or the test data of the associated test case corresponding to the interface according to the associated identification.
4. The method of claim 2, further comprising:
acquiring configuration information corresponding to the interface test case;
and determining the grouping of the interface test cases, the packet path of the interface test cases and the class names of the interface test cases according to the configuration information.
5. The method according to claim 4, wherein the step of calling a preset tool class to generate an interface test case script corresponding to the interface according to the actual test data comprises:
and calling a preset tool class to generate an interface test case script corresponding to the interface according to the actual test data, the grouping of the interface test cases, the packet path of the interface test cases and the class name of the interface test cases.
6. The method of claim 4, wherein if the generated interface test case script contains a script scope, the method further comprises:
and configuring index numbers corresponding to the information template and each area of the information template in the configuration information.
7. The method of claim 2,
the interface basic information includes: any one or more of interface description, interface request method, interface request address and interface request path;
the test information includes: any one or more of test case identification, incidence relation, data flow and database operation verification information;
the interface parameter information includes: any one of a request path parameter, a request body parameter, and a request header parameter.
8. An apparatus for determining an interface test script, comprising:
the first acquisition module is used for acquiring interface test case data and test data and writing the interface test case data and the test data into an information template;
the second acquisition module is used for acquiring the range configuration data of the interface test case;
and the determining module is used for determining the interface test case script according to the information template, the interface test case data, the test data and the range configuration data.
9. A computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory having stored therein computer instructions, the processor executing the computer instructions to perform the method of determining an interface test script according to any one of claims 1 to 7.
10. A computer-readable storage medium storing computer instructions for causing a computer to execute the method for determining an interface test script according to any one of claims 1 to 7.
CN202010670377.3A 2020-07-13 2020-07-13 Method, device, equipment and storage medium for determining interface test script Pending CN111881024A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010670377.3A CN111881024A (en) 2020-07-13 2020-07-13 Method, device, equipment and storage medium for determining interface test script

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010670377.3A CN111881024A (en) 2020-07-13 2020-07-13 Method, device, equipment and storage medium for determining interface test script

Publications (1)

Publication Number Publication Date
CN111881024A true CN111881024A (en) 2020-11-03

Family

ID=73150778

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010670377.3A Pending CN111881024A (en) 2020-07-13 2020-07-13 Method, device, equipment and storage medium for determining interface test script

Country Status (1)

Country Link
CN (1) CN111881024A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112346991A (en) * 2020-11-27 2021-02-09 新华三大数据技术有限公司 Interface test script generation method and device
CN113535567A (en) * 2021-07-21 2021-10-22 工银科技有限公司 Software testing method, device, equipment and medium
CN113742222A (en) * 2021-08-20 2021-12-03 许继集团有限公司 Automatic generation method and test method for server communication test case
CN114048130A (en) * 2021-11-11 2022-02-15 上海复深蓝软件股份有限公司 Unit testing method, unit testing device, computer equipment and storage medium
CN116561014A (en) * 2023-07-07 2023-08-08 国电南瑞科技股份有限公司 Device and method for generating test case of electric power secondary equipment

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112346991A (en) * 2020-11-27 2021-02-09 新华三大数据技术有限公司 Interface test script generation method and device
CN112346991B (en) * 2020-11-27 2022-03-22 新华三大数据技术有限公司 Interface test script generation method and device
CN113535567A (en) * 2021-07-21 2021-10-22 工银科技有限公司 Software testing method, device, equipment and medium
CN113742222A (en) * 2021-08-20 2021-12-03 许继集团有限公司 Automatic generation method and test method for server communication test case
CN113742222B (en) * 2021-08-20 2024-04-09 河南源网荷储电气研究院有限公司 Automatic generation method and test method for server communication test cases
CN114048130A (en) * 2021-11-11 2022-02-15 上海复深蓝软件股份有限公司 Unit testing method, unit testing device, computer equipment and storage medium
CN116561014A (en) * 2023-07-07 2023-08-08 国电南瑞科技股份有限公司 Device and method for generating test case of electric power secondary equipment
CN116561014B (en) * 2023-07-07 2023-09-29 国电南瑞科技股份有限公司 Device and method for generating test case of electric power secondary equipment

Similar Documents

Publication Publication Date Title
CN111881024A (en) Method, device, equipment and storage medium for determining interface test script
CN108415832B (en) Interface automation test method, device, equipment and storage medium
US10135936B1 (en) Systems and methods for web analytics testing and web development
US8745641B1 (en) Automatic verification and anomaly detection in a representational state transfer (REST) application programming interface
CN109614324B (en) Test case generation method and device
CN108628748B (en) Automatic test management method and automatic test management system
EP3032425A1 (en) Integrated automated test case generation for safety-critical software
CN112241360A (en) Test case generation method, device, equipment and storage medium
CN111124871A (en) Interface test method and device
CN112380255A (en) Service processing method, device, equipment and storage medium
CN114398293A (en) Interface test case generation method, electronic device and storage medium
CN111459509A (en) Container mirror image construction method and device and server
CN112395184A (en) Information acquisition method, equipment and computer storage medium
CN110990289B (en) Method and device for automatically submitting bug, electronic equipment and storage medium
CN111324540A (en) Interface testing method and device
CN117370203B (en) Automatic test method, system, electronic equipment and storage medium
CN113434405A (en) Method and device for determining test file, storage medium and electronic device
KR102418796B1 (en) FMEA failure mode recommend system
CN117493188A (en) Interface testing method and device, electronic equipment and storage medium
CN117113080A (en) Data processing and code processing method, device, all-in-one machine and storage medium
CN116431522A (en) Automatic test method and system for low-code object storage gateway
CN110968518A (en) Analysis method and device for automatic test log file
CN115934559A (en) Testing method of intelligent form testing system
CN115934772A (en) Process data calibration method and device based on rules
CN116383025A (en) Performance test method, device, equipment and medium based on Jmeter

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