CN106021118B - Test code generating method and device, test frame code execution method and device - Google Patents

Test code generating method and device, test frame code execution method and device Download PDF

Info

Publication number
CN106021118B
CN106021118B CN201610443187.1A CN201610443187A CN106021118B CN 106021118 B CN106021118 B CN 106021118B CN 201610443187 A CN201610443187 A CN 201610443187A CN 106021118 B CN106021118 B CN 106021118B
Authority
CN
China
Prior art keywords
code
test
case
file
module
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
CN201610443187.1A
Other languages
Chinese (zh)
Other versions
CN106021118A (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.)
Juzhi Technology (Hubei) Co.,Ltd.
Original Assignee
Shenzhen Chargerlink Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shenzhen Chargerlink Technology Co Ltd filed Critical Shenzhen Chargerlink Technology Co Ltd
Priority to CN201610443187.1A priority Critical patent/CN106021118B/en
Publication of CN106021118A publication Critical patent/CN106021118A/en
Application granted granted Critical
Publication of CN106021118B publication Critical patent/CN106021118B/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/3688Test management for test execution, e.g. scheduling of test suites

Landscapes

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

Abstract

The invention discloses test code generating method, device, test frame code execution method and device, test frame code execution method includes:Operating file selection input by user is received, all test case codes of load respective type are selected according to the operating file;Wherein, the type includes failure use-case code and other test case codes;The test case code is executed respectively, and records implementing result;Judge whether all test case codes are finished, pass through if so, judging whether test case code is tested, if so, generating test report, otherwise, it is failure use-case code to mark the test case code;The test case code is obtained by test code generating method.The present invention tests code file according to different step file generateds, need not change code using the different test code file time so that user greatlys save the testing time when being connected to test assignment, reduces manual testing's cost.

Description

Test code generating method and device, test frame code execution method and device
Technical field
The present invention relates to technical field of automation more particularly to a kind of test code generating methods and device, test frame Code execution method and device.
Background technology
Nearly all be during the test at present manually write test case, and it is artificial carry out use-case test, manually at This and time cost are high, variation is fast, version iteration is more, interface type is diversified, the testing time is urgent, test case maintenance at Under this high demand, test mode originally is no longer appropriate for.
Invention content
For overcome the deficiencies in the prior art, one of the objects of the present invention is to provide test code generating method, energy Automation tests code according to existing test template file generated.
One of the second object of the present invention is to provide test code generating unit, can achieve the object of the present invention.
The third object of the present invention is to provide test frame code execution method, can automatic load test use-case generation Code executes test job.
The fourth object of the present invention is to provide test frame code execution device, can achieve the object of the present invention it Three.
An object of the present invention is realized using following technical scheme:
A kind of test code generating method, includes the following steps:
Step 1:The script file of read test framework template, and test code file is generated according to the script file;
Step 2:Load test code file receives project name input by user, judges whether to generate use-case code, If so, executing step 3, otherwise, corresponding test frame code and the survey are generated according to project name and test code file Try skeleton code catalogue;
Step 3:Judge whether to generate interface testing code according to test code file, if so, step 4 is executed, it is no Then, a whole set of test code is generated according to project name and test code file;
Step 4:Access interface data generate returned data, and the test code verified, root are handled according to returned data A corresponding test case code is generated according to the test code and interface data of verification;
Step 5:Step 4 is repeated, a whole set of test code is generated according to all test case codes and project name;
Wherein, a whole set of described test code includes use-case test code and test frame code.
Preferably, the step 4 includes following sub-step:
Step 41:Store path input by user is received, to enter corresponding storage folder;
Step 42:The interface document in the storage folder is parsed, and handles and obtains interface data;
Step 43:Access interface data simultaneously generate returned data, and the test code verified is handled according to returned data, A corresponding test case code is generated according to the test code and interface data of verification.
The second object of the present invention is realized using following technical scheme:
A kind of test code generating unit, including following module:
Read module:Test code is generated for the script file of read test framework template, and according to the script file File;
Load-on module:For load test code file, project name input by user is received, judges whether to generate use-case Otherwise code, corresponding test frame generation is generated according to project name and test code file if so, executing judgment module Code and the test frame code directory;
Judgment module:For judging whether to generate interface testing code according to test code file, if so, thening follow the steps Four, otherwise, a whole set of test code is generated according to project name and test code file;
Access modules:Returned data is generated for access interface data, the test verified is handled according to returned data Code generates a corresponding test case code according to the test code and interface data of verification;
Generation module:For repeated accesses module, a whole set of survey is generated according to all test case codes and project name Try code;
Wherein, a whole set of described test code includes use-case test code and test frame code.
Preferably, access modules specifically include following submodule:
Receiving submodule:For receiving store path input by user, to enter corresponding storage folder;
Analyzing sub-module:For parsing the interface document in the storage folder, and handles and obtain interface data;
Access submodule:For access interface data and returned data is generated, is handled and verified according to returned data Code is tested, a corresponding test case code is generated according to the test code and interface data of verification.
The third object of the present invention is realized using following technical scheme:
A kind of test frame code execution method, includes the following steps:
A1:Operating file selection input by user is received, all surveys of load respective type are selected according to the operating file Example code on probation;Wherein, the type includes at least failure use-case code;
A2:The test case code is executed respectively, and records implementing result;
A3:Judge whether all test case codes are finished, if so, executing A4, otherwise returns to A2;
A4:Judge whether test case code is tested to pass through, if so, generating test report, otherwise, the test is marked to use Example code is failure use-case code;
The test case code is obtained by test code generating method.
The fourth object of the present invention is realized using following technical scheme:
A kind of test frame code execution device, including following module:
Load submodule:It is corresponding according to operating file selection load for receiving operating file selection input by user All test case codes of type;Wherein, the type includes at least failure use-case code;
Implementation sub-module:For executing the test case code respectively, and record implementing result;
First judging submodule:For judging whether all test case codes are finished, sentence if so, executing second Disconnected submodule, otherwise returns to implementation sub-module;
Second judgment submodule:Pass through for judging whether test case code is tested, if so, test report is generated, Otherwise, it is failure use-case code to mark the test case code;
The test case code is obtained by test code generating method.
Compared with prior art, the beneficial effects of the present invention are:
The present invention tests code file according to different step file generateds, is applying the different test code file time Code need not be changed so that user greatlys save the testing time when being connected to test assignment, reduces manual testing's cost.
Description of the drawings
Fig. 1 is the flow chart of the test code generating method of the present invention.
Fig. 2 is the flow chart of the test frame code execution method of the present invention.
Specific implementation mode
In the following, in conjunction with attached drawing and specific implementation mode, the present invention is described further:
Referring to Fig. 1, the present invention provides a kind of test code generating method comprising following steps:
S1:The script file of read test framework template, and test code file is generated according to the script file;
The script file finished writing is stored under specified directory, is run by update tools, automatic read specifies template Under script file, replace to obtain test code file by series of algorithms constant, test code file is data.db texts Part is preserved into data.tb files.It is encryption file to test code file, prevents abnormal change, is applied to test generation later In the operation of code file, actually has and operation first is decrypted to the test code file obtains code skeleton.
S2:Load test code file receives project name input by user;
Running tool is obj_create, automatic data.db files, and prompts user's cuit title, with to will The project name of the test code of production is created.
S3:Judge whether to generate use-case code, if so, S4 is executed, otherwise, according to project name and test code file Generate corresponding test frame code and the test frame code directory;
Direct production test skeleton code and catalogue, do not protect test case code if not generating use-case code.
S4:Judge whether to generate interface testing code according to test code file, if so, S5 is executed, otherwise, according to item Mesh title and test code file generate a whole set of test code;
S4 is also to judge test-types, if the read existing test frame templates of step S1 are interface model, Since test case needs, palpus access interface obtains interface data and need not then be carried out to interface if it is app test templates It accesses, directly generates a whole set of test code.
S5:Access interface data generate returned data, the test code verified are handled according to returned data, according to school The test code and interface data tested generate a corresponding test case code;
Step S5 specifically may include following sub-step:
Step 51:Store path input by user is received, to enter corresponding storage folder;
Step 52:The interface document in the storage folder is parsed, and handles and obtains interface data;
Step 53:Access interface data simultaneously generate returned data, and the test code verified is handled according to returned data, A corresponding test case code is generated according to the test code and interface data of verification.
The interface document that the export of Postman tools preserves, correlative code parses interface document, and memory is recorded In, each interface document is once accessed after parsing, returned data is recorded after accessing a http request, by algorithm Handle the test code verified.
S6:S5 is repeated, a whole set of test code is generated according to all test case codes and project name;
Wherein, a whole set of described test code includes use-case test code and test frame code.
That is, front user has selected generation use-case code, then use-case test code and test block can be generated simultaneously Otherwise frame code directly generates test frame code and its catalogue.
Correspondingly, the present invention also provides a kind of test code generating units comprising following module:
Read module:Test code is generated for the script file of read test framework template, and according to the script file File;
Load-on module:For load test code file, project name input by user is received, judges whether to generate use-case Otherwise code, corresponding test frame generation is generated according to project name and test code file if so, executing judgment module Code and the test frame code directory;
Judgment module:For judging whether to generate interface testing code according to test code file, if so, thening follow the steps Four, otherwise, a whole set of test code is generated according to project name and test code file;
Access modules:Returned data is generated for access interface data, the test verified is handled according to returned data Code generates a corresponding test case code according to the test code and interface data of verification;
Generation module:For repeated accesses module, a whole set of survey is generated according to all test case codes and project name Try code;
Wherein, a whole set of described test code includes use-case test code and test frame code.
Wherein, access modules specifically include following submodule:
Receiving submodule:For receiving store path input by user, to enter corresponding storage folder;
Analyzing sub-module:For parsing the interface document in the storage folder, and handles and obtain interface data;
Access submodule:For access interface data and returned data is generated, is handled and verified according to returned data Code is tested, a corresponding test case code is generated according to the test code and interface data of verification.
Referring to Fig. 2, the present invention also provides test frame code execution methods, and test frame code here is by test code Generation method obtains, and application of the execution method proposed here namely to test frame code includes the following steps:
A1:Operating file selection input by user is received, all surveys of load respective type are selected according to the operating file Example code on probation;
Here type includes failure use-case code and whole use-case codes, and whole use-case codes include failure and non-mistake It loses.The file that user can run needs selects, the whole test case codes of selection operation or all failure use Example code.It is not required to when carrying out test detection again for the last test case code for executing failure by this operation Whole test case codes are all retested one time, it is only necessary to which test crash test case code reduces recurrence Testing time.
A2:The test case code is executed respectively, and records implementing result;
A3:Judge whether all test case codes are finished, if so, executing A4, otherwise returns to A2;
A4:Judge whether test case code is tested to pass through, if so, generating test report, otherwise, the test is marked to use Example code is failure use-case code;Here failure use-case code is the identification use-case code in foregoing type.It is real On border, judgement here is to carry out judging to test whether to pass through to each test case code, for different test cases Code is then labeled as failure use-case code, if to carry out use-case test next time, and is only surveyed to failure use-case code When examination, then the whole failure use-case codes specifically marked are retested.
Test case code is obtained by test code generating method.
Correspondingly, the present invention also proposes a kind of test frame code execution device, including following module:
Load submodule:It is corresponding according to operating file selection load for receiving operating file selection input by user All test case codes of type;
Implementation sub-module:For executing the test case code respectively, and record implementing result;
First judging submodule:For judging whether all test case codes are finished, sentence if so, executing second Disconnected submodule, otherwise returns to implementation sub-module;
Second judgment submodule:Pass through for judging whether test case code is tested, if so, test report is generated, Otherwise, it is failure use-case code to mark the test case code;
The test case code is obtained by test code generating method, wherein the type includes failure use-case code With whole test case codes.
It will be apparent to those skilled in the art that technical solution that can be as described above and design, make various other Corresponding change and deformation, and all these changes and deformation should all belong to the protection domain of the claims in the present invention Within.

Claims (4)

1. a kind of test code generating method, which is characterized in that include the following steps:
Step 1:The script file of read test framework template, and test code file is generated according to the script file;
Step 2:Load test code file receives project name input by user, judges whether to generate use-case code, if so, Step 3 is executed, otherwise, corresponding test frame code and the test block are generated according to project name and test code file Frame code directory;
Step 3:Judge whether to generate interface testing code according to test code file, if so, executing step 4, otherwise, root A whole set of test code is generated according to project name and test code file;
Step 4:Access interface data generate returned data, the test code verified are handled according to returned data, according to school The test code and interface data tested generate a corresponding test case code;
Wherein, the step 4 includes following sub-step:
Step 41:Store path input by user is received, to enter corresponding storage folder;
Step 42:The interface document in the storage folder is parsed, and handles and obtains interface data;
Step 43:Access interface data simultaneously generate returned data, and the test code verified is handled according to returned data, according to The test code and interface data of verification generate a corresponding test case code;
Step 5:Step 4 is repeated, a whole set of test code is generated according to all test case codes and project name;
Wherein, a whole set of described test code includes use-case test code and test frame code.
2. a kind of test code generating unit, which is characterized in that including following module:
Read module:Test code file is generated for the script file of read test framework template, and according to the script file;
Load-on module:For load test code file, project name input by user is received, judges whether to generate use-case generation Otherwise code, corresponding test frame code is generated according to project name and test code file if so, executing judgment module With the test frame code directory;
Judgment module:For judging whether to generate interface testing code according to test code file, mould is accessed if so, executing Otherwise block generates a whole set of test code according to project name and test code file;
Access modules:Returned data is generated for access interface data, the test code verified is handled according to returned data, A corresponding test case code is generated according to the test code and interface data of verification;
Wherein, the access modules specifically include following submodule:
Receiving submodule:For receiving store path input by user, to enter corresponding storage folder;
Analyzing sub-module:For parsing the interface document in the storage folder, and handles and obtain interface data;
Access submodule:For access interface data and returned data is generated, the test verified is handled according to returned data Code generates a corresponding test case code according to the test code and interface data of verification.;
Generation module:For repeated accesses module, a whole set of test generation is generated according to all test case codes and project name Code;
Wherein, a whole set of described test code includes use-case test code and test frame code.
3. a kind of test frame code execution method, which is characterized in that include the following steps:
A1:Operating file selection input by user is received, selects all tests of load respective type to use according to the operating file Example code;Wherein, the type includes at least failure use-case code;
A2:The test case code is executed respectively, and records implementing result;
A3:Judge whether all test case codes are finished, if so, executing A4, otherwise returns to A2;
A4:Judge whether test case code is tested to pass through, if so, otherwise generating test report marks test case generation Code is failure use-case code;
The test case code is obtained by test code generating method described in claim 1.
4. a kind of test frame code execution device, which is characterized in that including following module:
Load submodule:Operating file selection input by user is received, the institute of load respective type is selected according to the operating file There is test case code;Wherein, the type includes at least failure use-case code;
Implementation sub-module:For executing the test case code respectively, and record implementing result;
First judging submodule:For judging whether all test case codes are finished, if so, executing second judges son Otherwise module returns to implementation sub-module;
Second judgment submodule:Pass through for judging whether test case code is tested, if so, test report is generated, otherwise, It is failure use-case code to mark the test case code;
The test case code is obtained by test code generating method described in claim 1.
CN201610443187.1A 2016-06-20 2016-06-20 Test code generating method and device, test frame code execution method and device Active CN106021118B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610443187.1A CN106021118B (en) 2016-06-20 2016-06-20 Test code generating method and device, test frame code execution method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610443187.1A CN106021118B (en) 2016-06-20 2016-06-20 Test code generating method and device, test frame code execution method and device

Publications (2)

Publication Number Publication Date
CN106021118A CN106021118A (en) 2016-10-12
CN106021118B true CN106021118B (en) 2018-09-25

Family

ID=57088860

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610443187.1A Active CN106021118B (en) 2016-06-20 2016-06-20 Test code generating method and device, test frame code execution method and device

Country Status (1)

Country Link
CN (1) CN106021118B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108470004A (en) * 2018-04-09 2018-08-31 平安普惠企业管理有限公司 Test script generation method, test method, device, equipment and storage medium
CN109344053B (en) * 2018-09-03 2023-05-30 平安科技(深圳)有限公司 Interface coverage test method, system, computer device and storage medium
CN109062817B (en) * 2018-10-15 2022-06-03 网宿科技股份有限公司 Automatic testing method and system
CN110262978B (en) * 2019-06-24 2022-12-09 四川新网银行股份有限公司 Interface retry method and device based on long-flow automatic test
CN110309071B (en) * 2019-06-27 2023-01-24 杭州数梦工场科技有限公司 Test code generation method and module, and test method and system
CN113495829A (en) * 2020-03-20 2021-10-12 北京海致星图科技有限公司 Automatic interface testing method and system

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101414935A (en) * 2008-07-09 2009-04-22 北京星网锐捷网络技术有限公司 Method and system for generating test case
CN104035873A (en) * 2014-06-30 2014-09-10 青岛海信电器股份有限公司 Method and device for generating testing codes
CN104572469A (en) * 2015-01-23 2015-04-29 广东能龙教育股份有限公司 Automatic interface testing method and system based on simulative http requests
WO2015174883A1 (en) * 2014-05-15 2015-11-19 Oracle International Corporation Test bundling and batching optimizations
CN105335293A (en) * 2015-11-30 2016-02-17 努比亚技术有限公司 Automatic testing system and method based on parallel ports

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101414935A (en) * 2008-07-09 2009-04-22 北京星网锐捷网络技术有限公司 Method and system for generating test case
WO2015174883A1 (en) * 2014-05-15 2015-11-19 Oracle International Corporation Test bundling and batching optimizations
CN104035873A (en) * 2014-06-30 2014-09-10 青岛海信电器股份有限公司 Method and device for generating testing codes
CN104572469A (en) * 2015-01-23 2015-04-29 广东能龙教育股份有限公司 Automatic interface testing method and system based on simulative http requests
CN105335293A (en) * 2015-11-30 2016-02-17 努比亚技术有限公司 Automatic testing system and method based on parallel ports

Also Published As

Publication number Publication date
CN106021118A (en) 2016-10-12

Similar Documents

Publication Publication Date Title
CN106021118B (en) Test code generating method and device, test frame code execution method and device
CN104077217B (en) The compiling dissemination method and system of code file
CN105022691B (en) A kind of increasingly automated method for testing software based on uml diagram
CN104298588B (en) The implementation method and device of a kind of continuous integrating
CN104794048B (en) A kind of UI automated testing methods and system
US20070094541A1 (en) Method and apparatus for generating test execution sequences automatically for a software testing process
CN107301130A (en) A kind of VR all-in-ones testing tool and its method
CN110221975B (en) Method and device for creating interface case automation test script
CN105095088A (en) Calculator automatic test method and test system based on uiautomator test framework
CN106133537A (en) A kind of FPGA function module emulation verification method and system thereof
CN106055464A (en) Pressure testing device and method for data buffer clusters
CN111444051B (en) Whole machine yield testing method and system for product
CN106598834A (en) UI (User Interface) testing method and device
CN108664386A (en) A kind of automated testing method and platform
CN107783902A (en) A kind of Selenium automated testing methods and system from coding
CN102486748B (en) Method and device for performance test
CN106059853A (en) Network connectivity test method and device
CN109426611A (en) A kind of method for testing software and device
CN110209584A (en) A kind of automatic generation of test data and relevant apparatus
CN103326930A (en) Automatic patrolling method and system for open platform interface
CN104063307A (en) Software testing method and system
CN110134381A (en) A kind of system and method intelligently generating source code configuration for alarm host machine
CN107608841A (en) Hard disk test document generating method, device, equipment and readable storage medium storing program for executing
CN102663205B (en) Software realization method and system for vehicle assembly shop tooling site management
CN107085553B (en) Input box testing method and device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20220331

Address after: 430000 b5-1 b5-2, Wuxue Electronic Information Industrial Park, Huanggang City, Hubei Province

Patentee after: Juzhi Technology (Hubei) Co.,Ltd.

Address before: 518000, 12 floor, Hang Sheng science and technology building, six New South six road, Nanshan District, Guangdong.

Patentee before: SHENZHEN CHARGERLINK TECHNOLOGY Co.,Ltd.