CN108536596A - Automated testing method, readable medium based on object formation data and equipment - Google Patents
Automated testing method, readable medium based on object formation data and equipment Download PDFInfo
- Publication number
- CN108536596A CN108536596A CN201810314553.2A CN201810314553A CN108536596A CN 108536596 A CN108536596 A CN 108536596A CN 201810314553 A CN201810314553 A CN 201810314553A CN 108536596 A CN108536596 A CN 108536596A
- Authority
- CN
- China
- Prior art keywords
- test
- data
- test data
- unit
- tested
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3684—Test management for test design, e.g. generating new test cases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3688—Test 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)
- Test And Diagnosis Of Digital Computers (AREA)
Abstract
The present invention provides a kind of automated testing method based on object formation data, includes the following steps:Extract scripting object;According to the scripting object, test data object is created;According to the test data object, the unit to be tested in the scripting object is extracted;According to the unit to be tested, the corresponding test data of the unit to be tested is created.The test method of the present invention makes test script code be detached with test data, and test data is mapped one by one using test cell as object, and test code script arbitrarily changes test data in test file, without carrying out maintenance modification to test script.Further relate to relevant computer readable storage medium and associated electronic device.
Description
Technical field
The present invention relates to software test field more particularly to a kind of automated testing method based on object formation data,
Related computer readable storage medium and electronic equipment.
Background technology
Existing unit testing, interface testing, automatic test mostly use csv when test data constructs in script,
The files such as xml, excel carry out data to the data of test and are detached with test script, but all test datas are without unified
When in use, correspondence can not effectively be mapped for specification or script, and later maintenance script and test script is caused to be developed
It is of high cost, in writing scenario process, the acquisition of data need to be completed using hard coded mode, makes scripted code maintainability and can
The property read is poor.
Invention content
In order to overcome at least one aspect of the above problem, the embodiment of the present invention provides a kind of based on object formation data
Automated testing method.
According to an aspect of the present invention, a kind of automated testing method based on object formation data is provided, including such as
Lower step:
Step S1 extracts scripting object;
Step S2 creates test data object according to the scripting object;
Step S3 extracts the unit to be tested in the scripting object according to the test data object;
Step S4 creates the corresponding test data of the unit to be tested according to the unit to be tested.
According to some embodiments, step S1 includes:It identifies the scripting object, the scripting object is defined.
According to some embodiments, script described in step S1 is arbitrary programming language.
According to some embodiments, step S2 is by identifying that the scripting object carries out the construction of test data object.
According to some embodiments, step S2 includes:The test data object is stored as yaml files.
According to some embodiments, step S4 includes carrying out test cell number in test data object for the unit to be tested
According to construction.
According to some embodiments, step S4 is including being the test data Object Creation data sub-element, by test data
It is stored as yaml files.
According to another aspect of the present invention, a kind of computer readable storage medium is provided, executable finger is stored thereon with
Enable, instruction when executed by the processor, may be implemented according to any one of above-described embodiment based on object formation number
According to automated testing method the step of.
According to a further aspect of the invention, a kind of electronic equipment is provided, including:
Memory, for storing executable instruction;And
Processor, for executing the executable instruction stored in memory, to realize according to any one of above-described embodiment
The step of described automated testing method based on object formation data.
Compared with prior art, the present invention has the following advantages:Test script code is detached with test data, test data
Mapped one by one using test cell as object, test code script test data is arbitrarily changed in test file, without pair
Test script carries out maintenance modification.
Description of the drawings
By the description made for the present invention of below with reference to attached drawing, other objects and advantages of the present invention will be aobvious and easy
See, and can help that complete understanding of the invention will be obtained.
Fig. 1 is the work flow diagram of the embodiment of the present invention;
Fig. 2 is the general flow chart of the embodiment of the present invention;
Fig. 3 is the call graph of the embodiment of the present invention;
Fig. 4 is the structural schematic diagram of the computer readable storage medium of the embodiment of the present invention;
Fig. 5 is the structural schematic diagram of the electronic equipment of the embodiment of the present invention.
Specific implementation mode
In order to make the object, technical scheme and advantages of the embodiment of the invention clearer, below in conjunction with the embodiment of the present invention
In attached drawing, technical scheme in the embodiment of the invention is clearly and completely described, it is clear that described embodiment is
A part of the embodiment of the present invention, instead of all the embodiments.Based on the embodiments of the present invention, those of ordinary skill in the art
The every other embodiment obtained without making creative work, shall fall within the protection scope of the present invention.
The term used in embodiments of the present invention is the purpose only merely for description specific embodiment, is not intended to be limiting
The present invention.Unless otherwise defined, the technical term or scientific terminology that the present invention uses should be tool in fields of the present invention
There is the ordinary meaning that the personage of general technical ability is understood.
The present invention provides a kind of automated testing method based on object formation data, and according to Fig. 1, this method includes
Following steps:
Step S1 extracts scripting object;
Step S2 creates test data object according to the scripting object extracted;
Step S3 extracts the unit to be tested in scripting object according to the test data object created;
Step S4 creates the corresponding test data of the unit to be tested according to the unit to be tested tested.
Above-mentioned steps are described in detail below.
Step S1 extracts scripting object.Script is the extension of autoexec, is the program that a kind of plain text preserves, one
As for a series of control computers for being to determine of computer script program carry out the combination of arithmetic operation action, wherein may be used
To realize certain logic branch etc..Script in step S1 can be any language, such as can be Ruby this simple fast
The script of prompt object-oriented can also be this object-oriented literal translation formula computer programming languages of Python, may be used also
To be this object oriented program languages that can write cross-platform program of Java, certainly, it is not limited on
Predicate is sayed.
" class " in programming language often refers to the set of a data function, and " object " then has actual memory
Class.If " class " is compared to be a design drawing if, " object " refers to just the material object created according to design drawing.
In the present embodiment, test cell is test object.In step sl, it needs that surveyed script unit object is identified, and
For the convenience of programming, scripting object can be generally defined, such as:class TestCheckWhiteList.Script
Unit object is the class object that test object defines, and that is to say the instantiation of test object, is exactly more by test object construction
A specific object.There are two types of modes for instance object, i.e., instantiate from stack and instantiated from heap.Instance object has from stack
Body mode is as follows, if to define an object, can write following code:TV tv.It, can if defining an object array
To write following code:TV tv[20].And the instance object from heap, then it needs to come out using pointer direction new operator applications
Memory.
Step S2 creates test data object according to the scripting object extracted.By identifying that surveyed scripting object carries out
The construction of test data object identifies that surveyed scripting object that is to say and is read out to surveyed scripting object, checks surveyed script
The testing attribute of object, testing attribute for example can be the types of test, then construct energy according to the testing attribute of scripting object
Enough realize the test data object of test function.For example, scripting object can be TesTCheckWhiteList, this script pair
As if check the white list of main broadcaster, and it checks which main broadcaster has permission and creates radio station, it can be by identifying scripting object
TestCheckWhiteList constructs the test data object of inspection main broadcaster's white list, that is to say and creates corresponding function,
Test data object can be, for example,:
" login in above-mentioned code:{″username″:" Test ", " password ":" 123456 " } " it is to have input main broadcaster
Information, for example, account and password, naturally it is also possible to be the information that other can show that identity, then can reply " 0 ", this
A " 0 " can talk about its concrete meaning below, while also reply " msg ":" operating successfully ", that is to say fed back one operation at
The information of work(illustrates what this function was up.
The good test data object of above-mentioned construction can be stored as yaml files.Yaml is " row is oriented to ", therefore, just
The confusion output want by existing program is calculated, is converted into yaml formats, and retain the appearance of most original document, it is also very simple
It is single.Because it need not balance closed label, bracket and quotation marks, can be generated from formula is simply utilized very much from report
yaml.Equally, space-separated can allow use to go the order being oriented to such as:Grep, Awk, perl, ruby and Python carry out emergency
Filtering yaml files when it is more convenient.And yaml is the language for purely being used for expressing data, so inside will not deposit code
The executable command of injection.This represent parser can quite safe ground resolution file, and without worry it is potential with execution order phase
The security breaches of pass.The simplicity of format conversion and reliable safety allow yaml become in script store data compare
Good selection.
Step S3 extracts the unit to be tested in scripting object according to the test data object created.It that is to say to upper
It states specific unit to be tested in the test data object created in step to extract, that is to say to unit to be tested construction one
A specific function.It is illustrated below with python language, in this section of code below, the test frame used is
Pyunit may be implemented automatic unit using pyunit and test, can obtain data by frame here, i.e., by obtaining class
Method that is to say specific test cell, and then by object map, that is to say and call corresponding function, specific to obtain
Data.Specific test script can be such as:
deftest_case01_normal(self):
The normal scenes of u " ':Whether inquiry live streaming platform main broadcaster, which has permission, creates radio station (white list control), main in white list
Id is broadcast, return can create (0) " '
Current_method=sys._getframe () .f_code.co_name
Get_data=self.testdata [self.class_name] [current_method] [' get_data ']
In above-mentioned code, " current_method=sys._getframe () .f_code.co_name ", which indicates to obtain, to be worked as
Preceding class method, that is to say specific test cell, " get_data=self.testdata [self.class_name]
[current_method] [' get_data '] " then represents specific data.Test script object unit that is to say specific
Test cell can be the test case01normal in above-mentioned script.
Step S4 creates the corresponding test data of the unit to be tested according to the unit to be tested tested.It can create
Test object data sub-element, such as can be interface unit.The above-mentioned test data created can be stored as to yaml texts
Part.In this way, just having constructed test data according to test cell.For example, then above-mentioned example, it is corresponding to create unit to be tested
Data, specific data are as follows:
Data in above-mentioned code include the identity of user, the identity of thread and server address, certainly, no
It is limited to above-mentioned parameter.It has been then back to " 0 ", has illustrated that the main broadcaster in this room has permission and creates radio station.And test cell, it that is to say
Function module has the function of inspection mistake, by calling corresponding function, specific test data is that is to say, to test
Unit is tested, in this way, test data and test cell just reached separation as a result, and being realized by call function
The one-to-one correspondence of test data and test cell that is to say that test data is mapped one by one using test cell as object.
The present embodiment carries out the construction of test data by using the mode of object, is test object by test cell,
The construction of test data is carried out according to test cell, realizes that test script code is detached with test data in script edit, is tested
Data are mapped one by one using test cell as object, and test code script arbitrarily changes test data, nothing in test file
Maintenance modification need to be carried out to test script.It realizes that test script is maintainable and readable strong, while enhancing test script robust
Property.
Fig. 2 is the general flow chart of the embodiment of the present invention, can be further simplified whole process by Fig. 2.
First, test object is extracted;Then, test data object is constructed according to the test object of extraction;Then, extraction is surveyed
Try the method unit of object;Finally, the data according to the method unit construction test object method unit of the test object of extraction.
Fig. 3 is the call graph of the embodiment of the present invention.
For convenience of description, " extraction test script object " module is denoted as A, it will be " based on extraction test script object
Construction test data object " module is denoted as B, and " extraction test script object method unit " module is denoted as C, will be " based on extraction
Test script object method unit construction test data unit " module is denoted as D.
First, the program of A is directly write, then B and C can directly invoke A, and D can directly invoke B and C, each to have
The unit to be tested of body can call C and D, for example, unit testing script, interface testing, UI automatic tests can call C
And D, it is tested using the test data created, has also achieved the purpose that test code and test data separation.
Based on same inventive concept, refering to what is shown in Fig. 4, the present invention also provides a kind of computer readable storage medium 401,
On be stored with executable instruction 402, executable instruction 402 when executed by one or more processors, may be implemented according to upper
The step of stating the automated testing method based on object formation data described in any one of embodiment.
Based on same inventive concept, refering to what is shown in Fig. 5, the present invention also provides a kind of electronic equipment 501, the electronic equipment
501 include:
Memory 510, for storing executable instruction 511;And
Processor 520, for executing the executable instruction 511 stored in memory 510, to realize as in above-described embodiment
The step of automated testing method of any one of them based on object formation data.
Finally it should be noted that:The above embodiments are merely illustrative of the technical solutions of the present invention, rather than its limitations;Although
Present invention has been described in detail with reference to the aforementioned embodiments, it will be understood by those of ordinary skill in the art that:It still may be used
With technical scheme described in the above embodiments is modified or equivalent replacement of some of the technical features;
And these modifications or replacements, various embodiments of the present invention technical solution that it does not separate the essence of the corresponding technical solution spirit and
Range.
Claims (9)
1. a kind of automated testing method based on object formation data, which is characterized in that including:
Step S1 extracts scripting object;
Step S2 creates test data object according to the scripting object;
Step S3 extracts the unit to be tested in the scripting object according to the test data object;
Step S4 creates the corresponding test data of the unit to be tested according to the unit to be tested.
2. according to the method described in claim 1, it is characterized in that, the step S1 includes:The scripting object is identified, to institute
Scripting object is stated to be defined.
3. according to the method described in claim 1, it is characterized in that, script described in the step S1 is arbitrary programming language.
4. according to the method described in claim 2, it is characterized in that, the step S2 is by identifying that the scripting object is surveyed
Try the construction of data object.
5. according to the method described in claim 1, it is characterized in that, the step S2 includes:The test data object is deposited
Storage is yaml files.
6. according to the method described in claim 1, it is characterized in that, the step S4 includes being surveyed for the unit to be tested
Try the construction of test cell data in data object.
7. according to the method described in claim 1, it is characterized in that, the step S4 includes being the test data Object Creation
Test data is stored as yaml files by data sub-element.
8. a kind of computer readable storage medium, is stored thereon with executable instruction, described instruction is when executed by the processor, real
Now the step of automated testing method based on object formation data according to any one of claim 1-7.
9. a kind of electronic equipment, including:
Memory, for storing executable instruction;And
Processor, for executing the executable instruction stored in the memory, to realize according to any one of claim 1-7
The step of described automated testing method based on object formation data.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810314553.2A CN108536596A (en) | 2018-04-09 | 2018-04-09 | Automated testing method, readable medium based on object formation data and equipment |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810314553.2A CN108536596A (en) | 2018-04-09 | 2018-04-09 | Automated testing method, readable medium based on object formation data and equipment |
Publications (1)
Publication Number | Publication Date |
---|---|
CN108536596A true CN108536596A (en) | 2018-09-14 |
Family
ID=63480616
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810314553.2A Pending CN108536596A (en) | 2018-04-09 | 2018-04-09 | Automated testing method, readable medium based on object formation data and equipment |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108536596A (en) |
Cited By (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109800154A (en) * | 2018-12-15 | 2019-05-24 | 深圳壹账通智能科技有限公司 | Loading method, device, computer equipment and the storage medium of test data |
CN111026666A (en) * | 2019-12-06 | 2020-04-17 | 京东数字科技控股有限公司 | Test data processing method, device, computer system and medium |
CN111176973A (en) * | 2018-11-13 | 2020-05-19 | 北京京东尚科信息技术有限公司 | Test method, system, electronic device and computer readable medium |
CN111324526A (en) * | 2018-12-14 | 2020-06-23 | 北京金山云网络技术有限公司 | Interface test system, method and server |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105630685A (en) * | 2016-01-29 | 2016-06-01 | 广州酷狗计算机科技有限公司 | Method and device for testing program interface |
WO2016206113A1 (en) * | 2015-06-26 | 2016-12-29 | Intel Corporation | Technologies for device independent automated application testing |
CN106294184A (en) * | 2016-08-30 | 2017-01-04 | 广州华多网络科技有限公司 | The graphical creation method of test scene, device and terminal unit |
CN107015908A (en) * | 2017-03-31 | 2017-08-04 | 广州慧睿思通信息科技有限公司 | A kind of computer application software test system and method |
CN107329891A (en) * | 2017-06-06 | 2017-11-07 | 千寻位置网络有限公司 | Automation regression testing method based on structural data and REST interfaces |
CN107766252A (en) * | 2017-11-08 | 2018-03-06 | 平安科技(深圳)有限公司 | Test script automated execution method, apparatus, equipment and storage medium |
-
2018
- 2018-04-09 CN CN201810314553.2A patent/CN108536596A/en active Pending
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2016206113A1 (en) * | 2015-06-26 | 2016-12-29 | Intel Corporation | Technologies for device independent automated application testing |
CN105630685A (en) * | 2016-01-29 | 2016-06-01 | 广州酷狗计算机科技有限公司 | Method and device for testing program interface |
CN106294184A (en) * | 2016-08-30 | 2017-01-04 | 广州华多网络科技有限公司 | The graphical creation method of test scene, device and terminal unit |
CN107015908A (en) * | 2017-03-31 | 2017-08-04 | 广州慧睿思通信息科技有限公司 | A kind of computer application software test system and method |
CN107329891A (en) * | 2017-06-06 | 2017-11-07 | 千寻位置网络有限公司 | Automation regression testing method based on structural data and REST interfaces |
CN107766252A (en) * | 2017-11-08 | 2018-03-06 | 平安科技(深圳)有限公司 | Test script automated execution method, apparatus, equipment and storage medium |
Non-Patent Citations (1)
Title |
---|
戴夫•托马斯: "《Rails 5敏捷开发》", 31 January 2018, 华中科技大学出版社 * |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111176973A (en) * | 2018-11-13 | 2020-05-19 | 北京京东尚科信息技术有限公司 | Test method, system, electronic device and computer readable medium |
CN111176973B (en) * | 2018-11-13 | 2024-02-02 | 北京京东尚科信息技术有限公司 | Test method, system, electronic device, and computer-readable medium |
CN111324526A (en) * | 2018-12-14 | 2020-06-23 | 北京金山云网络技术有限公司 | Interface test system, method and server |
CN111324526B (en) * | 2018-12-14 | 2024-04-26 | 北京金山云网络技术有限公司 | Interface test system, method and server |
CN109800154A (en) * | 2018-12-15 | 2019-05-24 | 深圳壹账通智能科技有限公司 | Loading method, device, computer equipment and the storage medium of test data |
CN111026666A (en) * | 2019-12-06 | 2020-04-17 | 京东数字科技控股有限公司 | Test data processing method, device, computer system and medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10235142B1 (en) | Code generator tool for building software applications with reusable components | |
CN108536596A (en) | Automated testing method, readable medium based on object formation data and equipment | |
CN104484216B (en) | Service interface document and on-line testing instrument generation method, device | |
US7272822B1 (en) | Automatically generating software tests based on metadata | |
US20130275946A1 (en) | Systems and methods for test development process automation for a test harness | |
US20050188271A1 (en) | Method and system for rule-based generation of automation test scripts from abstract test case representation | |
US8949790B2 (en) | Debugging visual and embedded programs | |
CA2553441A1 (en) | Method and system for conversion of automation test scripts into abstract test case representation with persistence | |
CN108845940A (en) | A kind of enterprise information system automated function test method and system | |
CN106294134A (en) | The collapse localization method of code and device | |
US11288062B2 (en) | Automatic source code refactoring | |
Mushtaq et al. | Multilingual source code analysis: State of the art and challenges | |
Fdez‐Riverola et al. | A JAVA application framework for scientific software development | |
CN106919374B (en) | Script generation method and device | |
US10042638B2 (en) | Evaluating documentation coverage | |
CN109522507B (en) | Method for uniformly managing webpage components | |
CN102541564A (en) | UI (User Interface) multiplexing method and device | |
Sun et al. | Extending linden scripting language on OpenSim | |
Moore et al. | Python GUI Programming-A Complete Reference Guide: Develop responsive and powerful GUI applications with PyQt and Tkinter | |
CN103782271B (en) | For the method for developing and realizing portal website and corresponding computer program product | |
Parnas et al. | An easily extensible toolset for tabular mathematical expressions | |
CN113342399A (en) | Application structure configuration method and device and readable storage medium | |
Del Fabro et al. | Industrial-strength Rule Interoperability using Model Driven Engineering | |
Aponte et al. | MQP: Soft. Eng. Capstone | |
Lin et al. | Towards verifying VDM using SPIN |
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 | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20180914 |