CN102096630B - Software testing method and device - Google Patents

Software testing method and device Download PDF

Info

Publication number
CN102096630B
CN102096630B CN 200910242386 CN200910242386A CN102096630B CN 102096630 B CN102096630 B CN 102096630B CN 200910242386 CN200910242386 CN 200910242386 CN 200910242386 A CN200910242386 A CN 200910242386A CN 102096630 B CN102096630 B CN 102096630B
Authority
CN
China
Prior art keywords
class
key word
layer
behavior
tested software
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
CN 200910242386
Other languages
Chinese (zh)
Other versions
CN102096630A (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.)
Datang Mobile Communications Equipment Co Ltd
Original Assignee
Datang Mobile Communications Equipment 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 Datang Mobile Communications Equipment Co Ltd filed Critical Datang Mobile Communications Equipment Co Ltd
Priority to CN 200910242386 priority Critical patent/CN102096630B/en
Publication of CN102096630A publication Critical patent/CN102096630A/en
Application granted granted Critical
Publication of CN102096630B publication Critical patent/CN102096630B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Stored Programmes (AREA)

Abstract

The embodiment of the invention discloses a software testing method and device. The method comprises the following steps: acquiring a use case and a verification point of software to be tested; calling behaviour keywords of the software to be tested according to the use case, calling data keywords of the software to be tested according to the verification point, and controlling execution of corresponding behaviours in the behaviour keywords according to the parameter value of the attribute provided by the data keywords; and acquiring the execution result of the behaviour keywords stored in the data keywords. By applying the invention, object-oriented software testing is realized.

Description

A kind of method for testing software and device
Technical field
The present invention relates to communication technical field, particularly relate to a kind of method for testing software and device.
Background technology
For the software test industry, depend merely on simple manual test and can not meet the demands far away.The manual test life period is tight, reliability is low, the shortage of manpower, can't guarantee consistance, the defective such as can't repeat.Comparatively speaking, automation software testing fast, can repetition, high coverage rate, high reliability, reusability be strong etc., and advantage just in time can be made up.
The automation software testing of main flow is developed generally based on technology such as recording and playback, data-driven, key word drivings on the market at present.Take as described in Figure 1 login window as example describes, specifically comprise the following steps:
1, record: record step and be divided into for 3 steps: input input password sa in user name sa, password text box in the user name text box, click " login (L) " button.
2, script and data separating: the user name sa that uses and password sa are stored in outside Excel form, correlation parameter variable replacing in script, term is parametrization.
3, inputting user name, input password, clicking these 3 steps of login button and be abstracted into a function, multiplexing for different use-cases as key word.
In realizing process of the present invention, the inventor finds prior art, and there are the following problems at least:
The shortcoming of prior art is as follows:
1, the GUI object adopts the mode of static identification, and when object or a little variation of object properties generation, all script playback that object is relevant therewith will be failed.
2, the combination of operation steps abstract be key word, be similar to that similar statement is organized into function is the same, level of abstraction is low, is unfavorable for follow-up maintenance.
3, the whole design concept of traditional test framework is structured on procedure-oriented exactly, is not inconsistent with existing object based programming trend.
4, the exploitation of test script must be developed fully at tested software and just can be begun after completing, and causes the exploitation of automation software testing script cannot be parallel with the exploitation of tested software.
Summary of the invention
Embodiments of the invention provide a kind of method for testing software and device, are used for realizing based on OO software test.
Embodiments of the invention provide a kind of method for testing software, comprising:
Obtain use-case and the check post of tested software;
Call the behavior class of the key word of described tested software according to described use-case, call the data class of the key word of described tested software according to described check post, and the parameter value of the attribute that provides according to described data class is controlled the execution of corresponding behavior in described behavior class;
Obtain the execution result that is stored in the described behavior class in described data class.
Wherein, before the behavior class of the described key word that calls described tested software according to described use-case, comprising: the Window layer of setting up described tested software;
The described Window layer of setting up described tested software specifically comprises:
Analyze the window of described tested software, extract key word, described key word is corresponding with described window;
According to described key word, extract the attribute of described key word, the composition data class;
According to described key word, extract the behavior of described key word, the constituting action class.
Wherein, described Window layer is comprised of object, before the described Window layer of setting up described tested software, comprising: the object layer of setting up described tested software;
The described object layer of setting up described tested software specifically comprises:
Identify the object of described tested software; And/or
Encapsulate basic control.
Wherein, the execution of controlling corresponding behavior in described behavior class of the parameter value of the described attribute that provides according to described data class comprises any in following two kinds of situations:
When the parameter value of the attribute that described data class provides is not empty, by the described object of described object layer dynamic lookup; Described object is carried out the described and corresponding behavior of described parameter value; Or
When the parameter value of the attribute that described data class provides is empty, object corresponding to described attribute do not carried out and the described corresponding behavior of described parameter value.
Wherein, also comprise:
Whether window corresponding to object judgement by described object layer ejects.
Wherein, before the behavior class of the described key word that calls described tested software according to described use-case, also comprise:
Set up the data Layer of described tested software, described data class and described behavior class are configured in described data Layer;
Set up bottom script, superclass and the top layer class of script layer, described bottom script is inherited described superclass, and described superclass is inherited described top layer class;
Wherein, described attribute comprises input parameter and/or output parameter;
Also comprise: described execution result and desired value are compared.
Embodiments of the invention provide a kind of software testing device, comprising:
The first acquisition module is used for the use-case and the check post that obtain tested software;
Execution module, be used for calling according to described use-case the behavior class of the key word of described tested software, call the data class of the key word of described tested software according to described check post, and the parameter value of the attribute that provides according to described data class is controlled the execution of corresponding behavior in described behavior class;
The second acquisition module is for the execution result that obtains the described behavior class that is stored in described data class.
Wherein, also comprise: set up module, be used for setting up the Window layer of described tested software;
The described module of setting up specifically is used for:
Analyze the window of described tested software, extract key word, described key word is corresponding with described window;
According to described key word, extract the attribute of described key word, the composition data class;
According to described key word, extract the behavior of described key word, the constituting action class.
Wherein, the described module of setting up also is used for: the object layer of setting up described tested software;
The described module of setting up specifically is used for:
Identify the object of described tested software; And/or
Encapsulate basic control.
Wherein, described execution module specifically is used for:
When the parameter value of the attribute that described data class provides is not empty, by the described object of described object layer dynamic lookup; Described object is carried out the described and corresponding behavior of described parameter value; Or
When the parameter value of the attribute that described data class provides is empty, object corresponding to described attribute do not carried out and the described corresponding behavior of described parameter value.
Wherein, described execution module also is used for:
Whether window corresponding to object judgement by described object layer ejects.
Wherein, the described module of setting up also is used for:
Set up the data Layer of described tested software, described data class and described behavior class are configured in described data Layer;
Set up bottom script, superclass and the top layer class of script layer, described bottom script is inherited described superclass, and described superclass is inherited described top layer class.
Wherein, described attribute comprises input parameter and/or output parameter;
Also comprise: comparison module is used for described execution result and desired value are compared.
Embodiments of the invention have the following advantages: by the foundation to object and the window of tested software, and the extraction of window key word, make the complete test to tested software of controlling the behavior class by the data class of key word, thereby realized based on OO software test, improve level of abstraction higher, reduced the follow-up maintenance amount.
Description of drawings
In order to be illustrated more clearly in the present invention or technical scheme of the prior art, the below will do simple the introduction to the accompanying drawing of required use in the present invention or description of the Prior Art, apparently, accompanying drawing in the following describes is only some embodiments of the present invention, for those of ordinary skills, under the prerequisite of not paying creative work, can also obtain according to these accompanying drawings other accompanying drawing.
A kind of login window that Fig. 1 provides for the embodiment of the present invention;
The process flow diagram of a kind of method for testing software that Fig. 2 provides for the embodiment of the present invention;
The structural representation of a kind of test frame that Fig. 3 provides for the embodiment of the present invention;
The structural representation of the script layer that Fig. 4 provides for the embodiment of the present invention;
A kind of window that extracts key word that Fig. 5 (a) provides for the embodiment of the present invention;
A kind of window that extracts key word that Fig. 5 (b) provides for the embodiment of the present invention;
A kind of window that logins successfully ejection that Fig. 6 (a) provides for the embodiment of the present invention;
The window that a kind of login failure that Fig. 6 (b) provides for the embodiment of the present invention ejects;
A kind of alarm knowledge base management window that Fig. 7 provides for the embodiment of the present invention;
The structural representation of a kind of software testing device that Fig. 8 provides for the embodiment of the present invention;
The structural representation of a kind of software testing device that Fig. 9 provides for the embodiment of the present invention.
Embodiment
Below in conjunction with the accompanying drawing in the present invention, the technical scheme in the present invention is carried out clear, complete description, obviously, described embodiment is a part of embodiment of the present invention, rather than whole embodiment.Based on the embodiment in the present invention, the every other embodiment that those of ordinary skills obtain under the prerequisite of not making creative work belongs to the scope of protection of the invention.
As shown in Figure 2, a kind of method for testing software for embodiments of the invention provide is applied to software test, specifically comprises the following steps:
Step 201, the use-case that obtains tested software and check post;
Step 202, call the behavior class of the key word of described tested software according to described use-case, call the data class of the key word of described tested software according to described check post, and the parameter value of the attribute that provides according to described data class is controlled the execution of corresponding behavior in described behavior class;
Step 203, obtain the execution result that is stored in the described behavior class in described data class.
For the method for testing software of realizing providing in the embodiment of the present invention, it is a kind of based on OO test frame that the embodiment of the present invention provides, this test frame can be identified the object of gui interface, and this object identification needs to use corresponding object to identify increase income bag Abbot or Jemmy.Test frame in the embodiment of the present invention is based on OO thought, and being divided into is four main levels: object layer, Window layer, data Layer, script layer.Call according to arrow shown in Figure 3 between at all levels, i.e. script layer calling data layer, data Layer calls Window layer, Window layer allocating object layer.Script layer comprises use-case and the check post of testing.Wherein script layer as shown in Figure 4, is divided into again: top layer class, superclass, bottom script.The bottom script is inherited superclass, and superclass is inherited the top layer class.In addition, also comprise the auxiliary levels such as field object layer, database layer, tool-class layer in this test frame.
In conjunction with above-mentioned test frame, the flow process of automation software testing is:
(1) analyze tested software, find out all controls of object layer, and control is encapsulated.
Particularly, object layer is identified the object in tested software, with encapsulating of all controls, and can realize dynamic lookup to object according to attribute, and judges according to attribute whether window ejects.
(2) analyze all windows of tested software, find out similar panel or window, extract key word, data class and the behavior class of encapsulation key word.
Window layer is comprised of object layer, according to all windows of analyzing tested software, extracts the key word of window, and wherein key word is corresponding with Window layer; According to key word, extract the attribute of key word, wherein attribute comprises input parameter and/or output parameter, the composition data class; According to key word, extract the behavior of key word, the constituting action class.Data class provides the parameter value of attribute for the behavior class, and the execution result of behavior class is stored in data class.Whether wherein, behavior class carries out corresponding behavior to related object is controlled by the parameter value of the attribute in data class.When being empty, related object is not carried out corresponding behavior when the parameter value of certain attribute of key word; When the parameter value of certain attribute of key word when not being empty, dynamic lookup is to related object, and this related object carried out the behavior of correspondence.
(3) utilize spring that key word behavior class and the data class that Window layer defines is configured in data Layer.
(4) obtain the superclass of top layer class and each submodule of tested software.
(5) the bottom script obtains use-case and check post.
Use-case (Test Case) is a group of test input, executive condition and expected results working out for certain special objective, in order to test certain Program path or examine and whether satisfy certain particular demands, test case is counted as the minimum test execution unit of effective discovery software defect.
The check post is very important ingredient in script (script), the result that obtains testing by the execution to the check post, thus complete real data that tested software is generated and the comparison of expected data.
Call the behavior class of the key word of tested software according to use-case, call the data class of the key word of described tested software according to described check post, and the parameter value of the attribute that provides according to described data class is controlled the execution of corresponding behavior in described behavior class.Obtain execution result from the output parameter of key word, execution result is compared with desired value, thereby realization is to the test of tested software.
Need to prove, when attribute changed, next use-case was carried out in this use-case failure.
Below in conjunction with accompanying drawing, function at all levels is carried out further detailed elaboration.
One, object layer
At first, this layer mainly carries out object identification by third party's object identification bag Abbot or Jemmy, builds on this basis the object layer of self.Object layer is divided into two parts:
(1) encapsulation of various control classes
Encapsulated all basic Java controls, it and concrete application are irrelevant, can be regarded as the MFC that test Java uses.Corresponding to the basic control of each class of Java, the Class of a correspondence is arranged, comprising the basic operation to this control, and some need the verification method that uses in test process, such as the value of certain attribute of checking.For the processing of the self-defined Java control of third party, adopt reflex mechanism directly to obtain UI attribute and method here.
(2) object factory
Object factory mainly provides two class functions: the one, search object by parent object attribute-name and 5 dynamic state of parameters such as property value, UI object class name, UI object properties name and property value of UI object, and overcome the drawback of static lookup object; The 2nd, judge dynamically by UI object properties name and property value whether window ejects.
For example: for the object function of searching of completing the object locating function be:
public static TestObject findTestObject(String propertyName,String propertyValue,String classID,String propertyNameParent,String propertyValueParent)
Such as: the function that whether has ejected for objects such as dynamically judging window is:
public static boolean isObjectExists(String id,String value,int fixedTime,longloopTime)
Two, Window layer
Window layer comprises following functions: extract key word according to all windows of tested software; According to key word, extract input, the output parameter of key word, the composition data class; According to key word, extract the behavior of key word, the constituting action class.
(1) analyze all windows of tested software, extract key word (being equivalent to window or panel).
When carrying out the gui interface exploitation, general step is the synthetic panel of various UI group of objects, more various panel are combined into window, as much as possible carries out multiplexing.Same, in test script, panel and window as keyword extraction out, like this when in the program gui interface, certain UI object changes, need to modify corresponding key word gets final product, and reaches the purpose of only revising a place.Wherein, according to the combination level relation between panel and window in each window, corresponding different panel or the key word of window also have corresponding hierarchical relationship, as high-level key word and low level key word.
As shown in Fig. 5 (a) and Fig. 5 (b), two " sub-condition " tab pages are positioned at two different windows, but are consistent substantially, so this tab page is abstracted into a key word: " sub-condition " tab page.In like manner, two " essential information " tab pages in Fig. 5 (a) and Fig. 5 (b) are abstracted into a key word: " essential information " tab page.Window in window in Fig. 5 (a) and Fig. 5 (b) also is abstracted into key word.According to the combination level of window and tab page in Fig. 5 (a) and Fig. 5 (b), can know that the window in Fig. 5 (a) is high-rise key word, comprise " essential information " tab page and two low layer key words of " sub-condition " tab page; Equally, the window in Fig. 5 (b) is also high-rise key word, comprises " essential information " tab page and two low layer key words of " sub-condition " tab page.As can be known, the low layer key word can be multiplexing for high-rise key word from above-mentioned relation.
(2) according to the key word that extracts, extract the attribute of key word, the composition data class.
After extracting key word, will the attribute of this key word be extracted the composition data class.Preferably, for each key word, its attribute comprises input and output parameter.The operations such as wherein, input parameter can be inputted for text box, button is clicked; Output parameter can be list data of inquiring etc.For each key word, comprise input parameter or output parameter, or input and output parameter.Whether and each parameter is to control a switch of this key word behavior, be empty behavior corresponding to key word of whether carrying out of controlling according to the parameter value of the attribute of key word.
Take the window shown in Fig. 1 as example, extract its attribute (this window key word does not have output parameter).As shown in Figure 1, inputting user name, input password, clicking " login " or " cancellation " button is all the input parameter of this window key word, and this key word does not have output parameter.The associated exemplary code is as follows:
public class LoginPara{
Private String username; The user name of // input is as sa
Private String password; The password of // input is as sa
Private String buttonname; The name of // button click, as " login (L) "
Private IActionWard actionward; // represent certain window object
... omit corresponding get/set method
}
From above-mentioned code, can see having configured an IActionWard attribute, be used for representing the window that next can eject, for example: eject the window shown in Fig. 6 (a) if login successfully; If login failure ejects the window shown in Fig. 6 (b).This IActionWard attribute need to configure in the data class of each key word, in order to know the window that next can eject.
Window in Fig. 7 extracts its attribute (this window key word comprises output parameter) as example.As shown in Figure 7, replacement, inquiry, knowledge base importing, derivation, X button etc. are all input parameters of this key word, and the table content that inquires is exactly output parameter.The correlative code example is as follows:
public class AlarmKnlgPara{
Private List<String〉lstTreePath; // represent left side listbox
Private List<String〉lstSpecCause; // represent row key word in form, be specific reasons here
Private String tableContextPath; // represent the form context menu
Private String buttonName; // represent in replacement, inquiry, knowledge base importing, derivation, X button
Private IActionWard actionWard; // represent next unknown pop-up window
Private Integer outTableCount; The form line number that // representative inquires
... omit corresponding get/set method
}
(3) extract the behavior of key word, constituting action class out
Whether the data class of key word is imported into the behavior class of key word, be the operation whether empty control behavior class carries out related object according to certain attribute in the data class of key word.Particularly, if wherein certain attribute is null (namely this attribute is for empty), do not carry out the operation of related object.Otherwise utilize object layer, the object corresponding to non-null attribute carries out dynamic lookup, and carries out associative operation on object, such as clicking button etc.By foregoing description as can be known, the data class of key word has double action, and the first is transmitted the needed data of UI object; It two is execution switches, and only having certain property value is non-null (being that parameter has data), just can carry out with the operation of relating to parameters.
Below the window that logs in shown in Figure 1 be example, the parameter how the behavior class that the crux word is described is transmitted according to the data class of key word is carried out the operation of related object.At first, the behavior class of key word receives JavaBean (the reusable assembly that a kind of JAVA language is write as) corresponding to key word that imports into, take out the parameter of data Layer configuration according to this JavaBean, comprising: user name parameter, password parameter, button name parameter and keyword parameter etc.If the user name parameter is set up, find related object, namely the user name text box, carry out the setText operation, settings on this object; If the password parameter is set up, find related object, namely the password text box, carry out the setText operation, settings on this object; If button name parameter is set up, find related object, namely button, carry out the click operation on this object, clicks button; If key word actionWard parameter is set up, carry out the key word that imports into, namely carry out next window object behavior class.Concrete correlative code example is as follows:
The behavior class of // key word
public class SecMngLoginAW implements IActionWard{
private SecMngLoginPara para;
// import JavaBean corresponding to key word into
public SecMngLoginAW(SecMngLoginPara para){
this.para=para;
}
public void perform(){
The parameter of // taking-up data Layer configuration from the JavaBean that imports into
String title=" user's login ";
String username=para.getUsername();
String password=para.getPassword();
String buttonname=para.getButtonname();
IActionWard actionWard=para.getActionWard();
if(ObjectFactory.isObjectExists(Constant.PROP_CaptionText,title)){
DDialog dialog=new DDialog(Constant.PROP_CaptionText,title);
If // user name parameter has been set up, first finds the user name text box, then carry out setText operation, settings on object
if(username!=null){
DTextField tfUsername=new DTextField (" user name ", dialog);
tfUsername.setText(username);
}
If // password parameter has been set up, first finds the password text box, then carry out setText operation, settings on object
if(password!=null){
DTextField tfPassword=new DTextField (" password ", dialog);
tfPassword.setText(password);
}
If // button name parameter has been set up, first find button, then carry out the click operation on object, click button
if(buttonname!=null){
DButton button=new DButton(buttonname,dialog);
button.click();
}
If // key word actionWard parameter has been set up, carry out the key word that imports into, namely carry out next window object behavior class
if(actionWard!=null){
actionWard.perform();
}
}
}
}
Take alarm knowledge base management window shown in Figure 7 as example, the parameter how the behavior class that key word is described is transmitted according to the data class of key word is carried out the operation of related object.For the key word input parameter, its processing procedure is similar to the above.For the output parameter in this key data class, if output parameter is set up, calls correlation method and find out the form line number, it is set in the key data class again, script layer just can obtain data in form by the key data class like this.The correlative code example is as follows:
public class AlarmKnlgAW implements IActionWard{
private AlarmKnlgPara para;
public AlarmKnlgAW(AlarmKnlgPara para){
this.para=para;
}
public void perform(){
Integer outTableCount=para.getOutTableCount();
IActionWard actionWard=para.getActionWard();
If (ObjectFactory.isObjectExists (Constant.PROP_CaptionText, " alarm knowledge base management "))
// ... the code of clipped input parameter
The code of // output parameter part
If // output parameter is set up, call correlation method and find out the form line number, it is set in the key data class again, script layer just can obtain data in form by the key data class like this
if(outTableCount!=null){
WTable table=new WTable(Constant.CLASS_JXTable,dialog);
Integer retVal=table.getTableCount()
para.setOutTableCount(retVal);
}
If // key word is set up, carry out so this key word
if(actionWard!=null){
actionWard.perform();
}
}
}
}
Three, data Layer
Key word behavior class and data class that Window layer is defined are configured in data Layer.This one deck is in conjunction with the Spring framework, utilize the thought of IoC, input/output argument and its behavior class that need to use key word are configured in the XML file, according to the difference of input/output argument content, key word can corresponding different data Layer Bean, call for script layer.Utilize the Spring framework that 2 advantages are arranged: the object that at first can configure any type in the XML file; Secondly similar Bean object can be done multiplexing succession in configuration file.Greatly reduced like this in the configuration file configuration of input/output argument bright.
Correlative code example to the login window settings is as follows:
<!--data Layer Bean, call for script layer--〉
<!--behavior class of user's login window key word--〉
<bean id=″superHelper_userLoginAW″class=″com.datang.omcauto.tasks.common.UserLoginAW″ init-method=″perform″lazy-init=″true″scope=″prototype″>
<constructor-arg ref=″superHelper_userLoginPara″></constructor-arg>
</bean>
<!--data class of user's login window key word--〉
<bean id=″superHelper userLoginPara″class=″com.datang.omcauto.tasks.common.UserLoginPara″>
<property name=″username″value=″sa″></property>
<property name=″password″value=″sa″></property>
<property name=" buttonname " value=" login (L) "〉</property 〉
<!--configuration is another key word here, should eject which window after namely logining successfully, configuration here be window after logining successfully--
<property name=″linkNeAW″ref=″superHelper_linkNeAW″></property>
</bean>
... omit other Bean
In addition, with user sa1 login window, utilize Spring, can omit the configuration in other 3 territories by inheriting, thereby utilize configuration file to reduce input quantity, the correlative code example is as follows:
<!--data class of user's login window key word--〉
<bean id=″superHelper_userLoginAnother″parent=″superHelper_userLoginPara″>
<property name=″username″value=″sa1″></property>
</bean>
As follows to the attribute configuration correlative code example with the alarm knowledge base window of output parameter:
<!--data class of alarm knowledge base window key word--〉
<bean id=″alarmKnlg_getTableObject″parent=″superHelper_userLoginPara″>
<!--... omit the configuration of input parameter--〉
<!--initial value of at will inputting corresponding types gets final product, and can reset in key word behavior class--〉
<property name=″outLstKnlgObject″value=″-1″></property>
</bean>
Four, script layer
As shown in Figure 4, script layer is divided into again: top layer class, superclass, bottom script below are explained in detail the function of each level respectively.
1, top layer class
Top layer class main contents comprise the startup tested program, and initialization spring container carries out abnormality processing, the functions such as configuration common data layer Bean.
(1) abnormality processing
Carry out the robotization use-case, very crucial is exactly a bit abnormal processing, and after previous use-case was carried out unsuccessfully, follow-up use-case also will continue normal execution.Process at present be script layer abnormal (as object search less than, object properties search less than, object method does not exist etc.) directly send to by type the superclass on upper strata, extremely processed various by superclass, as long as the processing of acquiescence is to have abnormal window of just all programs being correlated with to close one by one.
(2) configuration common data layer Bean
The data Layer Bean that login is published key word is put in the preposition and postcondition of top layer class, shares for all scripts, logins or publish the operation of tested program in order to realize the user.
// precondition function, calling data layer Bean " superHelper_userLoginAW ", realize that the user logins the operation of tested program
public void onSetup(){
context.getBean(″superHelper_userLoginAW″);
}
// postcondition function, calling data layer Bean " superHelper_userLogoutAW ", realize that the user withdraws from the operation of tested program
public void onTeardown(){
context.getBean(″superHelper_userLogoutAW″);
}
2, superclass
General tested program all is comprised of several submodules, so the peculiar common data layer Bean that each submodule is used is configured in this layer, the script corresponding for submodule shares.
3, bottom script
Use-case and check post are configured in the bottom script.In the precondition of script, postcondition, the Bean that configures in the calling data layer in operation steps, these Bean are multiplexing for script.For the check post, the actual value that needs can be obtained from the data class of key word, database place.
The correlative code example of 1 use-case bottom script in the alarm management submodule is as follows:
// inherit from alarm submodule superclass
public class A02B03C05_001_ExistTemplate extends AlarmSuper
{
private static Logger log =Logger.getLogger(A02B03C05_001_ExistTemplate.class);
Private String title=" A02B03C05.001--alarm management, alarm frequency analysis window use already present alarm conditions template to carry out frequency analysis, operate successfully ";
// script precondition
@Override
public void onSetup(){
log.info(title);
super.onSetup();
Log.info (" precondition 1: the pacing items template is set begins ");
context.getBean(″kw_basicConfTemplate_addBasicConfTemplateAW″);
Log.info (" precondition 1: the pacing items template is set finishes ");
Log.info (" precondition 2: report simulation alarm to begin ");
context.getBean(″kw_simulate_sendSNDBNewAlarm1″);
Log.info (" precondition 2: report simulation alarm to finish ");
}
// script postcondition
@Override
public void onTeardown(){
Log.info (" postcondition 1: deletion pacing items template begins ");
context.getBean(″kw_basicConfTemplate_delBasicConfTemplateAW″);
Log.info (" postcondition 1: deletion pacing items template finishes ");
Log.info (" postcondition 2: remove simulation alarm and begin ");
context.getBean(″kw_alarmMonitor_clearNodeBAlarmAW″);
Log.info (" postcondition 2: remove simulation alarm and finish ");
super.onTeardown();
log.info(title);
}
// script step
public void onTest(Object[]args)
{
Log.info (" step 1: the alarm frequency is set begins ");
context.getBean(″kw_alarmFrequency_addFrequencyAW_template″);
AlarmFrequencyResultPara alarmFrequencyResultPara =(AlarmFrequencyResultPara)context.getBean(″alarmFrequency_addAlarmFrequencyResultPara_template″);
Log.info (" step 1: the alarm frequency is set finishes ");
Log.info (" step 2: the checking alarm frequency begins ");
// check post, actual queries to alarm number and desired value do contrast, wherein output parameter takes out from the data class of key word
Assert.assertEquals (title, " the alarm number that actual queries arrives: "+alarmFrequencyResultPara.getOutTableRowCount (), 1, alarmFrequencyResultPara.getOutTableRowCount ());
Log.info (" step 2: the checking alarm frequency finishes ");
}
}
In addition, also comprise the auxiliary levels such as field object layer, database layer, tool-class layer in this test frame.
(1) field object layer
The field object layer is a kind of data class, and field object is in whole framework, and each level can use, and all field objects that system under test (SUT) needs all are configured in this.
For example: have a use-case to wish content in the Excel form of the content of form in figure, corresponding data-base content, derivation is compared, check whether three's data are consistent.According to OO thought, delegation in form is abstracted into 1 field object KnlgObject, the self-defined annotation of configuration on field object, form, database, Excel form can share an object like this, and whether the equals method by field object namely can compare the three consistent.
(2) database layer
Adopt the JPA technology, obtain data-base recording with object form, in order to better carry out comparing.
(3) tool-class layer
The encapsulation tool class is such as the ftp tool-class, assert tool-class, excel tool-class, csv tool-class etc.
Need to prove, the method for testing software that the embodiment of the present invention provides based on test frame, make automation software testing just can get involved after the tested software Outline Design is completed.As long as complete gui interface and software requirement are arranged, develop thereby make automation software testing just can synchronize with tested software.When tested software issue test, only need the corresponding automatized script of debugging, reduced the cost of development of automation software testing.
Embodiments of the invention provide a kind of software testing device, are applied to software test, and as shown in Figure 8, software testing device 800 comprises:
The first acquisition module 810 is used for the use-case and the check post that obtain tested software;
Execution module 820, be used for calling according to described use-case the behavior class of the key word of described tested software, call the data class of the key word of described tested software according to described check post, and the parameter value of the attribute that provides according to described data class is controlled the execution of corresponding behavior in described behavior class;
The second acquisition module 830 is for the execution result that obtains the described behavior class that is stored in described data class.
Wherein, also comprise: set up module 840, be used for setting up the Window layer of described tested software;
Setting up module 840 specifically is used for:
Analyze the window of described tested software, extract key word, described key word is corresponding with described window;
According to described key word, extract the attribute of described key word, the composition data class;
According to described key word, extract the behavior of described key word, the constituting action class.
Wherein, setting up module 840 also is used for: the object layer of setting up described tested software;
Setting up module 840 specifically is used for:
Identify the object of described tested software; And/or
Encapsulate basic control.
Wherein, execution module 820 specifically is used for:
When the parameter value of the attribute that described data class provides is not empty, by the described object of described object layer dynamic lookup; Described object is carried out the described and corresponding behavior of described parameter value; Or
When the parameter value of the attribute that described data class provides is empty, object corresponding to described attribute do not carried out and the described corresponding behavior of described parameter value.
Wherein, execution module 820 also is used for:
Whether window corresponding to object judgement by described object layer ejects.
Wherein, setting up module 840 also is used for:
Set up the data Layer of described tested software, described data class and described behavior class are configured in described data Layer;
Set up bottom script, superclass and the top layer class of script layer, described bottom script is inherited described superclass, and described superclass is inherited described top layer class.
Wherein, described attribute comprises input parameter and/or output parameter;
Also comprise: comparison module 850 is used for described execution result and desired value are compared.
Embodiments of the invention have the following advantages: by the foundation to object and the window of tested software, and the extraction of window key word, make the complete test to tested software of controlling the behavior class by the data class of key word, thereby realized based on OO software test, improve level of abstraction higher, reduced the follow-up maintenance amount.
Through the above description of the embodiments, those skilled in the art can be well understood to the present invention and can realize by the mode that software adds essential general hardware platform, can certainly pass through hardware, but in a lot of situation, the former is better embodiment.Based on such understanding, the part that technical scheme of the present invention contributes to prior art in essence in other words can embody with the form of software product, this computer software product is stored in a storage medium, comprise that some instructions are with so that a station terminal equipment (can be mobile phone, personal computer, server, the perhaps network equipment etc.) carry out the described method of each embodiment of the present invention.
The above is only the preferred embodiment of the present invention; should be pointed out that for those skilled in the art, under the prerequisite that does not break away from the principle of the invention; can also make some improvements and modifications, these improvements and modifications also should be looked protection scope of the present invention.

Claims (12)

1. a method for testing software, is characterized in that, comprising:
Obtain use-case and the check post of tested software;
Call the behavior class of the key word of described tested software according to described use-case, call the data class of the key word of described tested software according to described check post, and the parameter value of the attribute that provides according to described data class is controlled the execution of corresponding behavior in described behavior class;
Obtain the execution result that is stored in the described behavior class in described data class;
Wherein, call the behavior class of key word of described tested software according to described use-case before, comprising:
Set up the object layer of described tested software; Specifically comprise: identify the object of described tested software and/or encapsulate basic control;
Set up the Window layer of described tested software, described Window layer is comprised of object.
2. the method for claim 1, is characterized in that, the described Window layer of setting up described tested software specifically comprises:
Analyze the window of described tested software, extract key word, described key word is corresponding with described window;
According to described key word, extract the attribute of described key word, the composition data class;
According to described key word, extract the behavior of described key word, the constituting action class.
3. the method for claim 1, is characterized in that, the execution that the parameter value of the described attribute that provides according to described data class is controlled corresponding behavior in described behavior class comprises any in following two kinds of situations:
When the parameter value of the attribute that described data class provides is not empty, by the described object of described object layer dynamic lookup; Described object is carried out the described and corresponding behavior of described parameter value; Or
When the parameter value of the attribute that described data class provides is empty, object corresponding to described attribute do not carried out and the described corresponding behavior of described parameter value.
4. method as claimed in claim 3, is characterized in that, also comprises:
Whether window corresponding to object judgement by described object layer ejects.
5. the method for claim 1, is characterized in that, before the behavior class of the described key word that calls described tested software according to described use-case, also comprises:
Set up the data Layer of described tested software, described data class and described behavior class are configured in described data Layer;
Set up bottom script, superclass and the top layer class of script layer, described bottom script is inherited described superclass, and described superclass is inherited described top layer class; Wherein, the use-case of described tested software and check post are disposed in the bottom script; Each submodule of described tested software program peculiar common data layer used is disposed in superclass, and the script corresponding for described submodule shares; Described top layer class is used for starting tested program, initialization spring container, carries out abnormality processing, configures the common data layer.
6. method as described in any one in claim 1 to 5, is characterized in that, described attribute comprises input parameter and/or output parameter;
Also comprise: described execution result and desired value are compared.
7. a software testing device, is characterized in that, comprising:
The first acquisition module is used for the use-case and the check post that obtain tested software;
Execution module, be used for calling according to described use-case the behavior class of the key word of described tested software, call the data class of the key word of described tested software according to described check post, and the parameter value of the attribute that provides according to described data class is controlled the execution of corresponding behavior in described behavior class;
The second acquisition module is for the execution result that obtains the described behavior class that is stored in described data class;
Described software testing device also comprises sets up module, and the described module of setting up is used for: call the behavior class of key word of described tested software according to described use-case at described execution module before, set up the object layer of described tested software; Specifically comprise: identify the object of described tested software and/or encapsulate basic control; And, set up the Window layer of described tested software, described Window layer is comprised of object.
8. device as claimed in claim 7, is characterized in that, the described module of setting up specifically is used for:
Analyze the window of described tested software, extract key word, described key word is corresponding with described window;
According to described key word, extract the attribute of described key word, the composition data class;
According to described key word, extract the behavior of described key word, the constituting action class.
9. device as claimed in claim 7, is characterized in that, described execution module specifically is used for:
When the parameter value of the attribute that described data class provides is not empty, by the described object of described object layer dynamic lookup; Described object is carried out the described and corresponding behavior of described parameter value; Or
When the parameter value of the attribute that described data class provides is empty, object corresponding to described attribute do not carried out and the described corresponding behavior of described parameter value.
10. device as claimed in claim 9, is characterized in that, described execution module also is used for:
Whether window corresponding to object judgement by described object layer ejects.
11. device as claimed in claim 7 is characterized in that, the described module of setting up also is used for:
Set up the data Layer of described tested software, described data class and described behavior class are configured in described data Layer; And bottom script, superclass and the top layer class of setting up script layer, described bottom script is inherited described superclass, and described superclass is inherited described top layer class; Wherein, the use-case of described tested software and check post are disposed in the bottom script; Each submodule of described tested software program peculiar common data layer used is disposed in superclass, and the script corresponding for described submodule shares; Described top layer class is used for starting tested program, initialization spring container, carries out abnormality processing, configures the common data layer.
12. device as described in any one in claim 7 to 11 is characterized in that described attribute comprises input parameter and/or output parameter;
Also comprise: comparison module is used for described execution result and desired value are compared.
CN 200910242386 2009-12-10 2009-12-10 Software testing method and device Active CN102096630B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN 200910242386 CN102096630B (en) 2009-12-10 2009-12-10 Software testing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN 200910242386 CN102096630B (en) 2009-12-10 2009-12-10 Software testing method and device

Publications (2)

Publication Number Publication Date
CN102096630A CN102096630A (en) 2011-06-15
CN102096630B true CN102096630B (en) 2013-11-06

Family

ID=44129733

Family Applications (1)

Application Number Title Priority Date Filing Date
CN 200910242386 Active CN102096630B (en) 2009-12-10 2009-12-10 Software testing method and device

Country Status (1)

Country Link
CN (1) CN102096630B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103092750A (en) * 2012-11-13 2013-05-08 瑞斯康达科技发展股份有限公司 Unit testing method and device
CN107864488B (en) * 2017-11-15 2020-12-08 京信通信系统(中国)有限公司 Method, device and system for automatically testing base station service
CN107908564A (en) * 2017-11-27 2018-04-13 于海生 A kind of UI test frames based on data separating principle
CN108304329B (en) * 2018-02-13 2020-12-15 论客科技(广州)有限公司 Test case design method and device, terminal and readable storage medium
CN109783388B (en) * 2019-01-16 2022-03-01 北京金山云网络技术有限公司 UI (user interface) automatic testing method and device and electronic equipment
CN111737149B (en) * 2020-07-24 2020-12-29 浙江口碑网络技术有限公司 Real machine platform, test method and test script processing method

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5751941A (en) * 1996-04-04 1998-05-12 Hewlett-Packard Company Object oriented framework for testing software
CN101339534A (en) * 2008-06-17 2009-01-07 金蝶软件(中国)有限公司 Software test apparatus and test method

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5751941A (en) * 1996-04-04 1998-05-12 Hewlett-Packard Company Object oriented framework for testing software
CN101339534A (en) * 2008-06-17 2009-01-07 金蝶软件(中国)有限公司 Software test apparatus and test method

Non-Patent Citations (6)

* Cited by examiner, † Cited by third party
Title
刘佳 等.基于对象状态的面向对象软件测试方法研究.《电脑知识与技术》.2008,第4卷(第8期),全文.
基于对象状态的面向对象软件测试方法研究;刘佳 等;《电脑知识与技术》;20081231;第4卷(第8期);全文 *
张文祥 等.面向对象的软件测试方法.《计算机应用》.2004,第24卷(第12期),全文.
罗娜 等.面向对象软件测试的方法研究.《东北师大学报自然科学版》.2004,第36卷(第1期),全文.
面向对象的软件测试方法;张文祥 等;《计算机应用》;20041231;第24卷(第12期);全文 *
面向对象软件测试的方法研究;罗娜 等;《东北师大学报自然科学版》;20040331;第36卷(第1期);全文 *

Also Published As

Publication number Publication date
CN102096630A (en) 2011-06-15

Similar Documents

Publication Publication Date Title
CN102096630B (en) Software testing method and device
CN107861870B (en) Interface test and test data generation method, device, terminal and storage medium
CN109408357A (en) A kind of automatic interface testing method and device
CN105701005B (en) Application framework test method based on OSGI and system
CN101770423B (en) Test data generation method and test system
CN106843837A (en) The construction method of openstack assembly containers
Margaria et al. Efficient test-based model generation for legacy reactive systems
CN109040235B (en) Industrial control system operation record storage method based on block chain technology
CN107807878A (en) Automatic test engine based on keyword
CN103984626B (en) A kind of method and device for generating test case script
US10459830B2 (en) Executable code abnormality detection
CN109902017A (en) A kind of method and terminal based on RobotFramework test Dubbo interface
Fahland et al. Mining branching-time scenarios
CN108845940A (en) A kind of enterprise information system automated function test method and system
CN103605606B (en) A kind of embedded software test use-case batch execution method that can automatically change
CN102043716A (en) Automatic software testing method based on business driving
CN105204991A (en) Internet of things test method and device
CN103399814A (en) Automated testing method and automated testing device
CN106484609A (en) Page method of testing and device
CN110134612A (en) UI test data generating method, device, equipment and readable storage medium storing program for executing
CN106778264A (en) The application program analysis method and analysis system of a kind of mobile client
CN108874649A (en) Generation method, device and its computer equipment of automatic test script
CN101216766A (en) Atom manipulation encapsulation apparatus and method
Bhattacharyya et al. Semantic aware online detection of resource anomalies on the cloud
CN105760300A (en) Automatic STK/UTK service testing method and system

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant