Summary of the invention
The object of the present invention is to provide a kind of mobile terminal automation testing system and method based on Robotium automatized script, automated test frame bag is created by computing machine, JAVA unit testing framework bag is set, make computing machine can directly start Robotium automatized script, avoid and start Robotium automatized script by Eclipse framework.In this test frame bag, control application is set and performs bag, control the related application whether mobile terminal performs Robotium automatic test, and preserve test result.
In order to achieve the above object, the present invention is achieved through the following technical solutions:
Based on a mobile terminal automation testing method for Robotium automatized script, be characterized in, the method comprises following steps:
S1, computing machine creates automated test frame bag;
S2, described automated test frame bag is sent to described mobile terminal by described computing machine, and controls the application of running of mobile terminal Robotium automatized script;
S3, described mobile terminal according in the test setting file established, arrange and perform in described automated test frame bag the application in the Robotium automatized script needing to perform;
S4, test result is write automated test frame bag by described mobile terminal, and the automated test frame bag after upgrading is sent to described computing machine.
Preferably, this method of testing, before described step S1, also comprises following steps:
Described computing machine creates test setting file, and described test setting file is sent to described mobile terminal;
Described test setting file comprises: Apply Names, reading executing code commands.
Preferably, described automated test frame handbag is containing the JAVA unit testing framework bag by described computer installation; According to described JAVA unit testing framework bag, this computing machine directly starts Robotium automatized script.
Preferably, described automated test frame bag also comprise by described computer installation control apply perform bag;
Described control application performs in bag and comprises: event information class, event control class;
Described event information class comprises: Apply Names, event id, run time version, event title and event result remarks;
Described event control class comprises: read test arranges file utility command, controls application fill order and writing events result command.
Preferably, when described in described computer installation during event information class,
The Apply Names of each application in event information class described in this computer installation, corresponding event id, event title;
When described application is without the need to performing, this computer installation run time version is without the need to performing field; When described application needs to perform, this computer installation run time version is set to and need performs field.
Preferably, after described computing machine directly starts Robotium automatized script,
Described automated test frame bag is sent in described mobile terminal by described computing machine;
The automated test frame bag of described computer based in mobile terminal, controls Robotium automatized script described in described running of mobile terminal.
Preferably, described step S3 comprises following steps:
S3.1, the read test that described mobile terminal performs in described event control class arranges file utility command, reads the Apply Names in the described test setting file in mobile terminal, reads executing code commands;
S3.2, described mobile terminal performs the control application fill order in described event control class, call described event information class, search the Apply Names in the event information class identical with the Apply Names in described test setting file, and check the run time version value that this Apply Names is corresponding;
S3.3, according to Apply Names, event id in described event information class, described mobile terminal calls and performs the related application of described Robotium automatic test.
Preferably, described step S3.2 comprises following steps:
S3.2.1, described mobile terminal performs the reading executing code commands in described test setting file, reads the run time version of the correspondence in described event information class; When run time version is for during without the need to performing field, jump to described step S4; When run time version is for performing field, perform step S3.3.
Preferably, described step S4 comprises following steps:
S4.1, when described mobile terminal be finished Robotium automatized script related application after, this mobile terminal controls writing events result command in described event control class and creates event result file;
S4.2, described mobile terminal is by event result, event handling remarks write said write event result file;
S4.3, said write event result file is sent in the event result remarks of described event information class by described mobile terminal;
S4.4, the automated test frame bag after renewal is sent to described computing machine by described mobile terminal.
Based on a mobile terminal automation testing system for Robotium automatized script, be characterized in, this test macro comprises:
Mobile terminal;
Computing machine, is connected with described mobile terminal; Described computing machine creates test setting file, automated test frame bag respectively, and described test setting file, automated test frame bag are sent to described mobile terminal; And control the application of running of mobile terminal Robotium automatized script.
The present invention compared with prior art has the following advantages:
The present invention needs to perform by creating which application in test setting file control Robotium automatized script.The mobile terminal test feedback that is easily understood is obtained by reading writing events destination file.By creating automated test frame bag at computing machine and arranging JAVA unit testing framework bag, avoid configuring Eclipse framework on different computing machine, increase work efficiency.
Embodiment
Below in conjunction with accompanying drawing, by describing a preferably specific embodiment in detail, the present invention is further elaborated.
Based on a mobile terminal automation testing system for Robotium automatized script, this test macro comprises: mobile terminal, the computing machine be connected with described mobile terminal.Described computing machine creates test setting file, automated test frame bag respectively, and described test setting file, automated test frame bag are sent to described mobile terminal; And control the application of running of mobile terminal Robotium automatized script.
As shown in Figure 1, a kind of mobile terminal automation testing method based on Robotium automatized script, the method comprises following steps:
This method of testing, before described step S1, also comprises following steps:
Computing machine creates test setting file, and described test setting file is sent to described mobile terminal.
Described test setting file comprises: Apply Names, reading executing code commands.
S1, computing machine creates automated test frame bag.This step S1 comprises following steps:
S1.1, computer installation JAVA unit testing framework bag.
In the present embodiment, computer installation JAVA unit testing framework bag is official of Google jar bag-testjunit, and the unit testing starter (Instrumentation runner) wherein applied in configuration (i.e. Run Configurations) is changed to android special cell test starting device (com.neenbedankt.android.test.InstrumentationTestRunner).
S1.2, computer installation controls application and performs bag.This step S1.2 comprises following steps:
S1.2.1, computer installation event information class (being also CaseInfo class); Described CaseInfo class comprises: Apply Names, event id, run time version, event title and event result remarks.This step comprises following steps:
The Apply Names of each application in S1.2.1.1, computer installation CaseInfo class, corresponding event id, event title.
In the present embodiment, CaseInfo class comprises Apply Names field--the Name of each application, corresponding event ID field-Case Id, event name field-CaseName, run time version field-Execute, event result memo field-Comment.
S1.2.1.2, when applying without the need to performing, this computer installation run time version is without the need to performing field; When described application needs to perform, this computer installation run time version is set to and need performs field.
In the present embodiment, when applying without the need to performing, Execute=0; When application needs to perform, Execute is set to non-zero value.
S1.2.2, computer installation event control class (being also CaseControl class); Described CaseControl class comprises: read test arranges file utility command, controls application fill order and writing events result command.
In the present embodiment, arranging read test, to arrange file utility command be readCaseSetting, and arranging and controlling application fill order is checkCaseSetting, and arranging writing events result command is caseResToXml.
S1.2.3, described CaseInfo class, CaseControl class are combined to form described control application and perform bag by computing machine.
S1.3, described JAVA unit testing framework bag, control application are performed bag and are combined to form described automated test frame bag by computing machine.
In the present embodiment, the automated test frame bag of computer installation is a jar bag, and this jar bag comprises respectively: testjunit jar wraps, control application performs bag.
S2, computing machine controls the application of running of mobile terminal Robotium automatized script.This step S2 comprises following steps:
S2.1, according to the JAVA unit testing framework bag in automated test frame bag, computing machine directly starts Robotium automatized script.
In the present embodiment, owing to wrapping containing testjunit jar in automated test frame bag, then can start this testjunit jar and wrap, Robotium automatized script is run directly in computing machine.
S2.2, described automated test frame bag is sent in described mobile terminal by computing machine.
S2.3, the automated test frame bag of computer based in mobile terminal, controls Robotium automatized script described in described running of mobile terminal.
S3, mobile terminal according in the test setting file established, arrange and perform in described automated test frame bag the application needing to perform.This step S3 comprises following steps:
S3.1, the read test that mobile terminal performs in CaseControl class arranges file utility command, reads the Apply Names in the described test setting file in mobile terminal, reads executing code commands.
S3.2, mobile terminal performs the control application fill order in described CaseControl class, call described CaseInfo class, search the Apply Names in the CaseInfo class identical with the Apply Names in test setting file, and check the run time version value that this Apply Names is corresponding.This step S3.2 comprises following steps:
S3.2.1, mobile terminal performs the reading executing code commands in test setting file, reads the run time version of the correspondence in CaseInfo class; When run time version is for during without the need to performing field, jump to described step S4; When run time version is for performing field, perform step S3.3.
In the present embodiment, test setting file is set to setting.xml file, and this file concrete structure is as follows:
Wherein, Case Id represents the ID of different event, as above-mentioned example, only has the Execute=1 of the application correspondence of Case Id=" U_1 ", illustrates that mobile terminal only needs the application that Case Id=" U_1 " is corresponding, and other application are without the need to performing.
S3.3, according to Apply Names, event id in described CaseInfo class, described mobile terminal calls and performs the related application of Robotium automatic test.
S4, test result is write automated test frame bag by mobile terminal, and the automated test frame bag after upgrading is sent to described computing machine.This step S4 comprises following steps:
S4.1, when mobile terminal be finished Robotium automatized script related application after, this mobile terminal controls writing events result command in described CaseControl class and creates event result file.
In the present embodiment, event result file is caseres.xml file.
S4.2, mobile terminal is by event result, event handling remarks write said write event result file.
In the present invention, specific embodiment caseres.xml file is as follows:
As above-mentioned example, show the result of different application correspondences, process remarks and event title.Wherein Res Id is also the Case Id in corresponding setting.xml file.
S4.3, said write event result file is sent in the event result remarks of described CaseInfo class by mobile terminal;
S4.4, the automated test frame bag after renewal is sent to computing machine by mobile terminal.
Although content of the present invention has done detailed introduction by above preferred embodiment, will be appreciated that above-mentioned description should not be considered to limitation of the present invention.After those skilled in the art have read foregoing, for multiple amendment of the present invention and substitute will be all apparent.Therefore, protection scope of the present invention should be limited to the appended claims.