CN113760757B - Method and system for generating test model based on HAR file - Google Patents

Method and system for generating test model based on HAR file Download PDF

Info

Publication number
CN113760757B
CN113760757B CN202111015287.1A CN202111015287A CN113760757B CN 113760757 B CN113760757 B CN 113760757B CN 202111015287 A CN202111015287 A CN 202111015287A CN 113760757 B CN113760757 B CN 113760757B
Authority
CN
China
Prior art keywords
file
configuration
request
initial
har
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.)
Active
Application number
CN202111015287.1A
Other languages
Chinese (zh)
Other versions
CN113760757A (en
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.)
Chengdu DBAPPSecurity Co Ltd
Original Assignee
Chengdu DBAPPSecurity 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 Chengdu DBAPPSecurity Co Ltd filed Critical Chengdu DBAPPSecurity Co Ltd
Priority to CN202111015287.1A priority Critical patent/CN113760757B/en
Publication of CN113760757A publication Critical patent/CN113760757A/en
Application granted granted Critical
Publication of CN113760757B publication Critical patent/CN113760757B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

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

Abstract

The invention relates to the technical field of automatic interface testing, and discloses a method for generating a test model based on HAR files, which comprises the following steps of S1, acquiring an initial file a and inputting an initial configuration file b; s2, judging whether the initial file a is in the HAR format, if so, reading the initial file a into an input and output stream to analyze, obtaining an array object list a1 corresponding to the HAR format, and obtaining a corresponding parameter control object b1; s3, analyzing the data object list a1 to obtain a corresponding request object a2; s4, grouping, de-duplication and induction are carried out on the request object a2, and a corresponding dictionary object a3 is obtained; s5, generating an interface AW according to the parameter control object b1 in the step S2 and the dictionary object a3 in the step S4. The invention also discloses a system for generating the test model based on the HAR file. The invention generates the AW adapting to each interface test platform by acquiring the HAR file, and can realize the automatic generation of the interface based on the invention as long as the application is accessed by using the browser as the client.

Description

Method and system for generating test model based on HAR file
Technical Field
The invention relates to the technical field of automatic testing of interfaces, in particular to a method and a system for generating a test model based on HAR files.
Background
The browser is an indispensable testing tool for the WEB application, all the WEB applications can be matched with the browser, along with the cloud of the application, the WEB application is more and more, the front-back end separation technology is also accelerating to develop, which means that the requirements on the generation of the API template are higher and higher, and how to quickly generate the API interface template to improve the testing efficiency becomes a key problem.
At present, interface documents or HTTP requests are manually grabbed on a WEB interface to test the interface and then copied into a tool. The interface document flow includes: and synchronously outputting interface documents when the WEB application is developed and designed, delivering the documents to a test when the test is transferred, and importing the test to an interface tool for testing. This approach is limited to the problem of file definition of tools, only fixed tools can be used, developer level is staggered, the standard level of the document is difficult to determine, the final implementation and the document may be different, and most project groups do not have a strict flow system, or the document is missing for other reasons.
The manual grabbing of the HTTP request flow on the WEB interface comprises the following steps: the browser is used for capturing the requests after opening F12, the request URL is copied in sequence, and then the request query parameters, the request payload parameters and the payload types are filled into the corresponding tool UI, so that the template creation can be completed. This method is inefficient and requires high experience for the tester and familiarity with HTTP principles.
Based on these two disadvantages, we can confirm that the requests that can run on WEB must be in a final implementation form, and must be standardized. Secondly, the efficiency of the process of converting the request in the browser to the template file of the test tool needs to be improved, and the invention is compatible with the own language of each platform based on the requirement to realize the automation of template generation.
Disclosure of Invention
The invention aims to provide a method and a system for generating a test model based on HAR files, which realize the function of automatically generating interfaces and have the effects of more adaptation platforms, more user-defined participation, more AW generating capability and support of multi-file analysis.
The invention is realized by the following technical scheme: a method of generating a test model based on HAR files, comprising:
s1, acquiring an initial file a from a browser, judging whether the initial file a exists or not, if so, inputting an initial configuration file b into a preset user configuration file, and entering a step S2, and if not, deleting and re-acquiring the initial file a until entering the step S2;
s2, judging whether the initial file a is in the HAR format, if so, reading the initial file a into an input and output stream for analysis, obtaining an array object list a1 corresponding to the HAR format, analyzing the initial configuration file b, obtaining a corresponding parameter control object b1, if not, reporting an error and returning to the step S1;
s3, analyzing the array object list a1 according to a preset array object optimization rule to obtain a corresponding request object a2;
s4, grouping, de-duplication and induction are carried out on the request object a2 according to a preset de-duplication grouping and induction rule, and a corresponding dictionary object a3 is obtained;
s5, generating an interface AW according to the parameter control object b1 in the step S2 and the dictionary object a3 in the step S4.
In the technical scheme, in step S1, the user gives the HAR file and the user-defined profile path, which can be specified by executing the command, and in step S2, the user-defined profile configured by the user is parsed, and if the profile path is not given or the profile is empty, the default values of the attributes are controlled by using the parameters to complete the creation of the object. If the configuration file is not empty, analyzing the values of all parameters in the configuration file, and configuring the values to the attributes of the corresponding parameter control objects one by one; if the file is empty or does not exist, deleting the file, if the file is not empty or does not exist, reporting errors, if the file is not found, reading the file into an input/output stream, analyzing entries in the file, traversing objects in the file, extracting useful object information into a json array object list, and optimizing attribute values into a requirement (Request) object defined in the system by using the array object list in the step S3 as file analysis, wherein the attribute values can be extracted from the json array because the json array can better assign the object attributes, and assigning the parameter values in the entries to all attributes in the object. Finally, a list of requirement (Request) objects is returned. The value corresponding to the entries object is an array, each array contains a specific HTTP Request, the Request object list in step S4 is used as the entry data of the packet deduplication module, the dictionary object generated in step S4 and the parameter control object generated in step S2 are both used as the entry data of step S5, and different interfaces AW are generated according to the data. According to the technical scheme, the configuration files of the interface templates of the interface test platforms are generated, codes are not generated directly, and after different platforms are imported, the contents of the interfaces can be modified and copied continuously on the visual interface, so that the method is simple, convenient and quick.
In order to better implement the present invention, further, step S1 includes:
the user configuration file analyzes the input initial configuration file b, judges whether the path of the initial configuration file b is given or is empty, if so, enters step S2, and if not, assigns the default value of the initial attribute in the user configuration file to the initial configuration file b; the initial attributes in the user profile include test platform, packet naming logic, interface naming logic and whether to process static file requests.
In the technical scheme, the input/output stream comprises a byte input stream, a byte output stream, a character input stream and a character output stream, and the initial file can be better read and analyzed.
In order to better implement the present invention, further, step S2 includes:
s2.1, analyzing an initial configuration file b by using a configuration analysis function, and reading each configuration value in the initial configuration file b;
s2.2, judging whether the value of each configuration is not existed or is empty, if so, using a default value for the attribute of the initialization parameter control object b1, and if not, using the value of each configuration as the parameter of the initialization parameter control object b1;
s2.3, acquiring an initialization parameter control object b1 with assigned values of all the attributes.
In the technical scheme, the initial configuration file b is analyzed by using a configuration analysis function, after the configuration analysis function receives a parameter entering configuration file path, the configuration analysis function uses a config module to analyze, an object configured by a corresponding module is created after analysis is completed, the configuration is assigned to the attribute of the object, and the attribute of the object corresponds to the configuration in the configuration file one by one. The configuration analysis function of the configuration file conversion user configuration object firstly judges whether the file exists or not, if yes, the configuration file conversion user configuration module converts the configuration file into a configer object, the specific configuration is sequentially read out, then the u_config object is created by using the parameters, the u_config object is returned to a caller as a function parameter, if not, an initialization parameter control (UserConfig) object is returned, and the configuration content of the initial configuration file comprises a test platform, grouping naming logic, interface naming logic, whether a static file request is processed or not and the like. In the technical scheme, the data in the HAR file is converted into the template file for interface test of the platform after being subjected to a large amount of processing, so that the requirement of frequent access to the data content of the HAR file is avoided, and the method can be suitable for scene configuration of various test interfaces.
In order to better implement the present invention, further, the preset array object optimization rule in step S3 includes:
s3.1, defining a demand array object A1, traversing a data list of the demand array object A1, and obtaining demand elements of the demand array object A1;
s3.2, taking out the corresponding values of the KEY in the demand element, and assigning the values to an array object list a1;
s3.3, assembling the array object list a1 to generate a corresponding request object a2, and returning to the step S3.1.
In the technical scheme, a Request (Request) object list in an array object optimization rule is used as parameter entering data of a grouping duplication removal module, path+method in the Request (Request) object in the list is traversed firstly and put into a temporary list, if the path+method value exists in the temporary list, the Request (Request) object is removed from the list, and if the path+method value does not exist, the Request (Request) object is reserved. Traversing an original data list, taking an element in the list after traversing, taking out the value corresponding to each KEY in the element, assigning the attribute of a Request object, putting the Request object into an array list after assembling, and returning the list of the Request object after completing traversing.
In order to better implement the invention, step S3.2 comprises: s3.2.1, extracting a parameter set of the HTTP request in the array object list a1;
and S3.2.2, assigning values corresponding to the KEYs in the demand elements to the parameter set of the HTTP request in the array object list a1 for optimization.
In the technical scheme, because the HAR file is in the json format essentially, the technical scheme is equivalent to converting the KEY of json into the attribute storage of the object, and the value corresponding to the KEY of json is assigned to the value of the object attribute, so that the value corresponding to each KEY in the required element can be better assigned to the parameter set of the HTTP request in the array object list a1, and then the optimization is performed.
In order to better implement the present invention, the de-duplication grouping induction rule in step S4 includes: s4.1, grouping the request objects A2 to generate a grouping request object A2;
s4.2, performing deduplication on the packet request object A2 to generate a deduplication request object A21; and S4.3, summarizing the deduplication request object A21 to generate a dictionary object a3.
In this technical solution, after the above-mentioned completion of the Request (Request) and the de-duplication of the packet, the corresponding Request (Request) object is put into the corresponding packet. Traversing the demand (Request) object, reading the Path value of the demand (Request) object, adding the demand (Request) object to a list corresponding to the KEY value in the dictionary according to the Path value, and returning to the complete dictionary object after the processing is completed. In the technical scheme, the data of the HAR file can be more accurately analyzed through the customized duplicate removal grouping induction rule to generate the template.
In order to better implement the present invention, step S5 includes:
s5.1, acquiring grouping configuration information B1 of parameter control according to a parameter control object B1, acquiring generation configuration information B11 of an interface AW in parameter control according to the grouping configuration information B1, and acquiring platform configuration B12 to be generated according to the generation configuration information B11;
s5.2, generating a corresponding dictionary object group A3 according to the group configuration information B1 and the dictionary object A3;
s5.3, acquiring a demand list of the dictionary object group A3 and traversing a demand object A31 in the demand list;
s5.4, generating names of demand interfaces AW according to the generation configuration information B11 of the interfaces AW in parameter control and the demand objects A31;
s5.5, generating interface AW configuration content and grouping configuration content of a corresponding platform according to the name of the required interface AW and the platform configuration B12 to be generated in the step S5.4;
s5.6, judging whether dictionary iteration is finished, if yes, finishing iteration and splicing generated configuration content into a final interface AW, and if no, entering step S5.1.
In the technical scheme, firstly, a dictionary object is imported, then grouping configuration of the parameter control object is obtained from the parameter control object, grouping names are generated according to the grouping configuration and the imported dictionary object, a requirement (Request) list under a corresponding grouping in the dictionary object is obtained according to the generated grouping names, then the requirement (Request) object in the list is traversed, at the moment, interface AW names in the parameter control object are obtained to generate configuration, names of the interface AW of the Request are generated according to the generated configuration and the requirement (Request) object in the traversing list, platform configuration which is obtained according to the configuration is generated according to the interface AW names, whether iteration of the dictionary object is finished is judged according to the generated platform configuration and the names of the interface AW of the Request is completed, if yes, the iteration is completed, the generated configuration content is spliced into a final file, and if no, the process is ended, the next iteration grouping is continued.
In order to better realize the invention, the invention also provides a system for generating the test model based on the HAR file, which comprises a file importing module, a user configuring module, a file analyzing module, a duplicate removing grouping module and a generating module, wherein:
the file importing module comprises a HAR file judging unit and a file importing module, wherein the HAR file judging unit is used for acquiring an initial file a from a browser, judging whether the initial file a exists or not, if so, inputting an initial configuration file b into a preset user configuration file, and entering the HAR file judging unit, and if not, deleting and reacquiring the initial file a until entering the HAR file judging unit;
the user configuration module is used for designating a path of the initial configuration file b, analyzing the initial configuration file b after the configuration analysis function receives the path of the initial configuration file b, analyzing and reading each configured value in the initial configuration file b, and assigning each configured value to the parameter control object b1;
the file analysis module is used for analyzing the data object list a1 according to a preset array object optimization rule to obtain a corresponding request object a2;
the de-duplication grouping module is used for grouping and de-duplication inducing the request object a2 according to a preset de-duplication grouping inducing rule to obtain a corresponding dictionary object a3;
a generating module for generating an interface AW according to the parameter control object b1 in step S2 and the dictionary object a3 in step S4.
In the technical scheme, the whole system comprises five modules, namely a file import module, a user configuration module, a file analysis module, a duplicate removal grouping module and a generation module, wherein the modules are realized by using python, each module is coupled in a related manner, a function call inlet is provided for completing common work, and main function inlets among different modules are used for completing serial call. The file importing module is used for designating a storage path of the HAR file which is not empty and exists, the main parameter of the user configuration module is also a path for designating the user configuration file, the main parameter entering data of the file analyzing module is an object list of the HTTP request transmitted by the file importing module, the parameter entering data of the de-duplication grouping module is a standardized request list returned by the file analyzing module, and the generating module finally generates a required interface AW according to the parameter control object and the dictionary object.
In order to better implement the present invention, the user configuration module includes:
the contents of the initial configuration file b include test platform addresses, packet naming logic contents, interface naming logic contents and processing static file request cases.
Compared with the prior art, the invention has the following advantages:
(1) The invention provides a tool for converting an adaptation standard HAR file into each test platform template, which greatly improves the capability of converting a browser packet capture record into an HTTP request template;
(2) Compared with other schemes, the invention has more adaptation platforms, more user-defined parameter entering and richer capability of generating the interface AW, and supports multi-file analysis.
Drawings
The invention is further described with reference to the following drawings and examples, and all inventive concepts of the invention are to be considered as being disclosed and claimed.
FIG. 1 is a flow chart of a method for generating a test model based on HAR files according to the present invention.
Fig. 2 is a flowchart of a generating interface AW of a method for generating a test model based on HAR files provided by the present invention.
Fig. 3 is a schematic structural diagram of a system for generating a test model based on HAR files according to the present invention.
Wherein: 10. a file importing module; 11. a user configuration module; 12. a file analysis module; 13. a de-duplication grouping module; 14. and generating a module.
Detailed Description
Example 1:
in the method for generating a test model based on the HAR file in this embodiment, as shown in fig. 1, in step S1, a user gives the HAR file and a user-defined profile path, and the path may be specified by executing commands including, but not limited to, python aw_generate. Py-HAR "-HAR _path" -user_config "user_config_path", and in step S2, the user-defined profile configured by the user is parsed, and if the profile path is not given or the profile is empty, the default values of the attributes are controlled by using parameters to complete the creation of the object. If the configuration file is not empty, analyzing the values of all parameters in the configuration file, and configuring the values to the attributes of the corresponding parameter control objects one by one; if the file is empty or does not exist, deleting the file, if the file is not empty or does not exist, reporting errors, if the file is not found, reading the file into an input/output stream, analyzing entries in the file, traversing objects in the file, extracting useful object information into a json array object list, extracting path, url, query, header, payload, method, headers, cookies, files from the array object list in step S3 as file analysis, optimizing the file into a requirement (Request) object defined in the system, and assigning parameter values in the entries to various attributes in the object. Finally, a list of requirement (Request) objects is returned. The value corresponding to the entries object is an array, each array contains a specific HTTP Request, the Request object list in step S4 is used as the entry data of the packet deduplication module, the dictionary object generated in step S4 and the parameter control object generated in step S2 are both used as the entry data of step S5, and finally different interfaces AW can be generated according to the data.
Example 2:
in this embodiment, further optimization is performed based on embodiment 1, if the file acquired in step S1 is empty or does not exist, the file is deleted, step S2 reads the initial file a from the input/output stream, and parses the entries therein, first, the value corresponding to the objects in the entries is an array, each array includes a specific HTTP Request, then a specific object in the array is expanded, the content of the Request (Request) object is found, then the attribute of the original object data in the array is obtained, and then the data is assigned to the attribute of the custom requirement (Request) object class, where the attribute name of the custom object is the same as the KEY value in the Request of the HAR file. Traversing the objects, extracting useful object information into a json array object list, wherein the HAR file is in json format, loading file content by using json.load () function, and if no error is reported, the content is legal and the next step is carried out. If the loading fails, indicating that the internal format is incorrect or missing, reporting an error and exiting, if not, reporting an error; the input/output stream includes a byte input stream, a byte output stream, a character input stream and a character output stream, and can better read and parse the initial file, in this embodiment, further optimize on the basis of the above embodiment 1 or 2, determine whether the file name suffix is a HAR file, if not, report an error, if yes, perform content inspection; the HAR file is in json format in nature, the file content is loaded using json.load () function, no error is reported, and the content is legal for the next step. If the loading fails, the internal format is incorrect or the internal format is missing, and the error is reported to exit.
Example 3:
the present embodiment is further optimized based on the above embodiment 1, first, it is determined whether the initial file a is in HAR format, where determining whether the initial file a is in HAR format is two steps, and the first step is: judging whether the file name suffix is a HAR file, if not, reporting an error, and if so, performing content inspection; and a second step of: the HAR file is in json format in nature, the file content is loaded using json.load () function, no error is reported, and the content is legal for the next step. If the loading fails, the internal format is incorrect or the internal format is missing, and the error is reported to exit. If the initial file a is judged to be in the HAR format, the initial file a is read into an input and output stream to be analyzed, an array object list a1 corresponding to the HAR format is obtained, an initial configuration file b is analyzed by using a configuration analysis function, after the configuration analysis function receives a parameter entering configuration file path, the configuration analysis function uses a control (config) module to analyze, an object corresponding to the module configuration is created after the analysis is completed, the configuration is assigned to the attribute of the object, and the attribute of the object corresponds to the configuration in the configuration file one by one. The configuration analysis function of the configuration file to user configuration object firstly judges whether the file exists or not, if yes, the configuration analysis function is converted into a configer object through the user configuration module 11, the specific configuration is sequentially read out, then the u_config object is created by using the parameters, the u_config object is returned to a caller as a function parameter, if not, an initialization parameter control (UserConfig) object is returned, and the configuration content of the initial configuration file comprises a test platform, grouping naming logic, interface naming logic, whether to process a static file request or not and the like.
Example 4:
in this embodiment, further optimization is performed based on the foregoing embodiment 1, where a Request (Request) object list in an array object optimization rule is used as a packet deduplication module to enter parameter data, path+method in a Request (Request) object in the list is traversed first, the Request (Request) object is put into a temporary list, if a path+method value already exists in the temporary list, the Request (Request) object is removed from the list, and if the path+method value does not exist, the Request (Request) object is reserved. Traversing an original data list, taking an element in the list after traversing, taking out the value corresponding to each KEY in the element, assigning the attribute of the Request object, putting the Request object into an array list after assembling, and returning the list of the Request object after traversing.
Example 5:
further optimizing the above embodiment 4, wherein the value corresponding to the entries object is an array, each array contains a specific HTTP Request, traversing all the Request (Request) objects, taking out the value of the path attribute in the Request (Request) attribute, putting the value into the set of packets, de-duplicating, converting the value into the dictionary object a3, each packet is a KEY value in a dictionary, initializing the value corresponding to each KEY into an empty list, namely extracting the parameter set of the HTTP Request in the array object list a1, and assigning the value corresponding to each KEY in the Request element to the parameter set of the HTTP Request in the array object list a1 for optimizing.
Example 6:
in this embodiment, all the Request (Request) objects are traversed, the values of the path attribute in the Request (Request) attribute are taken out and put into the set of packets to be de-duplicated and then converted into dictionary objects, each packet is a KEY value in a dictionary, and the value corresponding to each KEY is initialized to be an empty list. After the Request and the de-duplication of the packet are completed, the corresponding Request (Request) object is put into the corresponding packet. Traversing the object, reading the Path value of the object, adding the object to a list corresponding to the KEY value in the dictionary according to the Path value, and returning to the complete dictionary object after the processing is completed
Example 7:
in this embodiment, as shown in fig. 2, the right part of fig. 2 is a main flow, the left part of fig. 2 is an auxiliary flow, the steps in the main flow need parameters in the auxiliary flow to complete execution, the main flow first leads into a dictionary object, the auxiliary flow is to obtain the grouping configuration of the parameter control object from the parameter control object, generate a grouping name according to the grouping configuration and the imported dictionary object, obtain a corresponding requirement (Request) list under the grouping in the dictionary object according to the generated grouping name, then traverse the requirement (Request) object in the list, obtain the interface AW name generation configuration in the parameter control object at this time, generate the configuration and obtain the generated platform configuration according to the interface AW name, judge whether the dictionary object is finished according to the generated platform configuration and the name of the interface AW of the generated requirement (Request), if yes, finish iteration, splice the generated configuration content and finally finish the next iteration, and if no, continue to iterate.
Example 8:
in this system, as shown in fig. 3, the input parameters required by the file import module 10 are file paths, that is, designated HAR file storage paths, if the file is empty, the file is prompted to be empty, the program exits, if the file content is not in HAR format, the file format is prompted to have a problem and cannot be resolved, and if everything is normal, a complete object list is returned; the main parameters of the user configuration module 11 are also paths for specifying user configuration files, wherein the configuration file content includes a test platform, packet naming logic, interface naming logic, whether to process static file requests, etc.: after the function receives the path of the configuration file of entering the parameter, the control (config) module is used for analyzing, an object configured by a corresponding module is created after the analysis is completed, the configuration is assigned to the attribute of the object, and the attribute of the parameter control (Userconfig) object corresponds to the configuration in the configuration file one by one; the profile transfer user configuration object function is as follows: firstly judging whether a file exists or not, if yes, converting the file into a configer object through a user configuration module 11, sequentially reading out specific configuration, then using the parameters to create a u_config object, taking the u_config object as a function output parameter, returning the u_config object to a caller, and if not, returning an initialization parameter control (Userconfig) object; the file parsing module 12 mainly inputs the object list of the HTTP Request transmitted from the file importing module 10, sequentially processes the original object data included in the list, converts the object data into a custom requirement (Request) class, and assembles each Request into a Request object list as a return value to return; the parameter entering data of the de-duplication grouping module 13 is a standardized request (request) list returned by the file analysis module 12, the path parameter in the request object is first identified, if the path is not repeated, a grouping is added to the grouping list, and meanwhile, a corresponding KEY value is added to the group_request_subject. If repeated, no addition to the packet list is required. Then analyzing whether the method in the request object exists in the KEY value list of the group_request_subject, if not, adding the request object into the list under the corresponding KEY value, and finally returning a grouping request object; the generating module 14 is a core module, and the input parameters thereof include two, one is a parameter control object and the other is a dictionary object. The program analyzes according to parameters of the configuration file, such as a platform, group name configuration and the like, generates a compressed file packet after the analysis is completed, and stores interfaces AW of different platforms under different catalogues, wherein the compressed file packet comprises a plurality of catalogues.
Example 9:
other portions of this embodiment are the same as any of embodiments 1 to 8 described above, and thus will not be described again.
Example 10:
the present embodiment is better described by way of example on the basis of the above embodiments 1-9, taking the first page of the access profile as an example:
inputting a browser address of a profile in a browser;
opening an F12 console, capturing HTTP requests, clicking saveashar (containscontent) on a right key menu on one request, and storing a file name of www.jianshu.com.har;
the parameters in the configuration user profile are as follows, with the file name user_conf.
[UsefConfig]
# you can config plane ,example: postman, cg, jmeter, soapui and etc
plane=postman
# group name struct, example: path, path_as_underline
group_name=path_as_underline
# request_name struct, example :path-method
request_name=path-method
# static: True for all requests contains static ,False only contains XDR
static=false
Placing both the HAR file and the user profile under the aw_generate. Py directory, executing python aw_generate. Py-HAR www.jianshu.com.har-user_config "user_conf. Ini";
filtering a request of an HDR type in HTTP requests which are just grabbed by a browser;
because the configuration file only generates the configuration file of the postman platform and does not generate a static file request, only a psottman folder is generated under an execution directory, and the folder contains two files, namely a request set file and an environment variable file generated by a system;
opening postman, clicking File > import, importing the generated dynamic request set File; clicking environment > imports, and importing the generated environment variable file;
after introduction we see postman interface display: the grouping is named after being spliced by underlining according to the set using path, the request uses path+request method naming, and only the contained hdr request is the same as the configuration of the user;
clicking send and sending a request, and when the acquired information in the corresponding comparison browser is completely consistent, determining that the generated request interface AW is successful and correct.
The foregoing description is only a preferred embodiment of the present invention, and is not intended to limit the present invention in any way, and any simple modification and equivalent variation of the above embodiment according to the technical matter of the present invention falls within the scope of the present invention.

Claims (8)

1. A method of generating a test model based on HAR files, comprising the steps of:
s1, acquiring an initial file a from a browser, judging whether the initial file a exists or not, if so, inputting an initial configuration file b into a preset user configuration file, and entering a step S2, and if not, deleting and re-acquiring the initial file a until entering the step S2;
s2, judging whether the initial file a is in the HAR format, if so, reading the initial file a into an input and output stream for analysis, obtaining an array object list a1 corresponding to the HAR format, analyzing the initial configuration file b, obtaining a corresponding parameter control object b1, if not, reporting an error and returning to the step S1;
s3, analyzing the array object list a1 according to a preset array object optimization rule to obtain a corresponding request object a2;
s4, grouping, de-duplication and induction are carried out on the request object a2 according to a preset de-duplication grouping and induction rule, and a corresponding dictionary object a3 is obtained;
s5, generating an interface AW according to the parameter control object b1 in the step S2 and the dictionary object a3 in the step S4;
the step S5 includes:
s5.1, acquiring grouping configuration information B1 of parameter control according to a parameter control object B1, acquiring generation configuration information B11 of an interface AW in parameter control according to the grouping configuration information B1, and acquiring platform configuration B12 to be generated according to the generation configuration information B11;
s5.2, generating a corresponding dictionary object group A3 according to the group configuration information B1 and the dictionary object A3;
s5.3, acquiring a demand list of the dictionary object group A3 and traversing a demand object A31 in the demand list;
s5.4, generating names of demand interfaces AW according to the generation configuration information B11 of the interfaces AW in parameter control and the demand objects A31;
s5.5, generating interface AW configuration content and grouping configuration content of a corresponding platform according to the name of the required interface AW and the platform configuration B12 to be generated in the step S5.4;
s5.6, judging whether dictionary iteration is finished, if yes, finishing iteration and splicing generated configuration content into a final interface AW, and if no, entering step S5.1.
2. The method of generating a test model based on HAR files according to claim 1, wherein the step S1 comprises: the user configuration file analyzes the input initial configuration file b, judges whether the path of the initial configuration file b is given or is empty, if so, enters step S2, and if not, assigns the default value of the initial attribute in the user configuration file to the initial configuration file b; the initial attributes in the user profile include test platform, packet naming logic, interface naming logic and whether to process static file requests.
3. The method of generating a test model based on HAR files according to claim 1, wherein the step S2 comprises:
s2.1, analyzing an initial configuration file b by using a configuration analysis function, and reading each configuration value in the initial configuration file b;
s2.2, judging whether the value of each configuration is not existed or is empty, if so, using a default value for the attribute of the initialization parameter control object b1, and if not, using the value of each configuration as the parameter of the initialization parameter control object b1;
s2.3, acquiring an initialization parameter control object b1 with assigned values of all the attributes.
4. The method for generating a test model based on HAR file according to claim 1, wherein the preset array object optimization rule in step S3 comprises:
s3.1, defining a demand array object A1, traversing a data list of the demand array object A1, and obtaining demand elements of the demand array object A1;
s3.2, taking out the corresponding values of the KEY in the demand element, and assigning the values to an array object list a1;
s3.3, assembling the array object list a1 to generate a corresponding request object a2, and returning to the step S3.1.
5. The method of generating a test model based on HAR files according to claim 4, wherein the step S3.2 comprises:
s3.2.1, extracting a parameter set of the HTTP request in the array object list a1;
and S3.2.2, assigning values corresponding to the KEYs in the demand elements to the parameter set of the HTTP request in the array object list a1 for optimization.
6. The method of generating a test model based on HAR files according to claim 1, wherein the de-duplication grouping induction rule in step S4 comprises:
s4.1, grouping the request objects A2 to generate a grouping request object A2;
s4.2, performing deduplication on the packet request object A2 to generate a deduplication request object A21;
and S4.3, summarizing the deduplication request object A21 to generate a dictionary object a3.
7. A system for generating a test model based on HAR files, performed according to the method of any of claims 1-6, comprising a file import module (10), a user configuration module (11), a file parsing module (12), a de-duplication grouping module (13) and a generation module (14), wherein:
the file importing module (10) comprises a HAR file judging unit and a user interface module, wherein the HAR file judging unit is used for acquiring an initial file a from a browser, judging whether the initial file a exists or not, if so, inputting an initial configuration file b into a preset user configuration file, entering the HAR file judging unit, and if not, deleting and reacquiring the initial file a until entering the HAR file judging unit;
the user configuration module (11) is used for designating a path of the initial configuration file b, analyzing the initial configuration file b after the configuration analysis function receives the path of the initial configuration file b, analyzing and reading each configured value in the initial configuration file b, and assigning each configured value to the parameter control object b1;
the file analysis module (12) is used for analyzing the data object list a1 according to a preset array object optimization rule to obtain a corresponding request object a2;
the de-duplication grouping module (13) is used for grouping, de-duplication and inducing the request object a2 according to a preset de-duplication grouping and inducing rule to obtain a corresponding dictionary object a3;
a generating module (14) for generating an interface AW according to the parameter control object b1 in step S2 and the dictionary object a3 in step S4.
8. The HAR file-based system of claim 7, wherein the user configuration module (11) comprises: the content of the initial configuration file b comprises a test platform address, grouping naming logic content, interface naming logic content and a static file request processing condition.
CN202111015287.1A 2021-08-31 2021-08-31 Method and system for generating test model based on HAR file Active CN113760757B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111015287.1A CN113760757B (en) 2021-08-31 2021-08-31 Method and system for generating test model based on HAR file

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111015287.1A CN113760757B (en) 2021-08-31 2021-08-31 Method and system for generating test model based on HAR file

Publications (2)

Publication Number Publication Date
CN113760757A CN113760757A (en) 2021-12-07
CN113760757B true CN113760757B (en) 2023-08-22

Family

ID=78792257

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111015287.1A Active CN113760757B (en) 2021-08-31 2021-08-31 Method and system for generating test model based on HAR file

Country Status (1)

Country Link
CN (1) CN113760757B (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109688202A (en) * 2018-12-04 2019-04-26 北京腾云天下科技有限公司 A kind of processing method of interface data, calculates equipment and storage medium at device
CN109977027A (en) * 2019-04-04 2019-07-05 广州市百果园信息技术有限公司 A kind of method, apparatus of performance test, system, equipment and storage medium
CN110337076A (en) * 2019-07-09 2019-10-15 深圳壹账通智能科技有限公司 SMS platform interface test method, device, computer equipment and storage medium
CN110489349A (en) * 2019-09-23 2019-11-22 四川长虹电器股份有限公司 A kind of interface test method based on JSON configuration file
CN111651342A (en) * 2019-03-04 2020-09-11 复旦大学 HTTP interface automation testing framework based on Charles recording session
CN113297086A (en) * 2021-05-31 2021-08-24 马上消费金融股份有限公司 Test case generation method and device, electronic equipment and storage medium

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10091076B2 (en) * 2015-08-25 2018-10-02 Google Llc Systems and methods for configuring a resource for network traffic analysis
US11163672B2 (en) * 2020-01-31 2021-11-02 Salesforce.Com, Inc. Test suite generation from metadata

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109688202A (en) * 2018-12-04 2019-04-26 北京腾云天下科技有限公司 A kind of processing method of interface data, calculates equipment and storage medium at device
CN111651342A (en) * 2019-03-04 2020-09-11 复旦大学 HTTP interface automation testing framework based on Charles recording session
CN109977027A (en) * 2019-04-04 2019-07-05 广州市百果园信息技术有限公司 A kind of method, apparatus of performance test, system, equipment and storage medium
CN110337076A (en) * 2019-07-09 2019-10-15 深圳壹账通智能科技有限公司 SMS platform interface test method, device, computer equipment and storage medium
CN110489349A (en) * 2019-09-23 2019-11-22 四川长虹电器股份有限公司 A kind of interface test method based on JSON configuration file
CN113297086A (en) * 2021-05-31 2021-08-24 马上消费金融股份有限公司 Test case generation method and device, electronic equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
基于私有云的接口平台设计与实现;王东晋;中国优秀硕士学位论文全文数据库 信息科技辑(第1期);I138-939,第21页,第5.4.4节 *

Also Published As

Publication number Publication date
CN113760757A (en) 2021-12-07

Similar Documents

Publication Publication Date Title
US11157512B2 (en) Method and system for replicating data to heterogeneous database and detecting synchronization error of heterogeneous database through SQL packet analysis
CN110109681B (en) Method and system for converting codes between different platforms
CN109344053B (en) Interface coverage test method, system, computer device and storage medium
CN110765639A (en) Electrical simulation modeling method and device and readable storage medium
CN109614329B (en) Software test case aided design method based on interface control file
CN109815112B (en) Data debugging method and device based on functional test and terminal equipment
CN109918310A (en) A kind of Modeling Platform interface test method
CN108984393A (en) A kind of unit testing code automatic generation method and device
CN113297086A (en) Test case generation method and device, electronic equipment and storage medium
CN114416049B (en) Configuration method and device of service interface combining RPA and AI
CN106302604B (en) Data transmission method and device
CN113760757B (en) Method and system for generating test model based on HAR file
CN112965912B (en) Interface test case generation method and device and electronic equipment
JP7346332B2 (en) Database migration method, database migration system, and database migration program
CN113761879A (en) Message format checking method, device and storage medium
CN115297029B (en) Method, device, equipment and medium for testing resolution performance of industrial internet identification
CN1115628C (en) Software simulation test method
CN116166533A (en) Interface testing method, device, terminal equipment and storage medium
CN112311679B (en) State detection method, state detection device, electronic equipment and readable storage medium
CN115114114A (en) Data report generation method and device in online file feeding mode and related equipment
CN114661298A (en) Automatic public method generation method, system, device and medium
CN114490892A (en) Data transmission method and device based on datax
CN112015645A (en) Function test method and device of web system and electronic equipment
CN116756050B (en) MBSE-based inertial product use case analysis method, system and storage medium
CN117349267B (en) Database migration processing method and system

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
GR01 Patent grant
GR01 Patent grant