CN108804331A - A kind of auto ordering method of automatic test cases - Google Patents

A kind of auto ordering method of automatic test cases Download PDF

Info

Publication number
CN108804331A
CN108804331A CN201810606162.8A CN201810606162A CN108804331A CN 108804331 A CN108804331 A CN 108804331A CN 201810606162 A CN201810606162 A CN 201810606162A CN 108804331 A CN108804331 A CN 108804331A
Authority
CN
China
Prior art keywords
case
substitute character
test
title
character
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
Application number
CN201810606162.8A
Other languages
Chinese (zh)
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.)
Zhengzhou Yunhai Information Technology Co Ltd
Original Assignee
Zhengzhou Yunhai Information 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 Zhengzhou Yunhai Information Technology Co Ltd filed Critical Zhengzhou Yunhai Information Technology Co Ltd
Priority to CN201810606162.8A priority Critical patent/CN108804331A/en
Publication of CN108804331A publication Critical patent/CN108804331A/en
Pending legal-status Critical Current

Links

Classifications

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

Landscapes

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

Abstract

The embodiment of the invention discloses a kind of auto ordering methods of automatic test cases, including:Metaclass is created in test frame;Obtain test case;The test case inherits the metaclass;It is modified to use-case title by the metaclass of succession;Modified use-case title is arranged by ascending order.Metaclass is created in the embodiment of the present invention in test frame, test case modifies to itself title to reach by the metaclass in Inherit Testing frame, it is modified to the title of test case in a manner of ascending order according to the sequence of writing of test case, the use-case title kidney deficiency arranging functional that test frame itself has is combined again, to realize that test case first writes the purpose first carried out, it need not manually modify, and change name format and meet preparation request, improve testing efficiency.

Description

A kind of auto ordering method of automatic test cases
Technical field
The present invention relates to automatization testing technique fields, more particularly to a kind of auto-sequencing side of automatic test cases Method.
Background technology
Test case is that the behavioral activity of software test is done a scientific tissue to conclude, it is therefore an objective to can be by software The behavior of test is converted to manageable pattern, while test case is also one of the method for specifically quantifying test, inhomogeneity Other software, test case are different.Different from such as system, tool, control, Games Software, the user of management software needs Seek more different trend.
In unittest unit testing frames, the basic python language of automatic test cases module is with the lattice of class Formula exists, and automation use-case exists with the format of function, wherein the entitled test_ beginnings of automation use-case, test frame Test frame is added in the function that test_ beginnings can be matched, and automatic test is executed according to automation use-case title.Because surveying Auto arrangement can be carried out according to the ascending order of test case title to test case by trying frame, therefore can lead to the execution of test case Sequence is not instead of top-down to write sequence, the ascending order of test case title.In order to which control test case executes sequence, Common method is, when writing test case, increases test case title manually, English is added between test_ and function Word mother is sorted in order.
However, in the prior art.The literary style that English alphabet is sorted in order is added between test_ and function Coding rule is not met, very big additional workload is caused when being inserted into or deleting use-case, and test case is large number of, It is difficult to carry out the manual modification of title, affects testing efficiency.
Invention content
A kind of auto ordering method of automatic test cases is provided in the embodiment of the present invention, to solve in the prior art The low problem of testing efficiency.
In order to solve the above-mentioned technical problem, the embodiment of the invention discloses following technical solutions:
The present invention provides a kind of auto ordering methods of automatic test cases, including:
Metaclass is created in test frame;
Obtain test case;
The test case inherits the metaclass;
It is modified to use-case title by the metaclass of succession;
Modified use-case title is arranged by ascending order.
Preferably, it is modified and is specifically included to use-case title by the metaclass of succession:
To the metaclass injection use-case title and modification data of succession;
The modification data are executed to modify to the use-case title.
Preferably, the execution modification data, which modify to the use-case title, specifically includes:
Obtain use-case title;
It determines in the use-case title and is replaced character;
Define substitute character length;
Obtain history substitute character;
Substitute character is determined according to the history substitute character and substitute character length;
It is replaced character described in substitute character replacement;
Replaced use-case name is referred to as to new use-case title.
Preferably, the substitute character is numerical character.
Preferably, the history substitute character preserves in a register.
Preferably, determine that substitute character specifically includes according to the history substitute character and substitute character length:
Add one operation is carried out to the history substitute character;
It is consistent by the length of operation result and substitute character length adjustment;
Using the operation result after adjustment as substitute character.
Preferably, when the length of the operation result is less than the substitute character length, in the operation result highest The preceding spot patch in position is neat.
Preferably, the substitute character length is greater than or equal to the length of test case maximum number.
Preferably, it is replaced described in substitute character replacement after character and further includes:Add after the substitute character Add use case description.
By above technical scheme as it can be seen that creating metaclass in the present invention in test frame, test case passes through Inherit Testing Metaclass in frame modifies to itself title to reach, and sequence is write in a manner of ascending order to surveying according to test case The title of example on probation is modified, and combines test frame itself the use-case title kidney deficiency arranging functional having, to realize Test case first writes the purpose first carried out, need not manually modify, and changes name format and meet preparation request, improves Testing efficiency.
Description of the drawings
It is illustrated more clearly that the embodiment of the present invention or technical solution in the prior art, it below will be to embodiment or existing Attached drawing is briefly described needed in technology description, it should be apparent that, for those of ordinary skills, Without creative efforts, other drawings may also be obtained based on these drawings.
Fig. 1 is a kind of flow diagram of the auto ordering method of automatic test cases provided in an embodiment of the present invention;
Fig. 2 is the flow diagram of the method provided in an embodiment of the present invention modified to use-case title;
Fig. 3 is the flow diagram of the method for determining substitute character provided in an embodiment of the present invention.
Specific implementation mode
In order to make those skilled in the art more fully understand the technical solution in the present invention, below in conjunction with of the invention real The attached drawing in example is applied, technical scheme in the embodiment of the invention is clearly and completely described, it is clear that described implementation Example is only a part of the embodiment of the present invention, instead of all the embodiments.Based on the embodiments of the present invention, this field is common The every other embodiment that technical staff is obtained without making creative work, should all belong to protection of the present invention Range.
It is that a kind of flow of the auto ordering method of automatic test cases provided in an embodiment of the present invention is shown referring to Fig. 1 It is intended to, as shown in Figure 1, the auto ordering method of automatic test cases provided in an embodiment of the present invention, including:
S10:Metaclass is created in test frame.
The function to the according to first letter female progress ascending order arrangement of use-case title is contained in test frame used in test case, Therefore, it is desirable to must modify to use-case title by certain rule compositor to use-case title.But test case is One group of compiled code, the function that add name modifications wherein is relatively difficult to achieve, therefore by being created in test frame Metaclass is realized.Class is to realize the basis of Information encapsulation, is a kind of user defined type.Each class includes data explanation and one group Operation data or the function for transmitting message, the example of class is known as object, wherein metaclass can be generated pair with class as template As being the class of class, because class can inherit his father's sector of breakdown or whole properties and metaclass itself and can be endowed variable Property, can be by making test case have the property of metaclass to realize the modification of use-case title.
S20:Obtain test case.
After having created metaclass in test frame, test frame be provided with can to the function that itself modifies, but because It is a kind of function that test frame has for the therefore metaclass that need not modify to test frame, but its own can't make With, therefore directly acquire test case after metaclass creates.
S30:The test case inherits the metaclass.
After test case acquisition finishes, test frame can be ranked up according to its title initial in the prior art, Therefore, it in order to realize the purpose arranged by use-case acquisition sequence, needs before test frame auto-sequencing to use-case title It modifies, therefore, after getting test case, test case is allowed to be inherited immediately to metaclass, test case is made to have There is property identical with metaclass, because for the relationship of test frame and test case, the class of test frame grade belongs to parent, Test case belongs to subclass, and subclass can inherit parent, therefore, test case can to the parent in test frame into Row is inherited.
S40:It is modified to use-case title by the metaclass of succession.
Test case can modify to itself title by realizing metaclass after being finished to first Similar integral, realize Process includes two steps:Use-case title and modification data are injected to the metaclass of succession and execute the modification data to described Use-case title is modified.
Use-case title can be read out itself title by the function of metaclass, and the name read, which is referred to as variable, to be assigned It is worth to metaclass, the title is allow to be changed, modification data is the one group of code modified to use-case title, by use-case title It is modified to use-case title as variable assignments to modification data can be directly invoked after metaclass.
Referring to Fig. 2, the flow for the method modified to use-case title for modification data provided in an embodiment of the present invention is shown It is intended to, is specifically included as shown in Fig. 2, executing the modification data and modifying to the use-case title:
S41:Obtain use-case title.
Because metaclass has the property for assigning variable, therefore during carrying out use-case name modifications by changing file The use-case title of acquisition is the first class variable obtained, is modified to the variable.
S42:It determines in the use-case title and is replaced character.
Because the title of test case is started with test_, thereafter with for function, therefore can be by test_ Alphabet later is defined as being replaced character, and certainly, user can voluntarily determination be replaced character as needed, but not Test_ can be defined as being replaced character, in order to avoid influence being normally carried out for test.
S43:Define substitute character length.
Substitute character is to be replaced character in replacement use-case title, therefore the length of substitute character cannot be long, One, secondly the number of characters for needing to judge when auto-sequencing can be made as small as possible, can shorten sequence to avoid the waste of resource Time.For intuitive the considerations of showing, the substitute character in the embodiment of the present invention is numerical character, i.e., will be replaced character replacement For set of number string.
S44:Obtain history substitute character.
The embodiment of the present invention is ranked up by i.e. acquisition sequence is write, and therefore, for the use-case title changed, is repaiied Result after changing is had to as the ascending order of previous use-case title, therefore needs to obtain history substitute character, and history substitute character exists It can be automatically saved in register after last time use-case name modifications, read and connect directly from register when this is changed, If this time use-case name modifications are to change for the first time, without preserving numerical value in register, the history got at this time replaces word Symbol is 0.
S45:Substitute character is determined according to the history substitute character and substitute character length.
It obtains history character and the significant character in substitute character is determined according to the principle of ascending order later, in the word according to setting It accords with length and finally determines substitute character content, be the stream of the method for determining substitute character provided in an embodiment of the present invention referring to Fig. 3 Journey schematic diagram, as shown in figure 3, determining that substitute character specifically includes according to the history substitute character and substitute character length:
S451:Add one operation is carried out to the history substitute character.
S452:It is consistent by the length of operation result and substitute character length adjustment.
S453:Using the operation result after adjustment as substitute character.
Because the substitute character in the embodiment of the present invention uses numerical character, therefore, to realize that ascending order value is needed in history Add operation is carried out on the basis of substitute character, for reduction character length as few as possible, added numerical value is 1 every time, Result after each operation is complete is a numeric string, and because the reason of test case number, the effective digital length meeting of numeric string Inconsistent, for example, when operation result is 11, numeric string effective digital length is 2, but when operation result position 111, effective digital Length is 3, is from first because the auto-sequencing function used in the present invention is ascending order arrangement included in test frame What character started to judge, because 11 and 111 length not always, is easy to occur when determining third character wrongheaded Situation keeps its length identical as the substitute character length of setting therefore, it is necessary to which operation result is adjusted to unified length.
For substitute character length need to illustrate when, substitute character length has to be larger than or equal to maximum of test case Several length, for example, the maximum number of test case is 10000, then substitute character length is at least 5 characters, when test is used When the number of example is 99999, substitute character degree at least should be 5 characters, ensure that its length can completely preserve add one operation Result afterwards.When being less than the substitute character length of setting for the effective digital length of operation result, in the highest of operation result The preceding spot patch in position is neat, for example, operation result is 11, and substitute character length is 5 characters, the then replacement after length adjustment Character is 00011, effective digital or 11, but its length becomes 5 characters.
S46:It is replaced in use-case title with the substitute character and is replaced character.
S47:Replaced use-case name is referred to as to new use-case title.
Substitute character is replaced the character that is replaced in use-case title by the property of metaclass after determining, use example Title becomes the string number symbol started with test_, and as new use-case title.
S50:Modified use-case title is arranged by ascending order.
Modified use-case title carries out auto-sequencing by the ranking function in test frame, to realize test case It first writes and first sorts, to the purpose executed by sequence is write.
Because it is difficult to intuitively check the function that the use-case is realized after use-case title is indicated with numeric string, therefore It is replaced described in substitute character replacement after character and further includes:Use case description is added after the substitute character.It should The operation of function or progress that test case is realized is added in the form of keyword after numerical character, because of test frame In have been able to carry out ascending sort by reading numerical character in auto-sequencing, therefore add test after numerical character Use case description does not interfere with the sequence of test case.
Metaclass is created in the present invention in test frame, test case is reached by the metaclass in Inherit Testing frame It modifies to itself title, the title of test case is repaiied in a manner of ascending order according to the sequence of writing of test case Change, and combine test frame itself the use-case title kidney deficiency arranging functional having, is first held to realize that test case is first write Capable purpose need not manually modify, and change name format and meet preparation request, improve testing efficiency.
The above is only the specific implementation mode of the present invention, is made skilled artisans appreciate that or realizing this hair It is bright.Various modifications to these embodiments will be apparent to one skilled in the art, as defined herein General Principle can be realized in other embodiments without departing from the spirit or scope of the present invention.Therefore, of the invention It is not intended to be limited to the embodiments shown herein, and is to fit to and the principles and novel features disclosed herein phase one The widest range caused.

Claims (9)

1. a kind of auto ordering method of automatic test cases, which is characterized in that including:
Metaclass is created in test frame;
Obtain test case;
The test case inherits the metaclass;
It is modified to use-case title by the metaclass of succession;
Modified use-case title is arranged by ascending order.
2. according to the method described in claim 1, it is characterized in that, the metaclass by succession modifies to use-case title It specifically includes:
To the metaclass injection use-case title and modification data of succession;
The modification data are executed to modify to the use-case title.
3. according to the method described in claim 2, being repaiied to the use-case title it is characterized in that, executing the modification data Change and specifically includes:
Obtain use-case title;
It determines in the use-case title and is replaced character;
Define substitute character length;
Obtain history substitute character;
Substitute character is determined according to the history substitute character and substitute character length;
It is replaced character described in substitute character replacement;
Replaced use-case name is referred to as to new use-case title.
4. according to the method described in claim 3, it is characterized in that, the substitute character is numerical character.
5. according to the method described in claim 3, it is characterized in that, the history substitute character preserves in a register.
6. according to the method described in claim 3, it is characterized in that, true according to the history substitute character and substitute character length Determine substitute character to specifically include:
Add one operation is carried out to the history substitute character;
It is consistent by the length of operation result and substitute character length adjustment;
Using the operation result after adjustment as substitute character.
7. according to the method described in claim 6, it is characterized in that, the length when the operation result is less than the substitute character It is neat with spot patch before the operation result highest order when length.
8. the method according to the description of claim 7 is characterized in that the substitute character length is greater than or equal to test case most The length of big number.
9. according to any methods of claim 3-8, which is characterized in that be replaced word described in substitute character replacement Further include after symbol:Use case description is added after the substitute character.
CN201810606162.8A 2018-06-13 2018-06-13 A kind of auto ordering method of automatic test cases Pending CN108804331A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810606162.8A CN108804331A (en) 2018-06-13 2018-06-13 A kind of auto ordering method of automatic test cases

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810606162.8A CN108804331A (en) 2018-06-13 2018-06-13 A kind of auto ordering method of automatic test cases

Publications (1)

Publication Number Publication Date
CN108804331A true CN108804331A (en) 2018-11-13

Family

ID=64085769

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810606162.8A Pending CN108804331A (en) 2018-06-13 2018-06-13 A kind of auto ordering method of automatic test cases

Country Status (1)

Country Link
CN (1) CN108804331A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114328209A (en) * 2021-12-24 2022-04-12 苏州浪潮智能科技有限公司 Automatic test plug-in generation method, device, equipment and storage medium

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101833507A (en) * 2010-05-04 2010-09-15 王轶辰 Method for testing software based on testing framework
CN106502892A (en) * 2016-10-20 2017-03-15 杭州电子科技大学 A kind of test case prioritization method based on uml model

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101833507A (en) * 2010-05-04 2010-09-15 王轶辰 Method for testing software based on testing framework
CN106502892A (en) * 2016-10-20 2017-03-15 杭州电子科技大学 A kind of test case prioritization method based on uml model

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
煎煎煎饼: "扩展Python的unittest框架", 《HTTPS://WWW.JIANSHU.COM/P/D65F97723AF7》 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114328209A (en) * 2021-12-24 2022-04-12 苏州浪潮智能科技有限公司 Automatic test plug-in generation method, device, equipment and storage medium
CN114328209B (en) * 2021-12-24 2023-11-03 苏州浪潮智能科技有限公司 Automatic test plug-in generation method, device, equipment and storage medium

Similar Documents

Publication Publication Date Title
US8201140B2 (en) System and method for creating and using graphical object instances in a statechart environment
CN109684057B (en) Task processing method and device and storage medium
US20060168557A1 (en) Methods and apparatus for implementing model-based software solution development and integrated change management
US11579856B2 (en) Multi-chip compatible compiling method and device
CN1530817A (en) Guide of effective content: execution of task and structural content
CN104407863A (en) Abstract control model programming device and method
CN104679519A (en) Method and device for acquiring functions of graphic user interface software
CN1828597A (en) Styling mechanism for enriching user interface design
CN111158666B (en) Entity normalization processing method, device, equipment and storage medium
CN105630514A (en) Form designing method based on modularization
CN102915228A (en) Menu toolbar integration system and method
CN108694114A (en) Method and its system for detaching test case, test script and test data
CN107330014A (en) The creation method and equipment of a kind of tables of data
CN109582382B (en) Loading method and device of configuration information, storage medium and terminal equipment
CN108804331A (en) A kind of auto ordering method of automatic test cases
CN109325217A (en) A kind of document conversion method, system, device and computer readable storage medium
CN100346308C (en) Automatic test method based on database operation
CN102467376B (en) Modification method and device for character information
CN116185853A (en) Code verification method and device
US9189249B2 (en) Method for automatically defining icons
CN116955393A (en) Data processing method and device, electronic equipment and storage medium
CN108962335A (en) A kind of test device and method that memory circulation note is wrong
CN110262790B (en) Component generation method and device, storage medium and terminal equipment
CN114003152A (en) Application icon management method and system
CN111241395A (en) Authentication service recommendation method and device

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: 20181113