CN112395184A - Information acquisition method, equipment and computer storage medium - Google Patents

Information acquisition method, equipment and computer storage medium Download PDF

Info

Publication number
CN112395184A
CN112395184A CN201910765704.0A CN201910765704A CN112395184A CN 112395184 A CN112395184 A CN 112395184A CN 201910765704 A CN201910765704 A CN 201910765704A CN 112395184 A CN112395184 A CN 112395184A
Authority
CN
China
Prior art keywords
data
tested
interface
test
application
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
CN201910765704.0A
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.)
China Mobile Communications Group Co Ltd
China Mobile Suzhou Software Technology Co Ltd
Original Assignee
China Mobile Communications Group Co Ltd
China Mobile Suzhou Software Technology 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 China Mobile Communications Group Co Ltd, China Mobile Suzhou Software Technology Co Ltd filed Critical China Mobile Communications Group Co Ltd
Priority to CN201910765704.0A priority Critical patent/CN112395184A/en
Publication of CN112395184A publication Critical patent/CN112395184A/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

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 an information acquisition method, which comprises the following steps: generating first data of an interface to be tested based on first identification information corresponding to the interface to be tested; acquiring test case data of the application to be tested based on the first data; and generating a test script of the application to be tested based on the test case data of the application to be tested. The invention also discloses an information acquisition device and a computer storage medium. The invention solves the problem of the relative technology that the interface test coverage is not wide in the interface test method.

Description

Information acquisition method, equipment and computer storage medium
Technical Field
The present invention relates to the field of software testing, and in particular, to an information acquisition method, device, and computer storage medium.
Background
In the field of software testing, interface testing is a test directed to testing interfaces between components of a system. In the actual interface testing process, testers need to develop an efficient test case execution process with the assistance of the test script. In the relative technology, a test script is generally generated by adopting a manual input mode or a webpage making mode. However, both of the above two interface test methods can only perform interface test on an interface corresponding to an operation that can be directly performed by a front-end page.
Disclosure of Invention
In view of this, the present invention mainly provides an information acquisition method, an information acquisition device, and a computer storage medium, which solve the problem of a relatively narrow coverage area of a test interface in an interface test method in the related art.
The technical scheme of the invention is realized as follows:
an information acquisition method, the method comprising:
generating first data of an interface to be tested based on first identification information corresponding to the interface to be tested; the first identification information represents description information corresponding to the interface information of the interface to be tested; the first data comprises data related to interface information of the interface to be tested; the interface to be tested is any interface in the application to be tested;
acquiring test case data of the application to be tested based on the first data;
and generating a test script of the application to be tested based on the test case data of the application to be tested.
Optionally, the obtaining test case data of the application to be tested based on the first data includes:
carrying out format conversion on the first data to obtain second data;
and acquiring the test case data based on the second data.
Optionally, the obtaining the test case data based on the second data includes:
acquiring test data corresponding to the interface to be tested;
and acquiring the test case data based on the second data and the test data.
Optionally, the obtaining the test case data based on the second data and the test data includes:
acquiring test data attribute information based on the second data;
and acquiring the test case data based on the test data, the test data attribute information and the second data.
Optionally, generating a test script of the application to be tested based on the test case data of the application to be tested includes:
loading the test case data to obtain a preliminary configuration test script based on the initialization test script;
and determining a request mode aiming at the application to be tested to generate the test script of the application to be tested based on the preliminary configuration test script.
Optionally, the generating first data of the interface to be tested based on the first identification information corresponding to the interface to be tested includes:
monitoring the application code of the application to be tested; wherein the application code is used for realizing the functions of the application to be tested;
if it is monitored that the application code of the to-be-tested application is successfully compiled, first data of the to-be-tested interface are generated based on first identification information corresponding to the to-be-tested interface.
Optionally, after generating the test script of the application to be tested based on the test script, the test case data, and the request manner, the method further includes:
acquiring a response state of the interface to be tested based on the test script;
determining a test result of the application to be tested based on the response state of the interface to be tested;
and generating a test report based on the test result.
The method for acquiring the test data comprises the following steps: the test data is manually filled in, automatically randomly generated or obtained by a database.
An information acquisition apparatus, the apparatus comprising: a processor, a memory, and a communication bus;
the communication bus is used for realizing communication connection between the processor and the memory;
the processor is used for executing the program of the data reading method in the memory to realize the following steps:
generating first data of an interface to be tested based on first identification information corresponding to the interface to be tested; the first identification information is used for converting the interface to be tested into the first data; the first data comprises data related to interface information of the interface to be tested; the interface to be tested is any interface in the application to be tested;
acquiring test case data of the application to be tested based on the first data;
and generating a test script of the application to be tested based on the test case data of the application to be tested.
The processor is used for executing the information acquisition program in the memory to realize the following steps:
carrying out format conversion on the first data to obtain second data;
and acquiring the test case data based on the second data.
A computer storage medium storing one or more programs executable by one or more processors to implement the above-described testing method.
According to the information acquisition method, the information acquisition equipment and the computer storage medium, the first data of the interface to be tested can be generated based on the first mark information corresponding to the interface to be tested, the test case data of the application to be tested can be acquired based on the first data, the test script of the application to be tested can be generated based on the test case data of the application to be tested, therefore, the data related to any interface to be tested can be automatically acquired, the corresponding test case data can be acquired according to any interface, the test script is generated by combining the test case data, and finally, the interface test is carried out on any interface based on the test script, so that the problem that the coverage of the test interface in the interface test method in the relative technology is not wide is solved.
Drawings
FIG. 1 is a schematic flow chart of a design scheme of an information acquisition method according to the present invention;
fig. 2 is a schematic flowchart of an information obtaining method according to an embodiment of the present invention;
fig. 3 is a schematic flowchart of an information obtaining method according to another embodiment of the present invention;
FIG. 4 is a schematic diagram of Object Notation data (JavaScript Object Notation, json) acquired based on the swagger annotation method;
fig. 5 is a schematic flowchart of an information obtaining method according to another embodiment of the present invention;
FIG. 6 is a schematic diagram of data loading based on Jmeter test cases according to the present invention;
FIG. 7 is a diagram illustrating a Jmeter interface based calling configuration according to the present invention;
fig. 8 is a schematic structural diagram of an information acquisition device according to an embodiment of the present invention.
Detailed Description
The technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.
The interface test is mainly used for detecting interaction points between systems and between subsystems, and the key points are to check the exchange, transmission and control management processes of data, the mutual logic dependency relationship between systems and the like. In the Interface testing process, the test technology, Application Programming Interface (API) reference document, test case, test data and test script all have important influence on the generation of the test report. The general interface test mainly includes two types of simple interface test tasks and test aiming at the service flow.
The following describes and introduces the interface test framework, the interface test tool and its type, and the interface test script type and its generation method involved in the existing interface test.
The test framework mainly used by the developer in the interface unit test (Java unit test is taken as an example) in the code is JUnit and TestNg, wherein:
JUnit is a Java language unit testing framework, and most Java development environments have integrated JUnit as a unit testing tool;
TestNg: TestNg is also a test frame, and its inspiration comes from JUnit and NUnit, but has introduced some new functions simultaneously, makes its function stronger, and it is more convenient to use. TestNg relates to testing covering all types: unit testing, functional testing, end-to-end testing, integration testing, and the like.
In actual testing work, a tester performs interface testing on a released code, and mainly relates to the types of testing tools including: a packet grabbing tool, an interface calling tool, a pressure testing tool and a Code-base tool. The following description is directed to the above-described types of tools, respectively.
A bag grabbing tool: taking Fiddler as an example, Fiddler as a HyperText Transfer Protocol (HTTP) agent can catch a browser to send out an HTTP request and return a result, and a user can quickly execute interface test by modifying the request and resending the request;
an interface calling tool: taking Postman as an example, Postman is a chrome plug-in used for webpage debugging and sending a webpage HTTP request, and can conveniently simulate a GET or POST or other requests to debug an interface;
pressure test type tool: taking LoadRunner as an example, HTTP requests and returned results sent by concurrent clients can be monitored and collected through an intermediate proxy, and scripts are generated;
code-base class tool: the Code-base tool realizes automatic testing based on codes, for example, an automatic testing frame is built, and then calling of an interface is realized in a Java + httpparent mode, so that the purpose of test case verification is achieved.
In the process of actually executing the automation interface test, a tester needs to develop an efficient test case execution process with the assistance of a test script. In the current software testing process, the test script generation scheme usually adopted by testers during interface testing mainly includes: manual input and webpage recording, wherein:
manual input: the method is suitable for interface calling tools and Code-base class tools. The tester records the script manually according to the test case based on the API document provided by the developer;
webpage recording: the pressure testing device is suitable for pressure testing tools such as a bale plucker. By starting the proxy server, a tester operates on a website and calls interface data of the background server side by intercepting and recording the client side, so that related script data is obtained.
However, for developers, due to aspects such as project time node tension, they are most likely not to do unit test work or to design unit test cases at will to pass the coverage standard. The art of software testing states that it is really a bad practice for any author to know that editing or collating his work in person is really done. The author knows what a certain piece of text is to say, and the actually expressed meaning is that the south thill rut is, but the author may not be aware of it. The same problem exists for programmers. Of course, this is not to say that the programmer does not need to do the unit test, but that the performance of the unit test session by the tester is better under the same time cost condition.
Meanwhile, the intercepting interface such as Fiddler carries out an interface test method, so that the current response result can be checked, the parameters can be modified, and then the request can be sent again.
Based on the above, the invention provides an information acquisition method, which generates first data of an interface to be tested based on first flag information corresponding to any interface in the application to be tested, acquires test case data corresponding to the application to be tested based on the first data, generates a test script of the application to be tested based on the test case data, and finally develops a test process based on the test script and the test case data.
The general idea of the information acquisition method proposed by the present invention is shown in fig. 1: the method comprises the steps of obtaining first data based on a to-be-tested interface of an application to be tested, then obtaining second data based on the first data, obtaining test case data by combining the second data and the test data, and finally generating a test script on the basis of the test case data.
Based on the general idea, the precondition for realizing the information acquisition method of the invention is that: in the development process, first data needs to be generated in a software code in a mode of modifying a configuration file and adding annotations to an interface to be tested.
The following explains and explains the implementation steps of the testing method proposed by the present invention in detail with reference to the drawings and the above general idea of the information acquisition method of the present invention.
It should be appreciated that reference throughout this specification to "an embodiment of the present invention" or "an embodiment described previously" means that a particular feature, structure or characteristic described in connection with the embodiment is included in at least one embodiment of the present invention. Thus, the appearances of the phrase "in an embodiment of the present invention" or "in the foregoing embodiments" in various places throughout the specification are not necessarily all referring to the same embodiment. Furthermore, the particular features, structures, or characteristics may be combined in any suitable manner in one or more embodiments. In various embodiments of the present invention, the sequence numbers of the above-mentioned processes do not mean the execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention. The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
The present invention provides an information acquisition method applicable to an information acquisition apparatus, as shown in fig. 2, the method including the steps of:
step 101, generating first data of an interface to be tested based on first identification information corresponding to the interface to be tested.
The first identification information represents description information corresponding to the interface information of the interface to be tested; the first data comprises data related to interface information of the interface to be tested; the interface to be tested is any interface in the application to be tested.
In one embodiment, in the development process, the first flag information of the to-be-tested interface of the to-be-tested application is directly added in the software code by a developer according to the requirement of interface testing.
In one embodiment, the first flag information added by the developer in the interface to be tested of the software code is annotation information corresponding to the interface to be tested. After the annotation information is added, the first data of the interface to be tested can be automatically generated through the storing and compiling processes.
And 102, acquiring test case data of the application to be tested based on the first data.
The first data is subjected to format conversion to obtain data in a required format, and then test case data of the application to be tested is obtained based on the data in the required format.
In an implementation manner, conversion of test case data of the application to be tested, which is obtained based on the first data, can be realized in a code development manner.
And 103, generating a test script of the application to be tested based on the test case data of the application to be tested.
The test script of the application to be tested is generated based on the test case data of the application to be tested, and the test is implemented by a tester according to the application to be tested in a corresponding test environment.
The information acquisition method provided by the invention can generate first data of the interface to be tested based on the first mark information corresponding to the interface to be tested of the application to be tested, then acquire test case data of the application to be tested based on the first data, and then generate a test script of the application to be tested based on the test case data of the application to be tested.
Based on the foregoing embodiments, an embodiment of the present invention provides an information obtaining method, which is applicable to an information obtaining device, and as shown in fig. 3, the method includes the following steps:
step 201, generating first data of the interface to be tested based on the first identification information corresponding to the interface to be tested.
The first identification information represents description information corresponding to the interface information of the interface to be tested; the first data comprises data related to interface information of the interface to be tested; the interface to be tested is any interface in the application to be tested.
In one embodiment, the first identification information is added in the software code by a developer directly according to the test requirement in the process of software development.
In an embodiment, the first flag information is obtained by modifying a configuration file by a developer to introduce a swagger package file, and correspondingly adding swagger notes to the interface to be tested.
Accordingly, the first data can be obtained by saving and compiling annotation information added by a developer at the to-be-tested interface part of the to-be-tested code.
In one embodiment, the first data may be json data, which is a data commonly used in software development and software testing, and is a lightweight data exchange format that is easy to read and write, and easy to machine parse and generate, and stores data in the form of key-value pairs.
In an implementation mode, the first data is json data obtained by developers in a mode of adding swagger annotations to software codes based on interface test requirements, so that the API interface documents in a preset format corresponding to the software codes can be written quickly, document sorting is reduced, document accuracy can be improved, and communication efficiency of team development is improved indirectly.
In an implementation mode, conversion from software codes to json data is achieved by adding swagger annotations, a back-end configuration dependent file can be modified in the software code development process, swagger annotations are added in corresponding software codes, and in addition, a User Interface (UI) module provided by swagger is combined, and newly generated API Interface documents and generated json data can be viewed in swagger in a browser mode in real time.
The scheme of obtaining json data by adding swagger annotation belongs to the mature technology, and details are not repeated in the embodiment of the invention.
In the embodiment of the present invention, a sample of json data is obtained by adding swagger annotation, for example, as shown in fig. 4, where fig. 4 shows a POST interface added with a blacklist, and the content of the POST interface is displayed on a World Wide Web (Web) end page of swagger, where the data sources in fig. 4 are: http://172.20.46.184:8085/v2/api-docs, the data sources are explained as follows: an Internet Protocol Address (IP) port on the host is 8085, and a relative file path is a file overall path under v2/api-docs, which is 172.20.46.184. The following table 1 summarizes and explains the fields and meanings of the data in fig. 4, and the field names, the parents, the field classifications and the description contents are illustrated in table 1; wherein the field name represents a key in the json data; the parent level represents the category to which the current field name belongs; the 'fixed/non-fixed' in the field classification means whether the current field name changes according to the interface content; the description indicates the actual meaning represented by the field name. Where each datum in FIG. 4 contains the contents listed in the first column of Table 1, e.g., the contents in line 9 of Table 1 indicates: the key of the current json data is post, and the key corresponds to a request sent in a non-fixed form under a/blacklistInfo/adddelakallist path; wherein,/blacklistInfo/addblocklist represents add blacklist operations under the blacklist base information path. The description field in table 1 explains each field in the field name in detail.
TABLE 1
Figure BDA0002171857010000091
Figure BDA0002171857010000101
In the embodiment of the present invention, the interface to be tested is any interface in the application to be tested, where any interface in the application to be tested includes a front-end interface and a non-front-end interface, and the front-end interface refers to an interface directly related to a page operation, such as a registration operation related interface and a search request sending operation related interface; the non-front-end interface refers to an interface which is not directly related to page operations, such as an interface related to background data conversion operations. Therefore, the interface to be tested in the testing method provided by the invention is not limited by only testing the front-end interface in the traditional interface test, and can cover any interface to be tested and applied.
Step 202, performing format conversion on the first data to obtain second data.
In step 202, obtaining the second data based on the first data may be performed manually by a tester or automatically by developing a code.
In one embodiment, the target format of the format conversion performed on the first data may be Comma Separated Values (CSV); CSV is also called character separation value because the separation character may not be a comma), may be extensible Markup Language (xml), or may be stored in other forms such as a spreadsheet (excel) or testoil based on a computer operating system.
It should be noted that, in the description and the step parsing in all embodiments of the present invention, the target format for converting the first data format is performed by taking the CSV format as an example, but in any step and method mentioned in the embodiments of the present invention, the format of the second data is not limited to the CSV.
In an embodiment, taking conversion of json data into a CSV format as an example, firstly, a development code analyzes the obtained json data to obtain a CSV format API document, where the content analysis of the CSV format API document is shown in table 2. In table 2, API information obtained by parsing json data in the form of key-value pairs (key, value) is obtained, where value corresponding to key case id is 1, value corresponding to key API type is blank-info-controller, value corresponding to key API name is blacklisted, value corresponding to key url is/blacklistInfo/dblacklist, value corresponding to key httpmesced is POST, value corresponding to key parameter is { "name": "string": and "string" }, value corresponding to key expectValue is { "code": string ": result": 0 ": result": 0 ": and the content of each key value table 2 is as follows: caseID is 1, apiName with apiType as black-info-controller is url of API interface for adding blacklist personnel: the API sends requests of name and phone contents carrying character string types corresponding to the parameter in a POST mode, and the expected return result expectValue corresponds to the contents as follows: the code corresponds to a value of 0, the message corresponds to a character string type, and the result corresponds to a value of 0. And if the returned result is not the value corresponding to expectValue, the result is an abnormal result. In summary, table 2 summarizes the transmission mode of an API interface, the address of the interface, the name of the interface, the parameters carried when the request is transmitted, and the expected returned result. That is, each piece of information in the CSV formatted document can be used to both send a request and check the request return result.
TABLE 2
Figure BDA0002171857010000121
It should be noted that table 3 summarizes the meaning of each field name in the first column of table 2, i.e., all parameter information in each API in the CSV document. Further description of the above API can be obtained by combining the above description of the contents of table 2 with the contents of table 3: the test case number (CodeID) is 1, the API type (apiType) is a custom blackbest-info-controller, the number under the API type (apiSeq) is 1, the API interface functional description is to add blacklist personnel, and the API interface request path (url) is: the API sends a name (name) carrying a character string type and a telephone (phone) content request corresponding to a parameter (parameter) in a POST mode, and the expected return result (expectValue) corresponds to the following content: the value corresponding to the code (code) is 0, the value corresponding to the message (message) is a character string type, and the value corresponding to the result (result) is 0. And if the returned result is not the value corresponding to expectValue, the result is an abnormal result.
TABLE 3
Figure BDA0002171857010000122
Figure BDA0002171857010000131
In the json data conversion process, data of a character String (String) type is filled in as "String", integer (int) data is filled in as 0, and other unknown data types are filled in as null.
In addition, the format of the input parameters can be adjusted according to the project requirements, for example: request parameters may be placed in a request header field (header) according to project requirements; request parameters may also be placed in the request path field; in the embodiment of the present invention, the form of self-adjusting the input parameter format is not limited to the above two forms, and in the specific implementation process, the flexible adjustment can be performed according to the actual situation of the interface and the test requirements.
And 203, acquiring test case data based on the second data.
In one embodiment, step 203 may also be implemented by steps 203a-203b, as follows:
step 203a, obtaining test data corresponding to the interface to be tested.
In one embodiment, the test data may be obtained by manual input. For CSV format API documents, specific values may be manually filled, for example, the content corresponding to the phone key in the parameter field in table 2 above may be manually filled.
In one embodiment, the test data may also be obtained by way of automatic random generation. In such an embodiment, a set of parameter-filling codes is typically developed to enable random generation of input parameters and corresponding types of filling operations. For example, data of int type will usually fill in values of 0, 1, -1, etc. automatically; in addition, data is randomly generated and filled according to the specific meaning and type of the input parameters in the related item interface, for example, the content corresponding to the phone (phone) keyword in the parameter field in table 2 above is a cell phone number, and the content corresponding to the name (name) keyword in the parameter field is a character string (string).
In one embodiment, the test data may also be obtained by way of derivation from a database. In this embodiment, a set of input parameters corresponding to the data type and number needs to be prepared in advance and stored in the database. When the test data is required to be obtained, the input parameters are obtained from the database in a specific mode and are filled into each interface correspondingly according to the types and the lengths of the input parameters.
In one embodiment, the test data is obtained from a database, and may also be obtained by creating data through an interface. In the field of software testing, creating and acquiring data by calling several interfaces is a very convenient and efficient operation mode, and dynamic acquisition of parameters can be realized. However, this approach is not recommended for the case of particularly complex interface parameters.
In one embodiment, the test data is obtained from the database, the input parameters can be imported into the database in advance, when the test data needs to be obtained, the required data is directly exported in a Structured Query Language (SQL) statement mode, the SQL statement can be compiled into an SQL file according to the test requirement, and the test data can be obtained by directly running the SQL file in the regression test, so that the interface can be ensured to be called randomly.
In the above embodiments, the obtaining mode of the test data may be flexibly adjusted according to the requirement of the actual project test, or a certain mode or a combination of certain modes may be adopted to obtain the test data.
Step 203b, obtaining test case data based on the second data and the test data.
In one embodiment, the test case data is obtained based on the second data and the test data, and may be executed by a developer or a tester according to actual test requirements of the application to be tested.
In one embodiment, the test case data is obtained based on the second data and the test data, and the test case data can be obtained by developing codes.
In an embodiment, step 203b may also be implemented by steps 203b1 to 203b2, which are as follows:
step 203b1, based on the second data, obtaining test data attribute information.
The test data attribute information represents attribute information of test data required by the interface to be tested and contained in the second data.
In one embodiment, obtaining the test data information corresponding to the second data may be implemented by developing software codes to parse a file storing the second data. The test data attribute information includes the interface name, the interface category, the input parameter attribute information, and the output parameter attribute information corresponding to the interface to be tested included in the second data, as described in table 2 and table 3 above. Specifically, the input parameter attribute information includes information such as an interface input parameter list, the number of parameters in the input parameter list, the type of each parameter, and the length of the parameter, and the output parameter attribute information includes information such as an output parameter list, the number of parameters in the output parameter list, the type of each output parameter, and the length of the output parameter.
Step 203b2, test case data is obtained based on the test data, the test data attribute information and the second data.
In step 203b2, test case data is obtained based on the test data, the test data attribute information, and the second data may be analyzed by a developer or a tester developing a software code pair and the test data is obtained according to the test data attribute information.
The data analysis and filling based on the software code belongs to the prior art, and is not described in detail in this step.
In the method used in step 203, the test data may be flexibly obtained, the attribute information of the test data may be obtained by automatically analyzing the second data, and the test case data may be obtained based on the second data, the test data, and the attribute information of the test data, so that the test case data may be automatically obtained, and the test case data may be generated more flexibly.
And 204, generating a test script of the application to be tested based on the test case data of the application to be tested.
It should be noted that, for descriptions of steps (or concepts) that are the same as or correspond to those in other embodiments of the present invention, reference may be made to descriptions in other embodiments, and further description is omitted here.
The information acquisition method disclosed by the invention can generate first data of the interface to be tested based on the first mark information corresponding to the interface to be tested, then acquire test case data of the application to be tested based on the first data, and then generate a test script of the application to be tested based on the test case data of the application to be tested.
Based on the foregoing embodiments, an embodiment of the present invention provides an information obtaining method, which may be applied to an information obtaining device, and as shown in fig. 5, the method includes the following steps:
step 301, generating first data of the interface to be tested based on the first identification information corresponding to the interface to be tested.
The first identification information is used for converting the interface to be tested into first data; the first data comprises data related to interface information of the interface to be tested; the interface to be tested is any interface in the application to be tested.
In one embodiment, step 301 may also be implemented by steps 301a to 301 b:
step 301a, monitoring an application code of an application to be tested.
The application code is used for realizing the functions of the application to be tested and is written by a software developer.
Step 301b, if it is monitored that the application code of the application to be tested is successfully compiled, generating first data of the interface to be tested based on the first identification information corresponding to the interface to be tested.
In the actual interface testing process, a general interface test needs to obtain an interface document and then perform test script design, and especially a meter and a LoadRunner are more prone to performing webpage recording after front and back end joint debugging to obtain an interface. The information acquisition method provided by the invention can lead the test time to be advanced, and once the development of the back-end code is completed, the interface information can be automatically obtained through storage and compilation, even the test case can be automatically obtained, thus leading the function of the test time to be comprehensive and advanced; and the problem that a large number of test cases are generally required to be modified when the interface changes due to repeated modification of the program is solved, so that the interface test cases can be rapidly changed after the software codes are changed, and the interface test and debugging can be performed based on the changed test cases.
Step 302, obtaining test case data of the application to be tested based on the first data.
And 303, loading the test case data to obtain a preliminary configuration test script based on the initialization test script.
In step 303, the tester creates an initialized test script based on the software testing tool. In the embodiment of the present invention, fig. 6 is a CSV data file setting diagram in a testing process, in the diagram, a tester can obtain a right CSV data file setting option summary window by selecting a CSV data file setting option of a left window, where a set CSV data file list at a lower portion of a right window includes a CSV file name to be selected and loaded, a code of the CSV file, a variable name, a leader, a separator, whether to allow a quotation mark, meet a file end symbol for recirculation, meet a file end symbol for stopping a thread, and a thread sharing mode, and in an actual interface testing process, the tester can select corresponding CSV test case data for a testing tool according to an application to be tested, and the testing tool can automatically load the CSV test case data. The software testing tools include the above mentioned packet capturing tools, such as Wireshark and Fiddler, and include interface calling tools, such as Postman and soaui, and include pressure testing tools, such as Jmeter and LoadRunner, and also include pressure testing tools, such as LoadRunner.
In the description of the steps in the embodiments of the present invention, a Jmeter is used as an example. However, in all the embodiments of the present invention, the test tool for acquiring the test script includes many test tools mentioned above, and is not limited to the kind of Jmeter.
Step 304, determining a request mode for the application to be tested.
In the interface testing process, the request modes of the application to be tested comprise GET and POST.
And 305, generating a test script of the application to be tested based on the preliminary configuration test script and the request mode.
In the embodiment of the present invention, as shown in fig. 7, a tester needs to configure an http request by selecting a GET or a POST method according to an actual test requirement of an application to be tested. In addition, a loop controller needs to be added under the thread group, and the loop number is set to be permanent. And adding a CSV Data configuration (Data Set Config) control under the cycle controller.
In one embodiment, after step 305, the following steps may also be performed:
and A, acquiring the response state of the interface to be tested based on the test case data.
In one embodiment, step a may obtain the response status of the interface to be tested by adding the assertion and configuring the assertion according to the project requirement and the emphasis of the interface test. For example, a unified assertion may be added to determine if the interface responds successfully (Status Code: 200).
And B, determining a test result of the application to be tested based on the response state of the interface to be tested.
In one embodiment, the response state of the interface to be tested is obtained first, and then the return result of the actual execution of the test case is compared with the expected result in the test case data to judge whether the service is successful.
And C, generating a test report based on the test result.
In the process of the actual interface test, the service execution result corresponding to the test case data can be summarized so as to obtain the test report.
The embodiment of the invention provides a method for acquiring an API document in a preset format by adding swagger annotation in a development code, acquiring test case data based on the API document and acquiring a test script based on the test case data, thereby realizing a full-automatic interface test flow, namely, a mode for automatically acquiring an interface, a test script and automatically executing.
The information acquisition method provided by the invention forms an integral test scheme from the acquisition of the test interface, the generation of the test case, the execution of the test case and the generation of the test report.
It should be noted that, for descriptions of steps (or concepts) that are the same as or correspond to those in other embodiments of the present invention, reference may be made to descriptions in other embodiments, and further description is omitted here.
The information acquisition method disclosed by the invention can generate first data of the interface to be tested based on the first mark information corresponding to the interface to be tested, then acquire test case data of the application to be tested based on the first data, and then generate a test script of the application to be tested based on the test case data of the application to be tested.
Based on the foregoing embodiments, the present invention provides an information acquiring apparatus, which may be applied to the information acquiring method provided in the embodiments corresponding to fig. 2 to 4, and as shown in fig. 8, the information acquiring apparatus includes: a processor 41, a memory 42 and a communication bus 43. Wherein:
a communication bus 42 for implementing a communication connection between the processor 41 and the memory 42.
The processor 41 is configured to execute the software testing method program stored in the memory 42 to implement the following steps:
and generating first data of the interface to be tested based on the first identification information corresponding to the interface to be tested.
The first identification information represents description information corresponding to the interface information of the interface to be tested; the first data comprises data related to interface information of the interface to be tested; the interface to be tested is any interface in the application to be tested.
And acquiring test case data of the application to be tested based on the first data.
And generating a test script of the application to be tested based on the test case data of the application to be tested.
In other embodiments of the present invention, processor 41 is further configured to execute a software test program stored in memory 42 to implement the following steps:
carrying out format conversion on the first data to obtain second data;
and acquiring the test case data based on the second data.
Acquiring test data corresponding to an interface to be tested;
and acquiring test case data based on the second data and the test data.
In other embodiments of the present invention, processor 41 is further configured to execute a software test program stored in memory 42 to implement the following steps:
acquiring test data attribute information based on the second data;
and acquiring test case data based on the test data, the test data attribute information and the second data.
In other embodiments of the present invention, processor 41 is further configured to execute a software test program stored in memory 42 to implement the following steps:
generating a test script of the application to be tested based on test case data of the application to be tested, wherein the test script comprises the following steps:
loading test case data to obtain a preliminary configuration test script based on the initialization test script;
and determining a request mode aiming at the application to be tested to generate a test script of the application to be tested based on the preliminary configuration test script.
In other embodiments of the present invention, processor 41 is further configured to execute a software test program stored in memory 42 to implement the following steps:
generating first data of the interface to be tested based on first identification information corresponding to the interface to be tested, wherein the generating comprises the following steps:
monitoring an application code of an application to be tested; the application code is used for realizing the functions of the application to be tested;
if the situation that the compiling of the application code of the to-be-tested application is successful is monitored, first data of the to-be-tested interface are generated based on first identification information corresponding to the to-be-tested interface.
In other embodiments of the present invention, processor 41 is further configured to execute a software test program stored in memory 42 to implement the following steps:
after generating the test script of the application to be tested based on the test script, the test case data and the request mode, the method further comprises the following steps:
acquiring a response state of the interface to be tested based on the test script;
determining a test result of the application to be tested based on the response state of the interface to be tested;
and generating a test report based on the test result.
In other embodiments of the present invention, processor 41 is further configured to execute a software test program stored in memory 42 to implement the following steps:
carrying out format conversion on the first data to obtain second data;
and acquiring the test case data based on the second data.
It should be noted that, for descriptions of the same steps and the same contents in the embodiment of the present invention and other embodiments, reference may be made to the descriptions in other embodiments, which are not repeated herein.
The information acquisition equipment provided by the invention can generate first data of the interface to be tested based on the first mark information corresponding to the interface to be tested, then acquire test case data of the application to be tested based on the first data, and then generate a test script of the application to be tested based on the test case data of the application to be tested.
Based on the foregoing embodiments, embodiments of the present invention provide a computer storage medium storing one or more programs, which are executable by one or more processors to implement the steps of the information acquisition method provided by the embodiments corresponding to fig. 2, 3 and 5 above.
The Processor may be at least one of an Application Specific Integrated Circuit (ASIC), a Digital Signal Processor (DSP), a Digital Signal Processing Device (DSPD), a Programmable Logic Device (PLD), a Field Programmable Gate Array (FPGA), a Central Processing Unit (CPU), a controller, a microcontroller, and a microprocessor. It is understood that the electronic device implementing the above-mentioned processor function may be other electronic devices, and the embodiments of the present application are not particularly limited.
The computer storage medium/Memory may be a Read Only Memory (ROM), a Programmable Read Only Memory (PROM), an Erasable Programmable Read Only Memory (EPROM), an Electrically Erasable Programmable Read Only Memory (EEPROM), a magnetic Random Access Memory (FRAM), a Flash Memory (Flash Memory), a magnetic surface Memory, an optical Disc, or a Compact Disc Read-Only Memory (CD-ROM); but may also be various terminals such as mobile phones, computers, tablet devices, personal digital assistants, etc., that include one or any combination of the above-mentioned memories.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, recitation of an element by the phrase "comprising an … …" does not exclude the presence of other like elements in the process, method, article, or apparatus that comprises the element.
The above-mentioned serial numbers of the embodiments of the present application are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present application may be embodied in the form of a software product, which is stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal device (such as a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method described in the embodiments of the present application.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
The above description is only a preferred embodiment of the present application, and not intended to limit the scope of the present application, and all modifications of equivalent structures and equivalent processes, which are made by the contents of the specification and the drawings of the present application, or which are directly or indirectly applied to other related technical fields, are included in the scope of the present application.

Claims (10)

1. An information acquisition method, characterized in that the method comprises:
generating first data of an interface to be tested based on first identification information corresponding to the interface to be tested; wherein the first identification information represents descriptive information of the interface to be tested; the first data comprises data related to interface information of the interface to be tested; the interface to be tested is any interface in the application to be tested;
acquiring test case data of the application to be tested based on the first data;
and generating a test script of the application to be tested based on the test case data of the application to be tested.
2. The method of claim 1, wherein obtaining test case data of the application to be tested based on the first data comprises:
carrying out format conversion on the first data to obtain second data;
and acquiring the test case data based on the second data.
3. The method of claim 2, wherein obtaining the test case data based on the second data comprises:
acquiring test data corresponding to the interface to be tested;
and acquiring the test case data based on the second data and the test data.
4. The method of claim 3, wherein obtaining the test case data based on the second data and the test data comprises:
acquiring test data attribute information based on the second data;
and acquiring the test case data based on the test data, the test data attribute information and the second data.
5. The method of claim 1, wherein generating a test script for the application to be tested based on the test case data of the application to be tested comprises:
loading the test case data to obtain a preliminary configuration test script based on the initialization test script;
determining a request mode aiming at the application to be tested;
and generating the test script of the application to be tested based on the preliminary configuration test script and the request mode.
6. The method of claim 5, wherein the generating first data of the interface to be tested based on the first identification information corresponding to the interface to be tested comprises:
monitoring the application code of the application to be tested; wherein the application code is used for realizing the functions of the application to be tested;
if it is monitored that the application code of the to-be-tested application is successfully compiled, first data of the to-be-tested interface are generated based on first identification information corresponding to the to-be-tested interface.
7. The method of claim 5, wherein after generating the test script for the application to be tested based on the preliminary configuration test script and the request manner, the method further comprises:
acquiring a response state of the interface to be tested based on the test script;
determining a test result of the application to be tested based on the response state of the interface to be tested;
and generating a test report based on the test result.
8. An information acquisition apparatus, characterized in that the apparatus comprises: a processor, a memory, and a communication bus;
the communication bus is used for realizing communication connection between the processor and the memory;
the processor is used for executing the information acquisition program in the memory to realize the following steps:
generating first data of an interface to be tested based on first identification information corresponding to the interface to be tested; the first identification information is used for converting the interface to be tested into the first data; the first data comprises data related to interface information of the interface to be tested; the interface to be tested is any interface in the application to be tested;
acquiring test case data of the application to be tested based on the first data;
and generating a test script of the application to be tested based on the test case data of the application to be tested.
9. The apparatus of claim 8, wherein the processor is configured to execute an information acquisition program in the memory to perform the steps of:
carrying out format conversion on the first data to obtain second data;
and acquiring the test case data based on the second data.
10. A computer storage medium, characterized in that the computer storage medium stores one or more programs executable by one or more processors to implement the information acquisition method steps of any one of claims 1 to 7.
CN201910765704.0A 2019-08-19 2019-08-19 Information acquisition method, equipment and computer storage medium Pending CN112395184A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910765704.0A CN112395184A (en) 2019-08-19 2019-08-19 Information acquisition method, equipment and computer storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910765704.0A CN112395184A (en) 2019-08-19 2019-08-19 Information acquisition method, equipment and computer storage medium

Publications (1)

Publication Number Publication Date
CN112395184A true CN112395184A (en) 2021-02-23

Family

ID=74603560

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910765704.0A Pending CN112395184A (en) 2019-08-19 2019-08-19 Information acquisition method, equipment and computer storage medium

Country Status (1)

Country Link
CN (1) CN112395184A (en)

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112882936A (en) * 2021-02-24 2021-06-01 平安普惠企业管理有限公司 Interface case testing method and device and storage medium
CN113238965A (en) * 2021-06-18 2021-08-10 杭州遥望网络科技有限公司 Interface test script generation method, system and storage medium
CN113407454A (en) * 2021-06-29 2021-09-17 山东派盟网络科技有限公司 Method, device and equipment for comprehensive test
CN113535548A (en) * 2021-06-21 2021-10-22 上汽通用五菱汽车股份有限公司 Test script generation method, device, equipment and computer readable storage medium
CN115292200A (en) * 2022-09-28 2022-11-04 北京六方云信息技术有限公司 Interface test method, device, equipment and medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107391379A (en) * 2017-07-28 2017-11-24 武汉斗鱼网络科技有限公司 Interface automatic test approach and device
CN108415832A (en) * 2018-02-07 2018-08-17 平安科技(深圳)有限公司 Automatic interface testing method, device, equipment and storage medium
CN109446072A (en) * 2018-09-27 2019-03-08 深圳壹账通智能科技有限公司 The generation method and device of test script
CN109947646A (en) * 2019-03-13 2019-06-28 平安信托有限责任公司 Interface test method, device, computer equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107391379A (en) * 2017-07-28 2017-11-24 武汉斗鱼网络科技有限公司 Interface automatic test approach and device
CN108415832A (en) * 2018-02-07 2018-08-17 平安科技(深圳)有限公司 Automatic interface testing method, device, equipment and storage medium
CN109446072A (en) * 2018-09-27 2019-03-08 深圳壹账通智能科技有限公司 The generation method and device of test script
CN109947646A (en) * 2019-03-13 2019-06-28 平安信托有限责任公司 Interface test method, device, computer equipment and storage medium

Cited By (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112882936A (en) * 2021-02-24 2021-06-01 平安普惠企业管理有限公司 Interface case testing method and device and storage medium
CN113238965A (en) * 2021-06-18 2021-08-10 杭州遥望网络科技有限公司 Interface test script generation method, system and storage medium
CN113238965B (en) * 2021-06-18 2023-04-07 杭州遥望网络科技有限公司 Interface test script generation method, system and storage medium
CN113535548A (en) * 2021-06-21 2021-10-22 上汽通用五菱汽车股份有限公司 Test script generation method, device, equipment and computer readable storage medium
CN113535548B (en) * 2021-06-21 2023-01-03 上汽通用五菱汽车股份有限公司 Test script generation method, device, equipment and computer readable storage medium
CN113407454A (en) * 2021-06-29 2021-09-17 山东派盟网络科技有限公司 Method, device and equipment for comprehensive test
CN115292200A (en) * 2022-09-28 2022-11-04 北京六方云信息技术有限公司 Interface test method, device, equipment and medium

Similar Documents

Publication Publication Date Title
CN107908541B (en) Interface testing method and device, computer equipment and storage medium
CN112395184A (en) Information acquisition method, equipment and computer storage medium
WO2020119434A1 (en) Method and apparatus for interface data processing, method and apparatus for automated testing, device, and medium
Mesbah et al. Automated cross-browser compatibility testing
US9652366B2 (en) Code change analysis to optimize testing lifecycle
US7877681B2 (en) Automatic context management for web applications with client side code execution
CN110427331A (en) The method for automatically generating performance test script based on interface testing tool
US20150026666A1 (en) Analysis system, analysis method, and computer program product
CN109359045B (en) Test method, device, equipment and storage medium
CN110750458A (en) Big data platform testing method and device, readable storage medium and electronic equipment
CN112241360A (en) Test case generation method, device, equipment and storage medium
CN111782526A (en) Interface testing method and device, electronic equipment and storage medium
CN112540924A (en) Interface automation test method, device, equipment and storage medium
CN110609785A (en) Software interface testing method and device
CN111737114A (en) Login function testing method and device
CN117632710A (en) Method, device, equipment and storage medium for generating test code
TW201629768A (en) Infrastructure rule generation
CN112256557B (en) Program regression testing method, device, system, computer equipment and storage medium
CN117370203B (en) Automatic test method, system, electronic equipment and storage medium
CN117076338B (en) Method and system for dynamically debugging Linux kernel based on kprobe
CN111506305B (en) Tool pack generation method, device, computer equipment and readable storage medium
CN111124937B (en) Method and system for assisting in improving test case generation efficiency based on instrumentation function
CN110134904B (en) Page checking method, device, equipment and medium
CN112346981A (en) Joint debugging test coverage rate detection method and system
KR101039874B1 (en) System for integration platform of information communication

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
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20210223

WD01 Invention patent application deemed withdrawn after publication