CN107341102B - Test case file generation method and device - Google Patents

Test case file generation method and device Download PDF

Info

Publication number
CN107341102B
CN107341102B CN201710440003.0A CN201710440003A CN107341102B CN 107341102 B CN107341102 B CN 107341102B CN 201710440003 A CN201710440003 A CN 201710440003A CN 107341102 B CN107341102 B CN 107341102B
Authority
CN
China
Prior art keywords
file
script
character string
data
test case
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
CN201710440003.0A
Other languages
Chinese (zh)
Other versions
CN107341102A (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.)
Qianxin Technology Group Co Ltd
Original Assignee
Qianxin Technology Group 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 Qianxin Technology Group Co Ltd filed Critical Qianxin Technology Group Co Ltd
Priority to CN201710440003.0A priority Critical patent/CN107341102B/en
Publication of CN107341102A publication Critical patent/CN107341102A/en
Application granted granted Critical
Publication of CN107341102B publication Critical patent/CN107341102B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

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

Landscapes

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

Abstract

The embodiment of the invention discloses a method and a device for generating a test case file, wherein the method comprises the following steps: reading a first preset character string in the middle template file according to the first script, and copying all data in the middle template file to a test case file; reading the data file according to the second script, and judging whether a first preset character string exists in the data file; and if the first preset character string exists in the data file, reading a target character string corresponding to the first preset character string in a target row of the data file, and replacing the first preset character string in the test case file with the target character string. The most time-consuming manual configuration part is realized by a script, so that the efficiency is greatly improved; the data and the template content are separated from the script, so that the corresponding middle template file can be directly selected for different interface tests; the data file and the middle template file are connected through the first preset character string, the test case file can be rapidly and automatically generated, efficiency is high, and mistakes are not easy to make.

Description

Test case file generation method and device
Technical Field
The embodiment of the invention relates to the technical field of computers, in particular to a test case file generation method and device.
Background
When the interface test and the performance test of the equipment are carried out, the core steps are to prepare test cases, and the test cases corresponding to different scenes and test points are different.
Especially for the private protocol, when the interface or performance test of the private protocol interface is required, in addition to analyzing the test points and test scenes, writing the test cases and preparing the test data, extracting the input conditions and the output expected values of the interface, the test cases and data also need to be converted into a form which can be recognized by the test framework, that is, the test cases which can be recognized by the private protocol of each interface. And the conversion work needs to manually compile and configure the test cases according to the setting of the test cases by the test framework in a manual mode. If a plurality of test cases of test data need to be prepared, the test case corresponding to each piece of test data needs to be configured manually, and particularly, the data size needed to be configured is very large when performance test is performed, which is difficult to complete manually.
In the process of implementing the embodiment of the present invention, the inventor finds that the existing method for manually configuring the test case is simple, has low threshold, but has very low efficiency and is easy to make mistakes.
Disclosure of Invention
The embodiment of the invention provides a method and a device for generating a test case file, which solve the problems that the existing method for manually configuring a test case is simple, has low threshold, but has very low efficiency and is easy to make mistakes.
In a first aspect, an embodiment of the present invention provides a method for generating a test case file, where the method includes:
running a first script in a script file, reading a first preset character string in a middle template file according to the first script, and copying all data in the middle template file to a test case file;
running a second script in a script file, reading a data file according to the second script, and judging whether the first preset character string exists in the data file;
if the first preset character string exists in the data file, reading a target character string corresponding to the first preset character string in a target row of the data file, and replacing the first preset character string in the test case file with the target character string.
Optionally, before the running a first script in the script file, reading a first preset character string in a middle template file according to the first script, and copying all data in the middle template file to a test case file, the method further includes:
running a third script in a script file, receiving an input character string input from the outside according to the third script, copying all data in a head template file to the test case file, and reading a second preset character string in the head template file;
and replacing the second preset character string in the test case file with the input character string.
Optionally, if the first preset character string exists in the data file, after reading a target character string corresponding to the first preset character string in a target row of the data file and replacing the first preset character string in the test case file with the target character string, the method further includes:
judging whether the target line is the last line of the data file;
and if the target behavior is the last line of the data file, operating a fourth script in a script file, and copying all data in the tail template file to the test case file according to the fourth script.
Optionally, after the running a fourth script in the script file and copying all data in the tail template file to the test case file according to the fourth script, the method further includes:
and automatically testing the private protocol of each interface according to the test case in the test case file.
Optionally, before the running a first script in the script file, reading a first preset character string in a middle template file according to the first script, and copying all data in the middle template file to a test case file, the method further includes:
and acquiring the preset script file, the middle template file, the head template file and the tail template file, and determining the data file according to the test requirement.
Optionally, the method further comprises:
and if the preset character string does not exist in the data file, generating error prompt information.
Optionally, the first, second, first last and second last characters of the first preset character string and/or the second preset character string are underlined.
Optionally, the first line of the data file stores the first preset character string.
Optionally, the middle template file is a template file of any interface protocol, and the template file of each interface protocol includes a test program of the corresponding interface protocol.
In a second aspect, an embodiment of the present invention further provides a test case file generating device, including:
the middle data copying module is used for operating a first script in a script file, reading a first preset character string in a middle template file according to the first script, and copying all data in the middle template file to a test case file;
the character string judging module is used for operating a second script in a script file, reading a data file according to the second script and judging whether the first preset character string exists in the data file or not;
and the first character string replacing module is used for reading a target character string corresponding to the first preset character string in a target row of the data file and replacing the first preset character string in the test case file with the target character string if the first preset character string exists in the data file.
Optionally, the apparatus further comprises:
the head data copying module is used for operating a third script in the script file, receiving an input character string input from the outside according to the third script, copying all data in the head template file to the test case file, and reading a second preset character string in the head template file;
and the second character string replacing module is used for replacing the second preset character string in the test case file with the input character string.
Optionally, the apparatus further comprises:
the target line judging module is used for judging whether the target line is the last line of the data file;
and the tail data copying module is used for operating a fourth script in the script file if the target behavior is the last line of the data file, and copying all data in the tail template file to the test case file according to the fourth script.
Optionally, the apparatus further comprises:
and the private protocol testing module is used for automatically testing the private protocol of each interface according to the test case in the test case file.
Optionally, the apparatus further comprises:
and the file acquisition module is used for acquiring the preset script file, the middle template file, the head template file and the tail template file and determining the data file according to the test requirement.
Optionally, the apparatus further comprises:
and the error prompt module is used for generating error prompt information if the preset character string does not exist in the data file.
Optionally, the first, second, first last and second last of the first preset character string and/or the second preset character string are underlined.
Optionally, the first line of the data file stores the first preset character string.
Optionally, the middle template file is a template file of any interface protocol, and the template file of each interface protocol includes a test program of the corresponding interface protocol.
In a third aspect, an embodiment of the present invention further provides an electronic device, including:
at least one processor; and
at least one memory communicatively coupled to the processor, wherein:
the memory stores program instructions executable by the processor, the processor invoking the program instructions to perform the method of the above method claims.
In a fourth aspect, embodiments of the invention also propose a non-transitory computer-readable storage medium storing a computer program which causes the computer to perform the method of the above method claim.
According to the technical scheme, the embodiment of the invention realizes the most time-consuming manual configuration part by the script through the script file, thereby greatly improving the efficiency; the data and the template content are separated from the script to form a data file and a middle template file respectively, so that the corresponding middle template file can be directly selected for different interface tests; the data file and the middle template file are connected through the first preset character string, the test case file can be rapidly and automatically generated, manual intervention for writing of scripts is not needed, efficiency is high, and mistakes are not easy to make.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is a schematic flow chart of a test case file generation method according to an embodiment of the present invention;
FIG. 2 is a diagram of a data file according to an embodiment of the present invention;
fig. 3 is a schematic flowchart of a test case file generation method according to another embodiment of the present invention;
fig. 4 is a schematic structural diagram of a test case file generating apparatus according to an embodiment of the present invention;
fig. 5 is a logic block diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The following further describes embodiments of the present invention with reference to the accompanying drawings. The following examples are only for illustrating the technical solutions of the present invention more clearly, and the protection scope of the present invention is not limited thereby.
Fig. 1 shows a flowchart of a test case file generation method provided in this embodiment, including:
s101, running a first script in a script file, reading a first preset character string in a middle template file according to the first script, and copying all data in the middle template file to a test case file.
The script file comprises a plurality of scripts for executing different operations, such as a first script, a second script, a third script and a fourth script.
The first script is used for reading a first preset character string in the middle template file.
The second script is used for reading a data file and judging whether the first preset character string exists in the data file.
The third script is used for receiving an input character string input from the outside, copying all data in the head template file to the test case file, and reading a second preset character string in the head template file.
And the fourth script is used for copying all data in the tail template file to the test case file.
The template file is used for storing templated test programs applicable to all interfaces, the test program in one test case comprises a head part, a middle part and a tail part, the head part comprises a case name, a login user name, a data file name and the like, the tail part only comprises brackets, and the middle part is a main body and comprises identification, input, expected results and the like of one protocol.
For each test protocol in an interface, the above-mentioned header, middle, and trailer are saved as separate json files, which are template files, and the portions in which test data needs to be filled are replaced with special character strings (first preset character strings) that do not overlap with other character strings.
Thus, the template files include a head template file, a middle template file, and a tail template file.
The content in the head template file and the tail template file only appears once in the finally generated test case file, but the content in the middle template file appears for multiple times in the finally generated test case file, and each piece of test data corresponds to the content in the middle template file. Therefore, if the data file includes N pieces of test data, the content in the middle template file appears N times in the finally generated test case file.
The test case file is a file for storing test cases, and the test cases in the file are used for finally carrying out interface test.
The test case is a basic execution entity of the interface in the private protocol of each interface, and comprises an execution command sequence and other attribute information. The command is a minimum execution unit, and includes a command identifier, dependency information, a user executing the command, input parameters, desired output parameters, and the like.
The first preset character string is a character string which is predefined in the middle template file and represents actual test data, for example, "__ resource id __" represents a resource serial number, and when a test case is actually executed, the place where "__ resource id __" appears in the middle template file is replaced by the actual test data in the data file. If 3 pieces of test data exist, the content of the middle template file appears 3 times in the finally generated test case file, the part of the middle template file with the 1 st resource sequence number in the 1 st time, where the "__ resource id __" appears, is replaced by the test data with the 1 st resource sequence number, the part of the middle template file with the 2 nd time, where the "__ resource id __" appears, is replaced by the test data with the 2 nd resource sequence number, and the part of the middle template file with the 3 rd time, where the "__ resource id __" appears, is replaced by the test data with the 3 rd resource sequence number.
S102, operating a second script in the script file, reading a data file according to the second script, and judging whether the first preset character string exists in the data file.
The data file is a predetermined file according to test data required by the test requirement. The data file stores a plurality of test data, and each test data may include one test parameter or a plurality of test parameters.
Specifically, the first preset character string may be searched in a data file in a sequential search manner.
S103, if the first preset character string exists in the data file, reading a target character string corresponding to the first preset character string in a target row of the data file, and replacing the first preset character string in the test case file with the target character string.
The target line may be any line in the data file. The embodiment may adopt a sequential reading mode, and read one row of test data at a time until the last row of the data file.
The target character string is a character string corresponding to a first preset character string in the test data of the target row.
For example, as shown in fig. 2, the first predetermined string is "__ resource id __" and represents a resource serial number, a data table is stored in the data file, the data table includes "__ fileName __" (file name) and "__ mimeType __" (multipurpose internet mail extension type) in addition to "__ resource id __", the first row of the data file stores attributes of test data (the first predetermined string), the remaining 11 rows are respectively 11 different test data, and each piece of data includes a corresponding file name, multipurpose internet mail extension type and resource serial number.
When the target action is on the 11 th line, the character string corresponding to the first preset character string ("__ resource id __") is "529 b1517-e910-4ea5-aeab-24e87016235 c", so that the part of the test case file where the "__ resource id __" appears in the content copied from the middle template file at this time is completely replaced by "529 b1517-e910-4ea5-aeab-24e87016235 c".
In the embodiment, the most time-consuming manual configuration part is realized by the script through the script file, so that the efficiency is greatly improved; the data and the template content are separated from the script to form a data file and a middle template file respectively, so that the corresponding middle template file can be directly selected for different interface tests; the data file and the middle template file are connected through the first preset character string, the test case file can be rapidly and automatically generated, manual intervention for writing of scripts is not needed, efficiency is high, and mistakes are not easy to make.
Fig. 3 shows a flowchart of a test case file generation method provided in this embodiment, including:
s301, running a third script in a script file, receiving an input character string input from the outside according to the third script, copying all data in a head template file to the test case file, and reading a second preset character string in the head template file;
s302, replacing the second preset character string in the test case file with the input character string.
S303, running a first script in the script file, reading a first preset character string in the middle template file according to the first script, and copying all data in the middle template file to the test case file.
S304, operating a second script in the script file, reading the data file according to the second script, and judging whether the first preset character string exists in the data file.
S305, if the first preset character string exists in the data file, reading a target character string corresponding to the first preset character string in a target row of the data file, and replacing the first preset character string in the test case file with the target character string.
S306, judging whether the target line is the last line of the data file;
s307, if the target behavior is the last line of the data file, a fourth script in the script file is operated, and all data in the tail template file are copied to the test case file according to the fourth script.
S303 to S305 completely correspond to S101 to S103 in the embodiment corresponding to fig. 1, and are not described herein again.
The input character string is a character string input from the outside of the terminal, for example, a character string input through a keyboard. In this embodiment, the input character string includes opCodeName (use case name), loginnname (login user name), and sourceFile (data file name).
The second preset character string is a character string which is predefined in the head template file and represents actual input.
Specifically, firstly, all data in the head template file are copied to the test case file, and a second preset character string in the head template file is replaced by an input character string; then, all data in the middle template file are copied to the lower side of the content of the head template file in the test case file in sequence, and the first preset character string in the test case file is replaced by a target character string (if N pieces of test data exist, the inside of the middle template file is copied and the first preset character is replaced for N times); and finally, copying all the data in the tail template file to the lower part of the content of the middle template file in the test case file after all the test data in the data file are replaced, and finishing the test case file which can be finally used for testing.
The head and the tail of all the interface test cases are the same, so that the interface test cases can be multiplexed, namely the head template file and the tail template file are suitable for all the interface tests and do not need to be changed, and the generation of new test cases is facilitated.
For example, the template file is as follows:
$ls-1template/
all_pre.json
all_suf.json
GetResource_mid.json
PutResource_mid.json
QueryResourceInfo_mid.json
json is a head template file, all _ suf.json is a tail template file, the rest json files are middle template files, each middle template file corresponds to a protocol of an interface, and in one test case, only one test program in each middle template file is included.
The template file name for a particular interface may be $ { opCodeName } _ mid.
Specifically, the contents of the header template file all _ pre.json are exemplified as follows:
Figure BDA0001319698600000111
json' content of the tail template file all _ suf.json is exemplified as follows:
$cat all_suf.json
]
}
"__ opCodeName __" and "__ loginnname __" in the header template file all _ pre.json are the first preset character string, and after being subsequently copied to the test case file, the first preset character string is replaced by test data in the corresponding data file.
Further, on the basis of the above method embodiment, after S307, the method further includes:
and S308, automatically testing the private protocol of each interface according to the test case in the test case file.
The private protocol corresponds to a general protocol, such as TCP and HTTP, and the private protocol is a self-defined protocol.
Because the private protocol is usually a completely self-defined protocol, the writing of the test case is time-consuming and labor-consuming, and the embodiment can automatically test the private protocol of each interface by using the test case in the test case file through automatically generating the test case file.
Further, on the basis of the above embodiment of the method, before S303, the method further includes:
and S3023, acquiring the preset script file, the preset middle template file, the preset head template file and the preset tail template file, and determining the data file according to the test requirement.
Specifically, when a protocol of each interface is tested, the same script file, head template file and tail template file are adopted, and one middle template file in a plurality of middle template files is adopted; when testing is performed on different protocols of different interfaces, data files of the interfaces are generally different, and therefore the data files need to be determined according to testing requirements.
Further, on the basis of the above embodiment of the method, the method further comprises:
s309, if the preset character string does not exist in the data file, generating error prompt information.
And the error prompt information is information for prompting that the preset character string does not exist in the data file so as to inform a user that the test case generation process is incorrect and cannot be continued. The user can check whether the data file is erroneous during the preparation process.
Further, on the basis of the above method embodiment, the first, second, penultimate and penultimate characters of the first preset character string and/or the second preset character string are all underlined.
For example, the first predetermined string is "__ resource id __".
By arranging the first, second, penultimate and penultimate characters as underlines, strings of this format are not used in normal situations, and therefore no collisions occur, and recognition of the first predetermined string and/or the second predetermined string is facilitated.
Further, on the basis of the above method embodiment, the first line of the data file stores the first preset character string.
The first preset character string is stored in the first row of the data file, so that the quick search can be facilitated.
Further, on the basis of the above method embodiment, the middle template file is a template file of any interface protocol, and the template file of each interface protocol includes a test program of the corresponding interface protocol.
Specifically, a middle template file includes template files for a protocol of an interface.
By defining a middle template file for each interface protocol, subsequent multiplexing is facilitated.
Specifically, the test case file generated last in this embodiment is placed in the cases directory; setting the interface to be tested according to the rule of the middle template file, and placing the interface under a template directory; when a test case of a new interface needs to be created, only a template file and a corresponding data file of the interface need to be created, and the test case is executed by a script.
The embodiment can not only realize the most time-consuming manual configuration part by the script, but also completely extract the data and the template content from the script, so that the method can also be used as a general data rapid generation scheme, the configuration efficiency is greatly improved compared with manual configuration, the number of template files is equivalent to that of corresponding interfaces, and the management is convenient; only one script file is needed and written once, and maintenance is not needed; the column sequence of the data files can be random, so that the cost for generating the data files is reduced; generating a single-protocol test case supporting all current protocols (and subsequent newly-added protocols); the data content needing to be replaced in the test case supports complete self-definition, and the expansibility is good; non-technical personnel can also generate test cases according to the use rules, so that the technical threshold is reduced, and the application range of the tool is enlarged; the data file self-contains the meaning of each column without reading a script; a set of method for generating test cases rapidly and conveniently can be formed preliminarily, and based on the method and codes, the method can be further improved to adapt to the generation of the test cases in a mixed protocol scene.
Fig. 4 shows a schematic structural diagram of a test case file generating device provided in this embodiment, where the device includes: a middle data copying module 401, a character string judging module 402 and a first character string replacing module 403; wherein:
the middle data copying module 401 is configured to run a first script in a script file, read a first preset character string in a middle template file according to the first script, and copy all data in the middle template file to a test case file;
the character string judging module 402 is configured to run a second script in a script file, read a data file according to the second script, and judge whether the first preset character string exists in the data file;
the first character string replacing module 403 is configured to, if the first preset character string exists in the data file, read a target character string corresponding to the first preset character string in a target row of the data file, and replace the first preset character string in the test case file with the target character string.
Specifically, the middle data copying module 401 runs a first script in a script file, reads a first preset character string in a middle template file according to the first script, and copies all data in the middle template file to a test case file; the character string judging module 402 runs a second script in a script file, reads a data file according to the second script, and judges whether the first preset character string exists in the data file; if the first preset character string exists in the data file, the first character string replacement module 403 reads a target character string corresponding to the first preset character string in a target row of the data file, and replaces the first preset character string in the test case file with the target character string.
In the embodiment, the most time-consuming manual configuration part is realized by the script through the script file, so that the efficiency is greatly improved; the data and the template content are separated from the script to form a data file and a middle template file respectively, so that the corresponding middle template file can be directly selected for different interface tests; the data file and the middle template file are connected through the first preset character string, the test case file can be rapidly and automatically generated, manual intervention for writing of scripts is not needed, efficiency is high, and mistakes are not easy to make.
Further, on the basis of the above embodiment of the apparatus, the apparatus further comprises:
the head data copying module is used for operating a third script in the script file, receiving an input character string input from the outside according to the third script, copying all data in the head template file to the test case file, and reading a second preset character string in the head template file;
and the second character string replacing module is used for replacing the second preset character string in the test case file with the input character string.
Further, on the basis of the above embodiment of the apparatus, the apparatus further comprises:
the target line judging module is used for judging whether the target line is the last line of the data file;
and the tail data copying module is used for operating a fourth script in the script file if the target behavior is the last line of the data file, and copying all data in the tail template file to the test case file according to the fourth script.
Further, on the basis of the above embodiment of the apparatus, the apparatus further comprises:
and the private protocol testing module is used for automatically testing the private protocol of each interface according to the test case in the test case file.
Further, on the basis of the above embodiment of the apparatus, the apparatus further comprises:
and the file acquisition module is used for acquiring the preset script file, the middle template file, the head template file and the tail template file and determining the data file according to the test requirement.
Further, on the basis of the above embodiment of the apparatus, the apparatus further comprises:
and the error prompt module is used for generating error prompt information if the preset character string does not exist in the data file.
Further, on the basis of the above device embodiment, the first, second, penultimate and penultimate characters of the first preset character string and/or the second preset character string are all underlined.
Further, on the basis of the above device embodiment, the first line of the data file stores the first preset character string.
Further, on the basis of the above device embodiment, the middle template file is a template file of any interface protocol, and the template file of each interface protocol includes a test program of the corresponding interface protocol.
The test case file generating device described in this embodiment may be used to execute the above method embodiments, and the principle and technical effect are similar, which are not described herein again.
Referring to fig. 5, the electronic device includes: a processor (processor)501, a memory (memory)502, and a bus 503;
wherein the content of the first and second substances,
the processor 501 and the memory 502 are communicated with each other through the bus 503;
the processor 501 is used to call program instructions in the memory 502 to perform the methods provided by the above-described method embodiments.
The present embodiments disclose a computer program product comprising a computer program stored on a non-transitory computer readable storage medium, the computer program comprising program instructions which, when executed by a computer, enable the computer to perform the methods provided by the above-described method embodiments.
The present embodiments provide a non-transitory computer-readable storage medium storing computer instructions that cause the computer to perform the methods provided by the method embodiments described above.
Those of ordinary skill in the art will understand that: all or part of the steps for implementing the method embodiments may be implemented by hardware related to program instructions, and the program may be stored in a computer readable storage medium, and when executed, the program performs the steps including the method embodiments; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.
It should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (18)

1. A test case file generation method is characterized by comprising the following steps:
running a first script in a script file, reading a first preset character string in a middle template file according to the first script, and copying all data in the middle template file to a test case file;
running a second script in a script file, reading a data file according to the second script, and judging whether the first preset character string exists in the data file;
if the first preset character string exists in the data file, reading a target character string corresponding to the first preset character string in a target row of the data file, and replacing the first preset character string in the test case file with the target character string;
judging whether the target line is the last line of the data file;
and if the target behavior is the last line of the data file, operating a fourth script in a script file, and copying all data in the tail template file to the test case file according to the fourth script.
2. The method according to claim 1, wherein before the running a first script in the script file, reading a first preset character string in a middle template file according to the first script, and copying all data in the middle template file to a test case file, the method further comprises:
running a third script in a script file, receiving an input character string input from the outside according to the third script, copying all data in a head template file to the test case file, and reading a second preset character string in the head template file;
and replacing the second preset character string in the test case file with the input character string.
3. The method according to claim 1, wherein after the running a fourth script in the script file and copying all data in the tail template file to the test case file according to the fourth script, further comprising:
and automatically testing the private protocol of each interface according to the test case in the test case file.
4. The method according to claim 1, wherein before the running a first script in the script file, reading a first preset character string in a middle template file according to the first script, and copying all data in the middle template file to a test case file, the method further comprises:
and acquiring the preset script file, the middle template file, the head template file and the tail template file, and determining the data file according to the test requirement.
5. The method of claim 1, further comprising:
and if the preset character string does not exist in the data file, generating error prompt information.
6. The method according to claim 2, wherein the first, second, penultimate and penultimate characters of the first predetermined string and/or the second predetermined string are all underlined.
7. The method of claim 1, wherein the first row of the data file stores the first predetermined string.
8. The method of claim 1, wherein the middle template file is a template file of any one of the interface protocols, and each template file of the interface protocol includes a test program of the corresponding interface protocol.
9. A test case file generation apparatus, comprising:
the middle data copying module is used for operating a first script in a script file, reading a first preset character string in a middle template file according to the first script, and copying all data in the middle template file to a test case file;
the character string judging module is used for operating a second script in a script file, reading a data file according to the second script and judging whether the first preset character string exists in the data file or not;
the first character string replacing module is used for reading a target character string corresponding to the first preset character string in a target row of the data file and replacing the first preset character string in the test case file with the target character string if the first preset character string exists in the data file;
the target line judging module is used for judging whether the target line is the last line of the data file;
and the tail data copying module is used for operating a fourth script in the script file if the target behavior is the last line of the data file, and copying all data in the tail template file to the test case file according to the fourth script.
10. The apparatus of claim 9, further comprising:
the head data copying module is used for operating a third script in the script file, receiving an input character string input from the outside according to the third script, copying all data in the head template file to the test case file, and reading a second preset character string in the head template file;
and the second character string replacing module is used for replacing the second preset character string in the test case file with the input character string.
11. The apparatus of claim 9, further comprising:
and the private protocol testing module is used for automatically testing the private protocol of each interface according to the test case in the test case file.
12. The apparatus of claim 9, further comprising:
and the file acquisition module is used for acquiring the preset script file, the middle template file, the head template file and the tail template file and determining the data file according to the test requirement.
13. The apparatus of claim 9, further comprising:
and the error prompt module is used for generating error prompt information if the preset character string does not exist in the data file.
14. The apparatus of claim 13, wherein the first, second, first last and second last characters of the first predetermined string and/or the second predetermined string are underlined.
15. The apparatus of claim 9, wherein the first row of the data file stores the first predetermined string.
16. The apparatus of claim 9, wherein the middle template file is a template file of any one of the interface protocols, and each template file of the interface protocol includes a test program of the corresponding interface protocol.
17. An electronic device, comprising:
at least one processor; and
at least one memory communicatively coupled to the processor, wherein:
the memory stores program instructions executable by the processor, the processor invoking the program instructions to perform the method of any of claims 1 to 8.
18. A non-transitory computer-readable storage medium storing a computer program that causes a computer to perform the method according to any one of claims 1 to 8.
CN201710440003.0A 2017-06-12 2017-06-12 Test case file generation method and device Active CN107341102B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710440003.0A CN107341102B (en) 2017-06-12 2017-06-12 Test case file generation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710440003.0A CN107341102B (en) 2017-06-12 2017-06-12 Test case file generation method and device

Publications (2)

Publication Number Publication Date
CN107341102A CN107341102A (en) 2017-11-10
CN107341102B true CN107341102B (en) 2020-07-14

Family

ID=60221432

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710440003.0A Active CN107341102B (en) 2017-06-12 2017-06-12 Test case file generation method and device

Country Status (1)

Country Link
CN (1) CN107341102B (en)

Families Citing this family (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109814517A (en) * 2017-11-21 2019-05-28 北京金风科创风电设备有限公司 Method and system for processing fan operation parameters and computer readable storage medium
CN108829574B (en) * 2018-04-13 2023-04-18 深圳壹账通智能科技有限公司 Test data laying method, test server and computer readable storage medium
CN108804327A (en) * 2018-06-12 2018-11-13 北京京东金融科技控股有限公司 A kind of method and apparatus of automatic Data Generation Test
CN109446099A (en) * 2018-11-09 2019-03-08 贵州医渡云技术有限公司 Automatic test cases generation method, device, medium and electronic equipment
CN109815122A (en) * 2018-12-15 2019-05-28 深圳壹账通智能科技有限公司 Test data generating method, device, electronic equipment and storage medium
CN111385159B (en) * 2018-12-28 2022-02-25 广州市百果园信息技术有限公司 Server side pressure testing method and device, storage medium and computer equipment
CN109902002B (en) * 2019-02-14 2020-06-02 浙江口碑网络技术有限公司 Generation method and device of combined test case, storage medium and computer equipment
CN112180890B (en) * 2019-07-05 2022-01-07 北京新能源汽车股份有限公司 Test case generation method, device and equipment
CN113746593A (en) * 2020-05-29 2021-12-03 北京沃东天骏信息技术有限公司 Character string data transmission method, system, device, electronic equipment and storage medium thereof

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103631720A (en) * 2013-12-20 2014-03-12 百度在线网络技术(北京)有限公司 Method and device for generating test case
CN104268073A (en) * 2014-09-05 2015-01-07 北京广利核系统工程有限公司 Method for generating test cases in batch mode
CN104503900A (en) * 2014-11-21 2015-04-08 北京奇虎科技有限公司 Test case generation method and device
CN106557416A (en) * 2015-09-28 2017-04-05 百度在线网络技术(北京)有限公司 The implementation method and device of software cloud test

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8838607B2 (en) * 2012-10-17 2014-09-16 International Business Machines Corporation Software system test case creation

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103631720A (en) * 2013-12-20 2014-03-12 百度在线网络技术(北京)有限公司 Method and device for generating test case
CN104268073A (en) * 2014-09-05 2015-01-07 北京广利核系统工程有限公司 Method for generating test cases in batch mode
CN104503900A (en) * 2014-11-21 2015-04-08 北京奇虎科技有限公司 Test case generation method and device
CN106557416A (en) * 2015-09-28 2017-04-05 百度在线网络技术(北京)有限公司 The implementation method and device of software cloud test

Also Published As

Publication number Publication date
CN107341102A (en) 2017-11-10

Similar Documents

Publication Publication Date Title
CN107341102B (en) Test case file generation method and device
US10684943B2 (en) Generating executable test automation code automatically according to a test case
CN110705237B (en) Automatic document generation method, data processing device and storage medium
CN112328489B (en) Test case generation method and device, terminal equipment and storage medium
CN114328276B (en) Test case generation method and device, and test case display method and device
US11409631B2 (en) Verification automation apparatus, verification automation method, and computer-readable recording medium
CN111679979B (en) Destructive testing method and device
CN113312108A (en) SWIFT message checking method and device, electronic equipment and storage medium
CN111611788B (en) Data processing method and device, electronic equipment and storage medium
CN111290996A (en) Document format conversion method, device, equipment and readable storage medium
CN113031944B (en) Business opening device and method based on template
CN114416547A (en) Test case based test method
CN106789205A (en) Group of planes order operation method and system
CN106681852B (en) A kind of method of adjustment and device of browser compatibility
CN111143228B (en) Test code generation method and device based on decision table method
CN111078529B (en) Client writing module testing method and device and electronic equipment
CN106293862B (en) A kind of analysis method and device of expandable mark language XML data
CN112947944A (en) Business work order processing method and device
CN109992293B (en) Method and device for assembling Android system component version information
CN113778426B (en) Page generation method and device
CN110515913B (en) Log processing method and device
CN110955687B (en) Data modification method and device
CN108287697A (en) A kind of html escape character replacement method, device and terminal
JP6556091B2 (en) System specification verification support apparatus and system specification verification support method
CN116450150A (en) Front-end modularized construction deployment method and device, electronic equipment and storage medium

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
CB02 Change of applicant information

Address after: 100088 Building 3 332, 102, 28 Xinjiekouwai Street, Xicheng District, Beijing

Applicant after: QAX Technology Group Inc.

Address before: 100015 Jiuxianqiao Chaoyang District Beijing Road No. 10, building 15, floor 17, layer 1701-26, 3

Applicant before: BEIJING QIANXIN TECHNOLOGY Co.,Ltd.

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant