Summary of the invention
For the test function in testing tool in correlation technique, there is the shortcoming not reusable, that dependence is stronger, thereby the problem that is difficult to the performance of work test, the present invention proposes method of testing and the device of the page in a kind of Web system, can shorten the construction cycle of test service script, the file strong to repeatability, that utilization factor is high carries out abstract integration, be convenient to related service repeat call, improved the through engineering approaches testing level of testing tool.
Technical scheme of the present invention is achieved in that
The method of testing of the page in a kind of Web system is provided according to an aspect of the present invention.
This method of testing comprises:
In the situation that a plurality of pages in the Web system are tested, extract the business in a plurality of pages;
According to the similarity of the business institute corresponding function of a plurality of pages, a plurality of pages are classified, and be a class file by each class page stores;
Class file is integrated in the test service script, and operation test service script.
Wherein, a plurality of pages are classified and are comprised:
A plurality of pages that the functional similarity degree are more than or equal to predetermined similarity threshold are divided into a class.
And, by each class page stores, be that a class file comprises:
Identical or corresponding Function Integration Mechanism is a test call item by a plurality of pages in this class file.
In addition, above-mentioned method of testing further comprises:
A plurality of class files based on project management tool Maven managed storage.
Preferably, above-mentioned test service script is write and is moved based on unit testing frame J unit.
Further, operation test service script comprises:
In the situation that a plurality of test service scripts of needs operation, the operation order of managing a plurality of test service scripts in Junit by Maven.
In addition, after each class page stores was a class file, above-mentioned method of testing further comprised:
The class file of having stored is carried out to instantiation and obtain corresponding business object;
The data of coming the storage service object to shine upon based on the comma separated value csv file.
Alternatively, class file is integrated into the test service script comprise following one of at least:
Call class file;
With the form of parameter, call the data that business object is shone upon.
The proving installation of the page in a kind of Web system is provided according to another aspect of the present invention.
Above-mentioned proving installation comprises:
Extraction module, in the situation that a plurality of pages of described Web system are tested, extract the business in described a plurality of pages;
Sort module, for the similarity of the institute of the business according to a plurality of pages corresponding function, classify to described a plurality of pages, and be a class file by each class page stores;
Integrate module, for class file being integrated into to the test service script, and operation test service script.
In addition, above-mentioned proving installation further comprises:
Administration module, for a plurality of class files based on project management tool Maven managed storage.
Preferably, the test service script is write and is moved based on unit testing frame J unit.
And when integrate module operation test service script, administration module is further used in the situation that needs move a plurality of test service scripts, by Maven, manages the operation order of a plurality of test service scripts in Junit.
The page that the present invention tests by the needs in the Web system storage of classifying, then be integrated in the test service script, can shorten the construction cycle of test service script, the file strong to repeatability, that utilization factor is high carries out abstract integration, be convenient to related service repeat call, improved the through engineering approaches testing level of testing tool.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is clearly and completely described, obviously, described embodiment is only the present invention's part embodiment, rather than whole embodiment.Based on the embodiment in the present invention, the every other embodiment that those of ordinary skills obtain, belong to the scope of protection of the invention.
According to embodiments of the invention, provide the method for testing of the page in a kind of Web system.
As shown in Figure 1, according to the method for testing of the embodiment of the present invention, can comprise:
Step S101, in the situation that a plurality of pages in the Web system are tested, extract the business in a plurality of pages, wherein, by the different pages abstract be class file, (for example: data comprise the necessary page info of test page, element variable, element locating information etc.), and in actual applications, the business of extracting in a plurality of pages can comprise that application Page-Object Design Mode separates the data in a plurality of pages with business, then extract the business in a plurality of pages, Page-Object Design Mode in Web automated test frame of the present invention, and the design philosophy of data separating is not only applicable to Selenium, also meet simultaneously being used in combination of the automated test tool of increasing income such as Watir,
In to Web system page test process, extract the related business of the page;
According to the similarity of the business institute corresponding function of the different pages, the different pages are classified, and be a class file by each class page stores, for different class files, write corresponding CSV data file;
Referenced classes file in service scenario, realize calling of data in service scenario.
Step S103, similarity according to the business institute corresponding function of a plurality of pages, a plurality of pages are classified, wherein, the functional similarity degree can be more than or equal to predetermined similarity threshold (in actual applications, threshold value can arrange similarity to be 50% or can be set to surpass functional similarity or identical the getting final product of some) a plurality of pages be divided into a class, and be a class file by each class page stores, can be by a plurality of pages in this class file identical or corresponding Function Integration Mechanism be a test call item, thereby when calling class file, save call overhead, shorten the construction cycle of test service script, in addition, after each class page stores is a class file, can further to the class file of having stored, carry out instantiation and obtain corresponding business object, and the data that can come the storage service object to shine upon based on the comma separated value csv file,
Step S105, class file is integrated in the test service script, alternatively, this step can comprise calls class file, with the form of parameter, call the data that business object is shone upon, then move the test service script, preferably, the test service script is write and is moved based on unit testing frame J unit, in addition, except using Junit to carry out good support, also can use another main flow unit testing framework Test NG of Java, can select applicable unit testing framework according to test granularity (being unit testing or integration testing) specific aim.
In addition, can be based on a plurality of class files of project management tool Maven managed storage according to the method for testing of the embodiment of the present invention, and Maven can further manage the data relevant to described a plurality of class files.Further, when operation test service script, if need a plurality of test service scripts of operation, can manage by Maven the operation order of a plurality of test service scripts in Junit.
In the data-driven design, data Layer adopts java Bean to design a model the attribute of data is set, data in the CSV data file are deposited in internal memory by the key-value pair mode of Hash table, the csv file of each page is all constructed to a classes of pages and realize the Page-Object interface.The design of this kind data-driven separates the code business fully with test data, has reduced the development difficulty of automatized script, safeguards the modification that has reduced code in the automatized script process, only needs Update Table.The file strong to repeatability, that utilization factor is high carries out abstract package, be convenient to related service repeat call, can improve the through engineering approaches testing level.
According to still another embodiment of the invention, a kind of method and thought of Web automatic test are provided, wherein, the method comprises: based on Web product business function, the page is carried out to abstract classification, namely abstract to the page of business function similarity higher (being greater than 50%), and be single class file by this type of page stores; The information such as the required data of this type of page test, page elements all are stored as to csv file.In test script, quote required classes of pages file, thus the data indirectly in the corresponding CSV data file of invoking page class file.The realization that this kind layering thought is good separating of business and data.By this separate mode development and testing script, the construction cycle of service scenario will be shortened largely, the business strong for repeatability, that utilization factor is high is carried out abstract integration, be convenient to the related service script repeat call, improved on the whole automatic test efficiency.
Provide according to another embodiment of the invention a kind of based on Selenium Web Driver API(Application Programming Interface, be application programming interface) the Web automated test frame, wherein, Web Driver is driven unit in webpage.
As shown in Figure 2, according to one embodiment of present invention, provide a kind of Web automated test frame, this framework can comprise browser operation, engineering management and structure and continue integrated.This automated test frame is a set of mixed type test frame (Java engineering), can comprise Junit Case(By Java) or Test NG Case(By Java).Support Selenium IDE to record the conversion generation script, simultaneously also can write linear script composite service, take the business datum separation method, greatly reduce the complexity of code, also alleviate simultaneously the maintenance cost of automatized script, improved the reusability of code.Select Xpath method identifying page surface element, better solved the dynamics such as ID, Name, ClassName.For Ajax Flash application have good support.And, can select to carry out engineering management and project build by project management tool Maven and/or Ant.
Web automated test frame according to the embodiment of the present invention, use Java language to write automatic test script, select Junit unit testing framework to realize the Case combination, assert the function such as checking, choose the project management tool Maven management engineering project of main flow, introduce the robotization structure compiling packing that CI (continuing integrated) meets automatized script.In conjunction with Jenkins distributed function<Master, Slave >, dispose many cover systems environment, a plurality of test assignments of parallel running under varying environment, improve test script program implementation efficiency.Also can pass through Selenium Grid, a kind of Selenium plug-in unit of supporting parallel running, a plurality of test assignments of parallel running under varying environment simultaneously.
As shown in Figure 3, provide the multi-layer design pattern according to the Web automated test frame of the embodiment of the present invention.This pattern comprises: operation layer (Buisness comprises service scenario), object layer (Object comprises the page object collection) and data Layer (Data, for store test data).This multi-layer design pattern adopts a kind of Design Mode Page-Object of innovation, and it is a kind of embodiment of object-oriented thought.In logic by each test page abstract be 1 Page class, and tested object, the basic test step of this page in such, have been encapsulated, readability, reusability, versatility and the consistance of code have been improved, the Design Mode of the Page-Object that the embodiment of the present invention adopts has shortened the construction cycle of robotization code dramatically, has reduced the complexity of code.
According to the technological frame combination of the Web automated test frame of the embodiment of the present invention, comprise Selenium, Junit, Maven and Jenkins.Distributed and the Integration Design that the embodiment of the present invention adopts, namely the integrated combination of Junit, Maven and Jenkins has been managed the Web automation engineering well, has realized lasting integrated technology.The distributed function of Jenkins provides good hardware and software platform support for the concurrent execution of many environment of automatic test task.
Its projects structure comprises: service logic bag, public method bag, parameter class bag, external reference class libraries, data folder and Pom file.Below introduce each construction package:
Service logic bag: deposit test case specific implementation class and method;
The public method bag: reusability in service logic is strong, that dependency degree is high logical method extracts, and realizes with common class, in this bag, also comprises the class that realizes of part specific function;
Parameter class bag: class file corresponding to all supplemental characteristic files;
External reference class libraries: comprise the relevant jar file that engineering relies on;
Data folder: deposit the csv files such as data in the page to be measured, element Xpath;
Pom(Project Object Model, i.e. item objects model) file: Maven engineering configuration file, the dependence jar file of allocation project necessity.
According to the Web automated test frame of the embodiment of the present invention, comprise following advantage:
Applicability is strong: can meet main flow Web shell frame products, as: Ext, Jsf, Jquery etc.
Unit testing framework expansion: except Junit unit framework good support, also support another main flow unit testing framework of Java Test NG, can select according to test granularity (unit testing, integration testing) specific aim.
Functional test instrument expansion: the Page-Object Design Mode in this Web automated test frame, and the design philosophy of data separating is not only applicable to Selenium, also meet simultaneously Watir(Web Application Testing in Ruby, a kind of instrument of automated function test based on the webpage pattern) etc. being used in combination of the automated test tool of increasing income.
Application extensions: be not limited to the automation mechanized operation of browser, also can process by robot(the robot of file) class or autoit(language scripts) process Windows Form application program, also support Flash Flex application program simultaneously.
CI expansion: support Jenkins to continue the expansion of integrating server, realize that the structure of robotization is disposed, log collection and test report e-mail transmitting function.
Manageability easily builds: except supporting the project management tool in the Maven(Java exploitation) carry out good management, also support the software building instrument of Ant(based on Java) carry out project build.
Good integration: the Case management system TestLink that can integratedly increase income, realize the associated execution of automatized script and test case.
Simple development and maintenance is reused with height: in the data-driven design, data Layer adopts java Bean to design a model the attribute of data is set, data in the CSV data file are deposited in internal memory by the key-value pair mode of Hash table, the csv file of each page is all constructed to a classes of pages and realize the Page-Object interface.The design of this kind data-driven separates the code business fully with test data, has reduced the development difficulty of automatized script, safeguards the modification that has reduced code in the automatized script process, only needs Update Table.The method abstract package strong to repeatability, that utilization factor is high, be convenient to reusing of related service.
Good professional platform independence is with compatible: fully played the professional platform independence of Java, support Linux the Windows system.Utilize the compatible characteristics of Selenium to multiple browser, can to dissimilar, version browser, carry out compatibility test by automatized script.
Telescopic distributed: in conjunction with Jenkins distributed function<Master, Slave >, dispose many cover systems environment, a plurality of test assignments of parallel running under varying environment, improve test script program implementation efficiency.Also can pass through the test aid of a Selenium Grid(robotization, Grid is by utilizing existing computer based Infrastructure, can accelerate the functional test of Web-app), a kind of Selenium plug-in unit of supporting parallel running, a plurality of test assignments of parallel running under varying environment simultaneously.
In addition, technical scheme of the present invention has been avoided the defect of testing tools more of the prior art, and for example existing QTP, WinRunner functional test instrument belong to business software, and purchase cost is high.In addition, existing testing tool for complicated Web Ajax the equal None-identified of Flash application, the major part of recording of this type of instrument is based on the property values such as ID, Name, ClassName, the identification of coherent element, control is searched and brought more difficulty, especially dynamic element, because the attribute of dynamic element does not have the feature of uniqueness, therefore more difficult identification is searched.
The proving installation of the page in a kind of Web system is provided according to another embodiment of the invention.
As shown in Figure 4, according to the proving installation of the embodiment of the present invention, can comprise:
Extraction module 41, be used in the situation that a plurality of pages of system are tested, extract the business in a plurality of pages, wherein, in actual applications, the business of extracting in a plurality of pages can comprise that application Page-Object Design Mode separates the data in a plurality of pages with business, then extract the business in a plurality of pages, Page-Object Design Mode in Web automated test frame of the present invention, and the design philosophy of data separating is not only applicable to Selenium, also meet being used in combination of the automated test tool of increasing income such as Watir simultaneously;
Sort module 42, similarity for the business institute corresponding function according to a plurality of pages, a plurality of pages are classified, wherein, the functional similarity degree can be more than or equal to predetermined similarity threshold (in actual applications, threshold value can arrange similarity to be 50% or can be set to surpass 20 functional similarities or identical getting final product) a plurality of pages be divided into a class, and be a class file by each class page stores, can be by a plurality of pages in this class file identical or corresponding Function Integration Mechanism be a test call item, thereby when calling class file, save call overhead, shorten the construction cycle of test service script, in addition, after each class page stores is a class file, can further to the class file of having stored, carry out instantiation and obtain corresponding business object, and the data that can come the storage service object to shine upon based on the comma separated value csv file,
Integrate module 43, for class file is integrated into to the test service script, alternatively, this step can comprise calls class file, with the form of parameter, call the data that business object is shone upon, then move the test service script, preferably, the test service script is write and is moved based on unit testing frame J unit, in addition, except using Junit to carry out good support, also can use another main flow unit testing framework Test NG of Java, can select applicable unit testing framework according to test granularity (being unit testing or integration testing) specific aim.
In addition, according to the proving installation of the embodiment of the present invention, may further include:
The administration module (not shown), for a plurality of class files based on project management tool Maven managed storage.
And when integrate module operation test service script, administration module can be further used in the situation that needs move a plurality of test service scripts, by Maven, manages the operation order of a plurality of test service scripts in Junit.
In sum, by means of technique scheme of the present invention, the page that the present invention tests by the needs in the Web system storage of classifying, then be integrated in the test service script, can shorten the construction cycle of test service script, the file strong to repeatability, that utilization factor is high carries out abstract integration, be convenient to related service repeat call, improved the through engineering approaches testing level of testing tool.Further, technical scheme of the present invention, by page object (being the realization of Page-Object) has greatly been shortened to the construction cycle of robotization code, has reduced the complexity of code.And technical scheme of the present invention designs page layering based on the data-driven of csv file, has simplified the maintenance of robotization code, has reduced maintenance cost, has improved the reusability of code, has really realized the low coupling high cohesion of Web automation engineering.In addition, the management that in distributed and Integration Design, the integrated combination of Junit, Maven and Jenkins is good the Web automation engineering, realized lasting integrated technology.The distributed function of Jenkins provides good hardware and software platform support for the concurrent execution of many environment of automatic test task.
The foregoing is only preferred embodiment of the present invention, in order to limit the present invention, within the spirit and principles in the present invention not all, any modification of doing, be equal to replacement, improvement etc., within all should being included in protection scope of the present invention.