CN106919509A - A kind of client generation method, device and electronic equipment - Google Patents

A kind of client generation method, device and electronic equipment Download PDF

Info

Publication number
CN106919509A
CN106919509A CN201710138310.3A CN201710138310A CN106919509A CN 106919509 A CN106919509 A CN 106919509A CN 201710138310 A CN201710138310 A CN 201710138310A CN 106919509 A CN106919509 A CN 106919509A
Authority
CN
China
Prior art keywords
file
test
client
information
data
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.)
Granted
Application number
CN201710138310.3A
Other languages
Chinese (zh)
Other versions
CN106919509B (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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201710138310.3A priority Critical patent/CN106919509B/en
Publication of CN106919509A publication Critical patent/CN106919509A/en
Application granted granted Critical
Publication of CN106919509B publication Critical patent/CN106919509B/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

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

This application provides a kind of client generation method, device and electronic equipment, when a certain test client is needed, common portion is pulled out to obtain corresponding client template file, afterwards, will be according to preset requirement by its thrifit file translations into test data file and test scene file, so, user can be according to test needs, test data is filled in the test data file, and corresponding test interface certificate parameter is filled in the test scene file, so as to change interface document according to preset data, client template file and compilation script template file, using the target detection data file and target detection document scene that obtain, automatically generate the executable file of test client, obtain test client.As can be seen here, the application utilizes template file, it is not necessary to write test client according to different test scenes, it is only necessary to which user fills in some data of needs, greatly reduces workload, improves operating efficiency.

Description

A kind of client generation method, device and electronic equipment
Technical field
Present application relates generally to field of computer technology, more particularly to a kind of client generation method, device And electronic equipment.
Background technology
Thrift is a kind of service arrangement framework across language, by an intermediate language such as IDL IDL (Interface Definition Language) come define RPC (Remote Procedure Call Protocol, remotely The invocation of procedure) interface and data type, some server-side code files and the visitor of corresponding language are then generated by compiler Family end code file, so that compiling obtains the executable program of service end and client in the case of needs, satisfaction is actually needed.
Based on this, when needing to test RPC service interface capability and function, prior art is typically for specific RPC service, writing corresponding client code according to Thrift document definitions carries out performance and functional test, and this is resulted in , it is necessary to write one-to-one client code under different test scenes, the performance and function that can just carry out RPC service are surveyed Examination, workload is very big, relatively costly and testing efficiency is relatively low.
The content of the invention
In view of this, the invention provides a kind of client generation method, device and electronic equipment, using the mould of client Plate file, by configuring the test scene and test data of needs, realizes the configuration to template file, obtains corresponding client End executable file, with very strong durability, reduces client code and writes workload, improves client generation effect Rate.
To achieve these goals, this application provides following technical scheme:
A kind of test client generation method, methods described includes:
The thrift files that acquisition is write for test client;
According to preset requirement by the thrift file translations into test data file and test scene file;
Using the configuration file for the test client for obtaining, to the test data file and the checkout area Scape file is configured, and obtains target detection data file and target detection document scene, wherein, the configuration file includes The test data of the test function for the test client filled in, and realize that the test interface of the test function is tested Card parameter;
Interface document and default client template file are changed according to preset data, using the target detection data file With the target detection document scene, test client file is generated.
The embodiment of the present application additionally provides a kind of test client generating means, and described device includes:
File obtains module, for obtaining the thrift files write for test client;
File translations module, for according to preset requirement by the thrift file translations into test data file and survey Examination document scene;
File destination configuration module, for using the configuration file for the test client for obtaining, to the survey Examination data file and the test scene file are configured, and obtain target detection data file and target detection scene text Part, the configuration file includes the test data of the test function for the test client filled in, and realizes described The test interface certificate parameter of test function;
File generating module, for changing interface document and default client template file according to preset data, using institute Target detection data file and the target detection document scene are stated, test client file is generated.
The embodiment of the present application additionally provides a kind of electronic equipment, including test client generating means as described above.
As can be seen here, compared with prior art, set this application provides a kind of client generation method, device and electronics It is standby, when a certain test client is needed, common portion is pulled out to obtain corresponding client template file, afterwards, will According to preset requirement by its thrifit file translations into test data file and test scene file, then, user can be with root Needed according to test, test data is filled in the test data file, and corresponding test is filled in the test scene file Interface certificate parameter, so as to change interface document, client template file and compilation script template file according to preset data, Using the target detection data file and target detection document scene that obtain, the executable file of test client is automatically generated, Obtain test client.As can be seen here, the application utilizes template file, it is not necessary to write test visitor according to different test scenes Family end, it is only necessary to which user fills in some data of needs, greatly reduces workload, improves operating efficiency.
Brief description of the drawings
In order to illustrate more clearly about the embodiment of the present invention or technical scheme of the prior art, below will be to embodiment or existing The accompanying drawing to be used needed for having technology description is briefly described, it should be apparent that, drawings in the following description are only this Inventive embodiment, for those of ordinary skill in the art, on the premise of not paying creative work, can also basis The accompanying drawing of offer obtains other accompanying drawings.
A kind of flow chart of test client generation method that Fig. 1 is provided for the embodiment of the present application;
The flow chart of another test client generation method that Fig. 2 is provided for the embodiment of the present application;
A kind of structured flowchart of test client generating means that Fig. 3 is provided for the embodiment of the present application;
The structured flowchart of another test client generating means that Fig. 4 is provided for the embodiment of the present application;
The structured flowchart of another test client generating means that Fig. 5 is provided for the embodiment of the present application;
The structured flowchart of another test client generating means that Fig. 6 is provided for the embodiment of the present application;
The hardware structure diagram of a kind of electronic equipment that Fig. 7 is provided for the embodiment of the present application.
Specific embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out clear, complete Site preparation is described, it is clear that described embodiment is only a part of embodiment of the invention, rather than whole embodiments.It is based on Embodiment in the present invention, it is every other that those of ordinary skill in the art are obtained under the premise of creative work is not made Embodiment, belongs to the scope of protection of the invention.
In actual applications, thrift system architectures are generally all to realize customer end/server mode, by code building Instrument (i.e. hereafter compilation tool), server end and client code (can be different language) are generated by Interface Definition Document, So as to realize the support of service end and client across language.Also, user can state the service of oneself in Thirft files, These service the code file by that can generate corresponding language after compiling, and then user realizes service (client call service, clothes Business device end proposes service) just can be with.
Wherein, Thrift type systems can include predefined fundamental type, User Defined structure, Container Type, Exception and service definition, the content on thrift files are referred to the description of hereafter appropriate section, and the present embodiment is herein not It is described further.
Also, structure can be made up of a series of domains, there is a unique integer identifier in each domain, type, name and optional Default parameter composition, there is unique, a positive integer identifier in each domain, each domain can be designated required or optional.And, definable multiple structure in a thrift, and there is adduction relationship, structure can include other Structure
In this application, each domain in the struct definition of specification can be crucial using required or optional Word is identified.If the domain of required marks does not have assignment, thrift will give and point out.If the domain of optional marks There is no assignment, the domain will not be serialized transmission;If certain optional identification field has default value and user is no again Assignment, then the value in the domain is always default value.
In order that the above objects, features and advantages of the present invention can be more obvious understandable, below in conjunction with the accompanying drawings and specifically The present invention is further detailed explanation for implementation method.
Reference picture 1, is a kind of flow chart of test client generation method that the embodiment of the present application is provided, and the method can be with Realized by compilation tool, the application is not construed as limiting to the content of the compilation tool, and the method may comprise steps of:
Step S11, the thrift files that acquisition is write for test client;
In the present embodiment, when needing to write a test client, the thrift files can define test visitor Communication interface that family end is communicated with server or other clients and communication rule etc., the application is to the thrift files Specific generating mode and comprising particular content be not construed as limiting.
It should be noted that the different test clients obtained for test scene or same test client are not Same demand for services, the thrift files for being generated can be with difference.
Optionally, in actual applications, the code file that default thrift files can be as follows, but not office It is limited to this:
From above-mentioned code file, structure struct and service interface service is included in thrift files Two parts, but be not limited to, and the structure that includes of the thrift files and service interface relevant information can bases Determine the need for test scene, it may also be said to be that the test function for needing the test client write to realize determines, this Shen Please this is not described further.
Thrift file translations are the pending file of preset data DIF by step S12;
Optionally, the present embodiment can determine the pending file, i.e. preset data exchange lattice using json definition modes Formula can be json definition, but be not limited thereto.
Wherein, json is a kind of data interchange format of lightweight, with the good readable and spy for being easy to quickly write Property, data exchange can be carried out between different platform;All it is compression due to the form, occupied bandwidth is small, it would be preferable to support many Language is planted, and directly for server-side code is used can enormously simplify the code development quantity of server end and client.
Based on this, still by taking thrift files given above as an example, the present embodiment can be translated into json (JavaScript Object Notation) is defined, code file as follows:
By the code content of above-mentioned pending file, may directly learn that it can fill in test data and corresponding clothes Business interface message etc., the application is not described in detail here.
Step S13, obtains the structure information and service interface information defined in pending file;
In the present embodiment, the knot in structure information and service interface information and thrift files in pending file Structure body information and service interface information correspondence are identical, and both are the representation in pending file and thrift files Or describing mode is different.
Enumerate implementation and illustrate with above-mentioned, the structure information in above-mentioned thrift files can include above-mentioned code The relevant information of the HeartBeatInfo in file, service interface information can be included in above-mentioned code file , it is necessary to explanation, the struct and service of thrift files are not limited to above-mentioned for the relevant information of BaseService The content that code file is recorded, is different for the thrift files needed for the different clients to be generated in actual applications , corresponding struct and service contents are also different, and the application is not described in detail one by one herein.
Correspondingly, in the pending file that conversion process is obtained is carried out to thrift files, the structure letter that it is included Breath can be the relevant information in " structs " in the code file of above-mentioned pending file, and service interface information is then " Relevant information in services ", structure information and the tool of service interface information that the application is included to pending file Hold in vivo and do not describe in detail one by one.
Step S14, generates test data file, and generate test scene using service interface information using structure information File.
In this application, the complicated type defined in thrift files can be converted to XML (Extensible Markup Language, extensible markup language) description data definition, to carry out subsequent operation, as described above, can By thrift file translations as pending file, to be reconverted into XML it should be noted that basic in for thrift files Data type can be filled in directly in xml, it is not necessary to launch description.
In this application, test data file can be the self-defined xml Data Definitions Files of thrift files conversion, use Test data is filled in user, test scene file can also be the XML file for defining test scene and interface checking, for using Fill in test interface certificate parameter in family.Wherein, filling in data content can be true according to the test request of specific RPC service Fixed, the application is not described in detail here.
As can be seen here, the application fills in the template file i.e. test data of test data by the way that thrift files are converted to File, and the template file i.e. test scene file of test interface certificate parameter is filled in, user can be according to actual test The requirement of scape, respective file fills in corresponding data content in currently displaying test data file and test scene file, letter Folk prescription just, is solved in the prior art, client is being write using the interface of thrift file translations, to test scene, test Data and checking data do not specify unified rule, are difficult to make user understand and interactive technical problem.
Step S15, the test data that detection user is input into according to the test data file for test client, and press According to the test interface certificate parameter that test scene file is input into for test client;
Analyze as described above, test data file and test scene file are all template files, and user can be according to this survey The need for the scape of examination hall, test data and corresponding test interface certificate parameter needed for input.
Wherein, structure information about firms belongs to basic data type information in test data file, that includes basic The rule change of data type information.
Step S16, using the test data configuration testing data file for detecting, obtains target detection data file, and Using the corresponding test interface certificate parameter configuration testing document scene for detecting, target detection document scene is obtained;
Step S17, interface document, and the master data defined in target detection data file are changed using preset data Change of types rule, generates target data rule change file;
Learnt according to the analysis above to test data file, the change of basic data type is included in test data file Change rule, so, it is determined that after target detection data file, can therefrom extract all basic data type rule change letters Breath, and default data variation interface document is combined, generate target data rule change file.
Optionally, in actual applications, can be by traveling through the structure information in target detection data file, if it is tied The datareg attributes of structure body member are defined, and the parameter of the corresponding interface is called to the knot from preset data change interface document The datareg attribute assignments of structure body member;If the datareg attributes are not defined, the value that can be filled in using user is to it Carry out assignment.Afterwards, the master data rule change defined in target detection data file, generation target data change are recycled Rule file.
In the present embodiment, target data rule change file can be used to carry out more the test data in test client New and initialization, that is to say, that when test client runs, as needed can be from the target data rule change file The rule change of corresponding interface is transferred, test data is obtained, concrete application process is not construed as limiting.
Step S18, using target detection data file and target detection document scene, according to default client's Side Template text Part, obtains test client file;
In the present embodiment, by traveling through each Service interface definition in target detection document scene, each can be obtained The return value of interface, function name attribute, call number, parameter, call back function type, the information such as whether verify, so as to according to this A little information are inserted directly into call back function information, interface interchange information in the corresponding region of default client template file, are used The test client file of family definition.
Wherein, it can be by the executable file to this kind of test client or compiling text to preset client template file Part carries out Commonness Analysis, so as to pull out the total part of test client, generates template file.So, test scene is worked as Compare many, i.e., RPC service it is diversified in the case of, it is not necessary to write test client one by one, it is only necessary to which user is filled in for each The test data of test scene and its corresponding service interface checking information, you can the different test clients of generation, it is simple and Aspect, reduces client and writes cost, improves client formation efficiency.
Step S19, using default compilation script template file and the test client file, according to the target data Rule change file, compiling obtains the executable file of the test client;
Step S110, performs the executable file of test client, obtains the test result of the test client.
In this application, test client file is utilized by compilation tool, replaces or fill in default compilation script template File, generates the executable file of test client, to realize the test function of test client, obtains test result.Also, Test result can be exported according to actual needs, and/or test result is verified, so as to export phase according to the result The prompt message answered.
, wherein it is desired to explanation, how the application is to using compilation script compiling to obtain the specific reality of executable file Existing method is not construed as limiting.
To sum up, for any specific RPC service, enter test client is write using the interface of thrift document definitions When row performance is with functional verification, the application need not write whole test client code, to obtain holding for test client Style of writing part, but utilize test client template file, by user directly according to test scene the need for, directly in thrift Test data file that file translations are obtained and fill in corresponding data in test scene file, you can automatic compiling is tested The executable file of client, it is simple and convenient with very strong durability, workload is greatly reduced, improve test effect Rate.
As shown in Fig. 2 the flow chart of another test client generation method provided for the embodiment of the present application, as described above Embodiment is identical, and the present embodiment can be realized by compilation tool, specifically be may comprise steps of:
Step S21, the thrift files that acquisition is write for test client;
The filename of the thrift files for test client that in the present embodiment, user can be filled in, The information solicitations such as name space, Service name, the thrift file paths of thrift files to compilation tool configuration file, this Sample, compilation tool can obtain corresponding thrift files according to these contents of the configuration file, realize to test client Automatic compiling.
Thrift file translations are the pending file of preset data DIF by step S22;
Step S23, obtains the structure information and service interface information defined in pending file;
Step S24, is processed structure information using default definition rule, obtains corresponding structure member letter Breath;
Optionally, in the present embodiment, for the structure information for obtaining, the knot of each structure that can there will be Structure body member launches and as node arranged side by side successively, and structure member variable name is referred to as into respective nodes name.
Wherein, the application is not construed as limiting to the particular content that the structure information about firms for obtaining is included, and can include data Type, index, rule change etc..
Step S25, detects whether the structure information about firms for determining belongs to basic data type information, if not, returning Step S24;If it is, into step S26;
In this application, it is thus necessary to determine that resulting structures body information about firms no longer includes structure, belongs to master data Type, such as short short, integer int, long long, single float, double double and character type Type char etc., to ensure being smoothed out for subsequent step.
After described above, during structure launched into the structure member for obtaining, if still including structure, can be according to upper The mode of stating continue launch, until resulting structures body member be untill structure body node is all basic data type.
Step S26, extracts the basic data type information for meeting the first preset requirement, generates test data file;
Wherein, the particular content that the first preset requirement is included can be according to the specific test of the test client that will be write It needs to be determined that, that is to say, that according to different test scene needs, the content of identified first preset requirement can with difference, And then the basic data type information extracted is also just different, test data file is different obtained from, and the application is to first The particular content that preset requirement is included is not construed as limiting.
Still illustrated by taking the thrift files that above-described embodiment is given as an example, by above-mentioned code file it is known that should Thrift files include a structure HeartBeat, according to the above-mentioned processing procedure to structure information, can obtain as follows Described test data file, i.e., self-defined XML data defines file, so that user fills in required test data.Wherein, should Test data file can be:
From the code content of test data file given above, it believes with the structure in above-mentioned pending file Breath content it is basically identical, thus, the application by thrift file translations be json files after, can be by its file content Parsed, obtained required test data file.
It should be noted that in order to meet different test needs, when the basic data type information content of extraction is different, Gained test data file also can accordingly change, it is not limited to above-described code file.
Wherein, in above-mentioned code file, datareg represents basic data type rule change, is such as incremented by, and successively decreases, at random, It is constant etc., for producing test data according to the rule change;Index represents rope of the structure member variable in structure Draw;Optional represents whether structure member chooses, the require with structure member variable in thrift files, Optional represents that implication is consistent;Type represents the data type of structure member.
Step S27, according to service interface information, determines remote procedure call interface information and corresponding interface checking letter Breath;
In the present embodiment, can service interface information be information that above-mentioned " services " is included from pending file In, determine the i.e. all RPCList nodes of all remote procedure call interface information that it is included, and total interface checking information I.e. all CheckList nodes, wherein, it is one-to-one between RPCList nodes and CheckList nodes.
Optionally, above-mentioned remote procedure call interface information can include interface requests transmission order, interface parameters sequentially And type label, interface interchange number of times, interface name, interface return type etc., then interface checking information can include checking The validation value of interface, checking interface name, whether verify and interface return type etc..The application is to above-mentioned remote procedure call The particular content that interface message and corresponding interface checking information are included is not construed as limiting.
Step S28, extracts remote procedure call interface information and corresponding the interface checking for meeting the second preset requirement Information, generates test scene file;
It should be noted that second preset requirement can be corresponding with above-mentioned first preset requirement, both for reality What existing same test purpose determined, the application is not construed as limiting to the particular content that it is included, in actual applications, second it is default will Asking can be with identical with the first preset requirement, it is also possible to different.
Still illustrated by taking the above-mentioned thrift files enumerated as an example, the test scene file for obtaining in the manner described above can To be following code file, but it is not limited thereto:
In above-mentioned code file, each RPCList nodes can be test scene definition, and child node order is interface requests Transmission sequentially, wherein, args represent interface parameters order and type label;Call_num represents interface interchange number of times;Func tables Show interface name;Return_type represents interface return type.And each CheckList nodes in the code file can be Interface checking definition, wherein, check_args represents the validation value of checking interface;Func represents checking interface name;is_check Indicate whether checking;Return_type represents interface return type.
It should be noted that when the second preset requirement is different, the remote procedure call interface information and correspondence of extraction Interface checking information it is different, i.e., the field extracted from service interface information is different, so that in the test scene file of generation Hold different, that is, to generate RPC nodes differences, the application is only illustrated by taking above-mentioned code file as an example herein.
Step S29, detects the test data and test interface and certificate parameter of user input, configures corresponding test data File and test scene file, obtain target detection data file and target detection document scene;
In the application practical application, after obtaining test data file and test scene file in the manner described above, Gained test data file and test scene file can be exported, now, user only needs to fill in this in file blank position Test data needed for secondary generation client, and test interface and certificate parameter, it is not necessary to write whole test data file And test scene file, it is very convenient.
Still illustrated by taking test data file given above and test scene file as an example, when needs are to each interface When being tested, and test result being verified, user can accordingly fill in id in the above-mentioned test data file for being given, The information such as version, address and comment.
The need for according to above-mentioned test scene, the test data of needs can be filled in above-mentioned test data file, such as Initialize the two structure information about firms of id and address in the structure variable of HeartBeatInfo, i.e. id datareg =" random ", i.e., id is generated at random;5 characters that address datareg=" static_5 ", i.e. address are fixed.Its In, the code file of the target detection data file after being filled in for user, the application is no longer enumerated herein.
Similarly, the need for user can be according to test scene, test scene file service interface message, such as RPC are filled in Args1.i64=" 1 ", RPC args1.enum.TestSeq=" TestID_1 ", RPC args1.string=" test_ Bool ",<RPC args1.byte=" 0x01 ",<RPC args1.i32=" 2 ",<RPCargs1.double=" 3.14 ",< RPC check_args=" 1 ",<RPC check_args=" TestID_2 ",<RPC check_args=" true ",<RPC Check_args=" 0x02 ",<RPC check_args=" hello ",<RPC check_args=" 3.14 ".For filling in Code content the present embodiment of target detection document scene afterwards will not be repeated here.
It can be seen from above-mentioned each code file, test scene have invoked heartbeat, test_enum, test_ successively Complex, test_byte, test_string and test_double interface are each once, and fill in corresponding parameter, and The structure variable defined in test data file is used, simultaneously as the application needs to call total interface return to tie Really verified, also fill in the value of check_char in the i.e. above-mentioned code file of validation value of each interface, but be not limited to The content that above-mentioned code file is recorded.
S210, interface document, and the master data class defined in target detection data file are changed using preset data Type rule change, generates target data rule change file;
Still illustrated by taking the corresponding code file of target detection data file that above-mentioned user fills in as an example, extract its bag The basic data type rule change for including, the target data rule change file of generation can be code file as follows, But it is not limited to the code file.
Optionally, in actual applications, can be believed by traveling through each structure of target detection data file member Breath is basic data type information, detects in the basic data type information and whether there is to basic data type rule change Definition, if in the presence of, using definition basic data type rule change, call the corresponding interface and to its assignment;If not existing, can Assignment is carried out to the corresponding interface according to types of variables and initial value with by user, so that it is determined that corresponding target data change rule Then file.
It should be noted that the application is not construed as limiting to the specific generating process of target data rule change file.
Step S211, parses target detection data file and target detection document scene, it is determined that corresponding call back function Information and interface interchange information.
It should be noted that the application is to parsing test data file and test scene file, it is determined that corresponding readjustment The implementation method of the code file of function and interface interchange function is not construed as limiting, and call back function and interface for obtaining Content the present embodiment of the code file of call function is not described in detail here.
Step S212, the call back function information that will be obtained and the default client template file of scene recalls information insertion, Obtain test client file;
Step S213, using default compilation script template file and the test client file, according to the number of targets According to rule change file, compiling obtains the executable file of test client;
In actual applications, in order to realize the test of test scene, user can be according to actual test needs, will be for surveying The performance test parameter for trying client is added in above-mentioned configuration file, so that test client is based on these performance test parameters Operation, and complete the test assignment of test scene.
Wherein, performance test parameter can include connected mode, connection quantity, transmission rate, number of requests, measurement period Etc., the application is not construed as limiting to this, can according to actual test it needs to be determined that, the application is no longer described in detail one by one herein.
Step S214, performs the executable file of test client, obtains test result.
Based on above-mentioned analysis, the application only needs to the related data that user fills in present test field scape needs, it is not necessary to compile Write the code of whole test client to obtain executable file, greatly reduce written in code workload, improve work effect Rate.
As shown in figure 3, the embodiment of the present application provides a kind of structured flowchart of test client generating means, the device can To include:
File obtains module 31, for obtaining the thrift files write for test client;
File translations module 32, for according to preset requirement by the thrift file translations into test data file and Test scene file;
In the present embodiment, in the test data file and test scene file obtained on thrift files and its conversion Hold, be referred to the description of above method embodiment corresponding part, the present embodiment will not be described in detail herein.
File destination configuration module 33, for using the configuration file for the test client for obtaining, to described Test data file and the test scene file are configured, and obtain target detection data file and target detection scene text Part;
Wherein, configuration file includes the test data of the test function for the test client filled in, Yi Jishi The test interface certificate parameter of the existing test function;
File generating module 34, for changing interface document and default client template file according to preset data, utilizes The target detection data file and the target detection document scene, generate test client file.
In the present embodiment, for the data message filled according to user, test client file, above-mentioned text are automatically generated Part collector 34 can include:
Rule file generation unit, for using the basic data type change defined in the target detection data file Rule and preset data change interface document, generate target data rule change file;
Test client file obtaining unit, for utilizing the target detection data file and the target detection scene File, according to default client template file, obtains test client file.
In this embodiment, the test client file obtaining unit can include:
Parsing subelement, for parsing the target detection data file and the target detection document scene, it is determined that Corresponding call back function information and interface interchange information;
Information is embedded in subelement, for the call back function information that will be obtained and interface interchange information insertion institute The default template file of client is stated, test client file is obtained.
Wherein, the specific generating process of test client file is referred to above method embodiment pair in above-described embodiment The description of part is answered, the present embodiment will not be repeated here.
As another embodiment of the application, on the basis of above-described embodiment, after obtaining test client file, Ke Yitong Compiler is crossed, compiling obtains corresponding executable file, so, as shown in figure 4, device can also include:
File collector 35, for using default compilation script template file and the test client file, compiling Obtain the executable file of the test client;
Test module 36, for performing the test executable file, obtains the test result of the test client
Optionally, as shown in figure 5, this document conversion module 32 can include:
First file generating unit 321, for using the structure information defined in the thrift files, generation test Data file;
Second file generating unit 322, for using the service interface information defined in the thrift files, generation to be surveyed Examination document scene.
In the present embodiment, as shown in fig. 6, first file generating unit 321 can include:
Information process unit 3211, is entered using default definition rule to the structure information defined in the thrift files Row treatment, obtains corresponding structure information about firms;
Detection unit 3212, for detecting whether the structure information about firms for determining belongs to basic data type letter Breath;If not, triggering described information processing unit continues to believe being not belonging to basic data type using the default definition rule The structure information about firms of breath is processed, until the structure information about firms that the detection unit is obtained is belonged to substantially Data type information;
First information extraction unit 3213, the basic data type information of the first preset requirement, generation are met for extracting Test data file.
In addition, reference picture 6, the second file generating unit 322 can include:
Information determination unit 3221, for using the service interface information defined in the thrift files, it is determined that remotely Calling interface information and corresponding interface checking information;
Second information extraction unit 3222, the far call interface message of the second preset requirement and right is met for extracting The interface checking information answered, generates test scene file.
In sum, when the test for needing to realize certain RPC service, when writing corresponding test client, the present embodiment will By client template file, required test data and its corresponding service interface checking information is directly filled in by user, And the configuration for realizing accordingly to client template file, required test client is obtained, and then complete to RPC service The checking of performance and function, it is not necessary to which user writes the code file of whole test client, greatly reduces workload, carries Testing efficiency high.
The embodiment of the present application additionally provides a kind of electronic equipment, and it can include the test as described in above-mentioned device embodiment Client generating means, structure and its function are constituted on it, are referred to the description of said apparatus embodiment, and the present embodiment exists This is no longer described in detail.
Wherein, in actual applications, electronic equipment can be specifically that computer, industrial computer etc. can load setting for compilation tool Standby, the application is not construed as limiting to the specific product type of the electronic equipment.
As shown in fig. 7, the hardware block diagram of a kind of electronic equipment that the embodiment of the present application is also provided, the system can be wrapped Include:Processor 71, memory 72, display 73, communication interface 74 and communication bus 75;
Wherein, processor 71, memory 72, display 73 and communication interface 74 are completed each other by communication bus 65 Communication.
Optionally, the communication interface 74 can be USB interface or other serial ports etc..
Processor 71, for configuration processor;
Memory 72, the various data etc. for depositing program and acquisition;
Display 73, is displayed for the performance test results and test process etc.;
In the present embodiment, the processor 71 can be central processor CPU, or specific integrated circuit ASIC (Application Specific Integrated Circuit), or be arranged to implement the one of the embodiment of the present invention Individual or multiple integrated circuits.
Memory 72 can include high-speed RAM memory, it is also possible to also including nonvolatile memory (non-volatile Memory), for example, at least one magnetic disk storage etc..
Wherein, said procedure can be specifically for:
The thrift files that must be write for test client;
According to preset requirement by the thrift file translations into test data file and test scene file;
Using the configuration file for the test client for obtaining, to the test data file and the checkout area Scape file is configured, and obtains target detection data file and target detection document scene, and the configuration file includes filling in The test function for the test client test data, and realize the test function test interface checking ginseng Number;
Interface document and default client template file are changed according to preset data, using the target detection data file With the target detection document scene, test client file is generated.
Using default compilation script template file and the test client file, compiling obtains the test client Executable file;
The executable file of the test client is performed, the test result of the test client is obtained.
To sum up, the present embodiment utilizes reusable template file, and the number for present test field scape is directly filled in by user According to, you can obtain test client, it is not necessary to compile the code of whole test client, greatly reduce workload, improve Testing efficiency.
Furthermore, it is necessary to explanation, on the various embodiments described above in, such as first, second or the like relational terms are only Only it is used for operating an operation, unit or module with another, unit or module make a distinction, and not necessarily requires or secretly Show between these units, operation or module there is any this actual relation or order.And, term " including ", " bag Containing " or any other variant thereof is intended to cover non-exclusive inclusion, so that process, method including a series of key elements Or system not only includes those key elements, but also other key elements including being not expressly set out, or also include being this Process, method or the intrinsic key element of system.In the absence of more restrictions, being limited by sentence "including a ..." Key element, it is not excluded that also there is other identical element in the process including the key element, method or system.
Each embodiment is described by the way of progressive in this specification, and what each embodiment was stressed is and other The difference of embodiment, between each embodiment identical similar portion mutually referring to.For device disclosed in embodiment For, because it is corresponding with method disclosed in embodiment, so description is fairly simple, related part is referring to method part illustration .
Professional further appreciates that, with reference to the unit of each example of the embodiments described herein description And algorithm steps, can be realized with electronic hardware, computer software or the combination of the two, in order to clearly demonstrate hardware and The interchangeability of software, generally describes the composition and step of each example according to function in the above description.These Function is performed with hardware or software mode actually, depending on the application-specific and design constraint of technical scheme.Specialty Technical staff can realize described function to each specific application using distinct methods, but this realization should not Think beyond the scope of this invention.
The step of method or algorithm for being described with reference to the embodiments described herein, directly can be held with hardware, processor Capable software module, or the two combination is implemented.Software module can be placed in random access memory (RAM), internal memory, read-only deposit Reservoir (ROM), electrically programmable ROM, electrically erasable ROM, register, hard disk, moveable magnetic disc, CD-ROM or technology In field in known any other form of storage medium.
The foregoing description of the disclosed embodiments, enables professional and technical personnel in the field to realize or uses the present invention. Various modifications to these embodiments will be apparent for those skilled in the art, as defined herein General Principle can be realized in other embodiments without departing from the spirit or scope of the present invention.Therefore, the present invention The embodiments shown herein is not intended to be limited to, and is to fit to and principles disclosed herein and features of novelty phase one The scope most wide for causing.

Claims (14)

1. a kind of test client generation method, it is characterised in that methods described includes:
The thrift files that acquisition is write for test client;
According to preset requirement by the thrift file translations into test data file and test scene file;
Using the configuration file for the test client for obtaining, to the test data file and test scene text Part is configured, and obtains target detection data file and target detection document scene, wherein, the configuration file includes filling in The test function for the test client test data, and realize the test function test interface checking ginseng Number;
Interface document and default client template file are changed according to preset data, using the target detection data file and institute Target detection document scene is stated, test client file is generated.
2. method according to claim 1, it is characterised in that it is described according to preset requirement by the thrift file translations Into test data file and test scene file, including:
Using the structure information defined in the thrift files, test data file is generated;
Using the service interface information defined in the thrift files, test scene file is generated.
3. method according to claim 1, it is characterised in that described that interface document and default visitor are changed according to preset data Family Side Template file, using the target detection data file and the target detection document scene, generation test client text Part, including:
Using the basic data type rule change defined in the target detection data file and preset data change interface File, generates target data rule change file;
Using the target detection data file and the target detection document scene, according to default client template file, obtain Obtain test client file.
4. method according to claim 1, it is characterised in that methods described also includes:
Using default compilation script template file and the test client file, compiling obtains holding for the test client Style of writing part;
The executable file of the test client is performed, the test result of the test client is obtained.
5. method according to claim 2, it is characterised in that the structure using defined in the thrift files Information, generates test data file, including:
The structure information defined in the thrift files is processed using default definition rule, obtains corresponding structure Body information about firms;
Detect whether the structure information about firms for determining belongs to basic data type information;
If not, continuing to enter the structure information about firms for being not belonging to basic data type information using the default definition rule Row treatment, until the structure information about firms for obtaining belongs to basic data type information;
If it is, extracting the basic data type information for meeting the first preset requirement, test data file is generated.
6. method according to claim 2, it is characterised in that the service using defined in the thrift files connects Message ceases, and generates test scene file, including:
Using the service interface information defined in the thrift files, far call interface message and corresponding interface are determined Checking information;
The far call interface message and corresponding interface checking information for meeting the second preset requirement are extracted, test scene is generated File.
7. method according to claim 3, it is characterised in that described to utilize the target detection data file and the mesh Mark test scene file, according to default client template file, obtains test client file;, including:
Parse the target detection data file and the target detection document scene, it is determined that corresponding call back function information And interface interchange information;
The call back function information that will be obtained and the interface interchange information are embedded in the default template file of the client, Obtain test client file.
8. method according to claim 1, it is characterised in that turn the thrift files according to preset requirement described Before chemical conversion test data file and test scene file, methods described also includes:
It is the pending file of preset data DIF by the thrift file translations.
9. a kind of test client generating means, it is characterised in that described device includes:
File obtains module, for obtaining the thrift files write for test client;
File translations module, for according to preset requirement by the thrift file translations into test data file and checkout area Scape file;
File destination configuration module, for using the configuration file for the test client for obtaining, to the test number Configured according to file and the test scene file, obtained target detection data file and target detection document scene, institute Stating configuration file includes the test data of the test function for the test client filled in, and realizes the test work( The test interface certificate parameter of energy;
File generating module, for changing interface document and default client template file according to preset data, using the mesh Mark test data file and the target detection document scene, generate test client file.
10. device according to claim 9, it is characterised in that the file translations module includes:
First file generating unit, for using the structure information defined in the thrift files, generation test data text Part;
Second file generating unit, for using the service interface information defined in the thrift files, generating test scene File.
11. devices according to claim 9, it is characterised in that described device also includes:
File collector, for using default compilation script template file and the test client file, compiling to obtain institute State the executable file of test client;
Test module, for performing the test executable file, obtains the test result of the test client.
12. devices according to claim 10, it is characterised in that first file generating unit includes:
Information process unit, is processed the structure information defined in the thrift files using default definition rule, Obtain corresponding structure information about firms;
Detection unit, for detecting whether the structure information about firms for determining belongs to basic data type information;If not, Triggering described information processing unit continues the structure to being not belonging to basic data type information using the default definition rule Information about firms is processed, until the structure information about firms that the detection unit is obtained belongs to basic data type letter Breath;
First information extraction unit, the basic data type information of the first preset requirement is met for extracting, and generates test data File.
13. devices according to claim 10, it is characterised in that second file generating unit includes:
Information determination unit, for using the service interface information defined in the thrift files, determining far call interface Information and corresponding interface checking information;
Second information extraction unit, the far call interface message and corresponding interface of the second preset requirement are met for extracting Checking information, generates test scene file.
14. a kind of electronic equipment, it is characterised in that including the test client life as described in claim 9~13 any one Into device.
CN201710138310.3A 2017-03-09 2017-03-09 Client generation method and device and electronic equipment Active CN106919509B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710138310.3A CN106919509B (en) 2017-03-09 2017-03-09 Client generation method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710138310.3A CN106919509B (en) 2017-03-09 2017-03-09 Client generation method and device and electronic equipment

Publications (2)

Publication Number Publication Date
CN106919509A true CN106919509A (en) 2017-07-04
CN106919509B CN106919509B (en) 2020-11-24

Family

ID=59461530

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710138310.3A Active CN106919509B (en) 2017-03-09 2017-03-09 Client generation method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN106919509B (en)

Cited By (20)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108052320A (en) * 2017-12-11 2018-05-18 上证所信息网络有限公司 A kind of method that binary structure body is converted to JSON objects
CN108509337A (en) * 2018-03-15 2018-09-07 链家网(北京)科技有限公司 The dynamic testing method and device called based on interface
CN108614776A (en) * 2018-05-04 2018-10-02 艺龙网信息技术(北京)有限公司 Across the dynamic fixing method and system of language protocol test request
CN108614770A (en) * 2018-04-09 2018-10-02 中国工商银行股份有限公司 Automatic test asserts method, apparatus, storage medium and equipment
CN109753432A (en) * 2018-12-21 2019-05-14 瑞庭网络技术(上海)有限公司 A kind of interface performance test method, apparatus, server and system
CN109783359A (en) * 2018-12-14 2019-05-21 深圳壹账通智能科技有限公司 The method, apparatus and computer equipment that automatic detection interface effectively identifies
CN109902274A (en) * 2019-02-22 2019-06-18 今天东翼科技有限公司 A kind of method and system converting json character string to thrift binary stream
CN110389899A (en) * 2019-06-21 2019-10-29 北京字节跳动网络技术有限公司 Detect square law device, medium and the equipment of the API data type of JS program
WO2020006930A1 (en) * 2018-07-05 2020-01-09 平安科技(深圳)有限公司 Data forgery method and apparatus, and computer storage medium
CN111078529A (en) * 2019-11-15 2020-04-28 汉海信息技术(上海)有限公司 Client write-in module testing method and device and electronic equipment
CN111200573A (en) * 2018-11-16 2020-05-26 迈普通信技术股份有限公司 RPC request calling method and device
CN111240967A (en) * 2020-01-03 2020-06-05 北京字节跳动网络技术有限公司 Code generation method and device
CN111338944A (en) * 2020-02-21 2020-06-26 北京字节跳动网络技术有限公司 Remote Procedure Call (RPC) interface test method, device, medium and equipment
CN111488267A (en) * 2019-01-25 2020-08-04 北京搜狗科技发展有限公司 Interface test script generation method and device and electronic equipment
CN112433933A (en) * 2020-04-09 2021-03-02 上海哔哩哔哩科技有限公司 Method and equipment for automatically testing interface
WO2021052338A1 (en) * 2019-09-16 2021-03-25 杭州趣链科技有限公司 Smart contract client program generation method, system and device, and medium
CN113360386A (en) * 2021-06-17 2021-09-07 锐捷网络股份有限公司 Switching chip drive test method, device, electronic equipment and storage medium
CN113656295A (en) * 2021-08-10 2021-11-16 上海浦东发展银行股份有限公司 Automatic generation method and device of test data, electronic equipment and storage medium
CN113986747A (en) * 2021-11-05 2022-01-28 京东科技信息技术有限公司 Data generation method and device, electronic equipment and storage medium
CN115114177A (en) * 2022-08-31 2022-09-27 云账户技术(天津)有限公司 Method and device for generating gPC scene template

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104035859A (en) * 2013-03-07 2014-09-10 腾讯科技(深圳)有限公司 Visualized automatic testing method and system thereof
CN104636254A (en) * 2015-01-16 2015-05-20 北京创毅视讯科技有限公司 Method and device for generating test case, testing method and testing equipment
CN104699612A (en) * 2015-03-25 2015-06-10 北京嘀嘀无限科技发展有限公司 Processing method, equipment and system used in software testing
CN104932974A (en) * 2015-05-28 2015-09-23 国家计算机网络与信息安全管理中心 Script conversion method and script conversion device
CN105808428A (en) * 2016-03-03 2016-07-27 南京大学 Method for performing unified performance test on distributed file system
US9477583B2 (en) * 2011-08-08 2016-10-25 Ca, Inc. Automating functionality test cases

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9477583B2 (en) * 2011-08-08 2016-10-25 Ca, Inc. Automating functionality test cases
CN104035859A (en) * 2013-03-07 2014-09-10 腾讯科技(深圳)有限公司 Visualized automatic testing method and system thereof
CN104636254A (en) * 2015-01-16 2015-05-20 北京创毅视讯科技有限公司 Method and device for generating test case, testing method and testing equipment
CN104699612A (en) * 2015-03-25 2015-06-10 北京嘀嘀无限科技发展有限公司 Processing method, equipment and system used in software testing
CN104932974A (en) * 2015-05-28 2015-09-23 国家计算机网络与信息安全管理中心 Script conversion method and script conversion device
CN105808428A (en) * 2016-03-03 2016-07-27 南京大学 Method for performing unified performance test on distributed file system

Cited By (30)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108052320B (en) * 2017-12-11 2021-03-05 上证所信息网络有限公司 Method for converting binary structure body into JSON object
CN108052320A (en) * 2017-12-11 2018-05-18 上证所信息网络有限公司 A kind of method that binary structure body is converted to JSON objects
CN108509337A (en) * 2018-03-15 2018-09-07 链家网(北京)科技有限公司 The dynamic testing method and device called based on interface
CN108614770A (en) * 2018-04-09 2018-10-02 中国工商银行股份有限公司 Automatic test asserts method, apparatus, storage medium and equipment
CN108614770B (en) * 2018-04-09 2021-08-27 中国工商银行股份有限公司 Automatic test assertion method, device, storage medium and equipment
CN108614776A (en) * 2018-05-04 2018-10-02 艺龙网信息技术(北京)有限公司 Across the dynamic fixing method and system of language protocol test request
CN108614776B (en) * 2018-05-04 2021-08-31 艺龙网信息技术(北京)有限公司 Dynamic construction method and system for cross-language protocol test request
WO2020006930A1 (en) * 2018-07-05 2020-01-09 平安科技(深圳)有限公司 Data forgery method and apparatus, and computer storage medium
CN111200573A (en) * 2018-11-16 2020-05-26 迈普通信技术股份有限公司 RPC request calling method and device
CN109783359A (en) * 2018-12-14 2019-05-21 深圳壹账通智能科技有限公司 The method, apparatus and computer equipment that automatic detection interface effectively identifies
CN109753432A (en) * 2018-12-21 2019-05-14 瑞庭网络技术(上海)有限公司 A kind of interface performance test method, apparatus, server and system
CN111488267A (en) * 2019-01-25 2020-08-04 北京搜狗科技发展有限公司 Interface test script generation method and device and electronic equipment
CN111488267B (en) * 2019-01-25 2024-03-12 北京搜狗科技发展有限公司 Interface test script generation method and device and electronic equipment
CN109902274A (en) * 2019-02-22 2019-06-18 今天东翼科技有限公司 A kind of method and system converting json character string to thrift binary stream
CN110389899A (en) * 2019-06-21 2019-10-29 北京字节跳动网络技术有限公司 Detect square law device, medium and the equipment of the API data type of JS program
CN110389899B (en) * 2019-06-21 2023-12-19 北京字节跳动网络技术有限公司 Method and device for detecting API data type of JS program, medium and equipment
WO2021052338A1 (en) * 2019-09-16 2021-03-25 杭州趣链科技有限公司 Smart contract client program generation method, system and device, and medium
CN111078529A (en) * 2019-11-15 2020-04-28 汉海信息技术(上海)有限公司 Client write-in module testing method and device and electronic equipment
CN111078529B (en) * 2019-11-15 2023-07-14 汉海信息技术(上海)有限公司 Client writing module testing method and device and electronic equipment
CN111240967A (en) * 2020-01-03 2020-06-05 北京字节跳动网络技术有限公司 Code generation method and device
CN111240967B (en) * 2020-01-03 2023-09-15 北京字节跳动网络技术有限公司 Code generation method and device
CN111338944A (en) * 2020-02-21 2020-06-26 北京字节跳动网络技术有限公司 Remote Procedure Call (RPC) interface test method, device, medium and equipment
CN111338944B (en) * 2020-02-21 2023-09-08 北京字节跳动网络技术有限公司 Remote Procedure Call (RPC) interface testing method, device, medium and equipment
CN112433933A (en) * 2020-04-09 2021-03-02 上海哔哩哔哩科技有限公司 Method and equipment for automatically testing interface
CN113360386A (en) * 2021-06-17 2021-09-07 锐捷网络股份有限公司 Switching chip drive test method, device, electronic equipment and storage medium
CN113360386B (en) * 2021-06-17 2024-06-14 锐捷网络股份有限公司 Method and device for testing driving of switching chip, electronic equipment and storage medium
CN113656295A (en) * 2021-08-10 2021-11-16 上海浦东发展银行股份有限公司 Automatic generation method and device of test data, electronic equipment and storage medium
CN113656295B (en) * 2021-08-10 2024-06-07 上海浦东发展银行股份有限公司 Automatic generation method and device of test data, electronic equipment and storage medium
CN113986747A (en) * 2021-11-05 2022-01-28 京东科技信息技术有限公司 Data generation method and device, electronic equipment and storage medium
CN115114177A (en) * 2022-08-31 2022-09-27 云账户技术(天津)有限公司 Method and device for generating gPC scene template

Also Published As

Publication number Publication date
CN106919509B (en) 2020-11-24

Similar Documents

Publication Publication Date Title
CN106919509A (en) A kind of client generation method, device and electronic equipment
CN104484216B (en) Service interface document and on-line testing instrument generation method, device
US9483260B1 (en) Documentation generation for web APIs based on byte code analysis
US8504913B2 (en) Client-side components
Peng et al. Using JSON for data exchanging in web service applications
CN103605518B (en) Object unserializing method and apparatus
CA2675332C (en) Framework for automatically merging customizations to structured code that has been refactored
US8527943B1 (en) System and method of application development
CN104035859B (en) A kind of Visual Automatic Test method and its system
US8997053B2 (en) System and method for automated testing of software applications with dynamic user interfaces spanning multiple technologies
US20090254881A1 (en) Code generation techniques for administrative tasks
US20070006179A1 (en) Methods and systems for transforming a parse graph into an and/or command tree
CN110297999A (en) A kind of web page template generation method and device, webpage loading method and front-end server and Website server
CN107239271A (en) Develop document structure tree method and device
Lampropoulos et al. Automatic WSDL-guided test case generation for PropEr testing of web services
CN109783752A (en) Page loading method and device, electronic equipment and computer readable storage medium
CN109933331A (en) Data transfer device and associated component between a kind of client-server
CN109002390A (en) A kind of test case dynamic state of parameters configuration method and device
CN108170409A (en) The development approach and system of WEB front-end control
CN109101225A (en) Component building method and device, Component Gallery framework and computer readable storage medium
CN109271160A (en) Active rule construction method, device and computer system, medium
CN107040818B (en) Layout analytic hierarchy process method and system for Android TV
CN111881043A (en) Page testing method and device, storage medium and processor
Li et al. Automated creation of navigable REST services based on REST chart
Stoeckle et al. A framework for visual notation exchange

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