A kind of automated testing method and device
Technical field
The application is related to field of computer technology, more particularly to a kind of automated testing method and device.
Background technology
With technical development of computer, software test is gradually by the manual test method conversion taking human as driving
The automatic test course performed for computer.Automatic test can using Software Testing Tool to software from
It is dynamic to realize test, the test that many manual tests can not be realized or are difficult to is completed, takes rational
Automated testing method quickly can be tested comprehensively software, so as to improve software weight, save money
Take, shorten software development cycle etc..It is typically runtime journey on a preset condition based in automatic test
Sequence or application program, obtain operation result and are compared with expected results with to system program or application program
Quality be estimated.
When automatic test is specifically performed, database can be accessed first and carries out test data preparation, is then accessed
Above-mentioned database carries out the operation such as test result verification.But, may because above-mentioned database is public service
There are multiple modifications and operation for accessing and simultaneously the data in database or database being carried out with different modes, this
The test data that sample automatic test is relied on will be unable to ensure accuracy, so that cause test result incorrect,
When such as automatic test accesses database, database table structure is modified by other access, will be caused
The data created in test case implementation procedure can not typing, generally require manually to adjust data message
Whole, being run multiple times can just run succeeded, therefore the stability of automatic test operation at present is relatively low.
The content of the invention
Based on above-mentioned technical problem, the embodiment of the present application provides a kind of automated testing method and device, is used for
Improve the stability of automatic test operation.
The embodiment of the present application uses following technical proposals:
A kind of automated testing method, including:Create the database for current automatic test;Obtain and survey
Data are tried, and the test data got is imported in the database;From the test number in the database
According to middle acquisition data to perform the method for testing of automatic test, and test result data is stored in the number
According in storehouse;The database is accessed, according to expected results data to the test result data in the database
Carry out data check.
Preferably, the database is specially memory database.
Preferably, test data is obtained, and will specifically be wrapped in the test data got the importing database
Include:Test data is obtained from the test code of automatic test, and the test data got is imported into institute
State in database.
Preferably, before the test data got is imported in the database, methods described also includes:
The corresponding table structure of test data is created in the database of establishment.
Preferably, data check is carried out to the test result data in the database according to expected results data
Afterwards, methods described also includes:Feedback check result.
Preferably, after feedback check result, methods described also includes:Delete the test in the database
Data.
Preferably, delete after the test data in the database, methods described also includes:Test code
Terminate operation, database is out of service.
Preferably, create and specifically included for the database of current automatic test:Run automatic test generation
Code, the database of current automatic test is used for by testing results code establishing.
A kind of automatic test device, including:Database creation module, test data preparation module, test
Performing module and result data correction verification module, wherein:The database creation module, is used to work as creating
The database of preceding automatic test;The test data preparation module, for obtaining test data, and will be obtained
The test data got is imported in the database;The testing execution module, for from the database
Test data in obtain data to perform the method for testing of automatic test, and test result data is preserved
In the database;The result data correction verification module, for accessing the database, according to expected knot
Fruit data carry out data check to the test result data in the database.
Preferably, the database that the database creation module is created is specially memory database.
At least one above-mentioned technical scheme that the embodiment of the present application is used can reach following beneficial effect:Certainly
Dynamicization creates the database for current automatic test first when testing, the test data got is imported
In the database, the method for testing of automatic test is then performed, above-mentioned database is finally visited again to survey
Test result data carry out data check, all build a set of database environment during each automatic test automatically, create
The test data of this dependence is built, the stabilization of database and the accuracy of test data have been ensured, so as to carry
Rise the stability of automatic test operation result.
Brief description of the drawings
Accompanying drawing described herein is used for providing further understanding of the present application, constitutes the part of the application,
The schematic description and description of the application is used to explain the application, does not constitute the improper limit to the application
It is fixed.In the accompanying drawings:
Fig. 1 is the application scenarios schematic diagram of automated testing method in the prior art;
Fig. 2 implements schematic flow sheet for a kind of automated testing method of the offer of the embodiment of the present application 1;
Fig. 3 implements schematic flow sheet for a kind of automated testing method of the offer of the embodiment of the present application 2;
Fig. 4 is the automated testing method application scenarios schematic diagram that the embodiment of the present application 2 is provided;
Fig. 5 is a kind of concrete structure schematic diagram for automatic test device that the embodiment of the present application 3 is provided.
Embodiment
It is specifically real below in conjunction with the application to make the purpose, technical scheme and advantage of the application clearer
Apply example and technical scheme is clearly and completely described corresponding accompanying drawing.Obviously, it is described
Embodiment is only some embodiments of the present application, rather than whole embodiments.Based on the implementation in the application
Example, the every other implementation that those of ordinary skill in the art are obtained under the premise of creative work is not made
Example, belongs to the scope of the application protection.
As it was previously stated, can access database first when performing automatic test in the prior art and be tested
Data prepare, and then access database and carry out test result verification, or are to access database to tie test
Fruit data such as are estimated at the operation.But because database is public service, there may be multiple access simultaneously
Data are carried out with the modification and operation of different modes, the test data that such automatic test is relied on will be unable to
Accuracy is ensured, so as to cause test result incorrect.For example, as shown in figure 1, public database
Server is employed server, automatic test server A, and automatic test server B institutes are public.When
Automatic test server A, automatic test server B are right in the same program institute to be tested of execution respectively
During two test cases answered, wherein the data needed for program operation to be tested are maintained in public database
In server, if application server runs above-mentioned program to be tested table knot corresponding to relied on data
Structure is modified, and will likely now cause automatic test server A can not be in above-mentioned public database service
Increased newly in device and record and then data preparation can not be carried out, while automatic test server B can not obtain record
And then data check can not be carried out, ultimately cause test run result it is incorrect or test interrupt situation,
Therefore the stability of automatic test operation at present is relatively low.
Embodiment 1
In order to solve the above technical problems, the embodiment of the present application 1 provides a kind of method of automatic test, it is used for
Improve the stability of automatic test operation.The idiographic flow schematic diagram of this method is as shown in Fig. 2 including under
State step:
Step 11:Create the database for current automatic test;
When creating the database for current automatic test, the database created can be in this test
The memory database created in the internal memory that use-case is run, or establishment be used for current automatic test
Disk database.Data can be placed in internal memory the control that directly conducts interviews by memory database, relative to
Disk database, its read or write speed will be several orders of magnitude higher, and then can be greatly enhanced test case
Execution efficiency.
During specific establishment database, it is possible to use Create DataBase<Database-name>Order create number
According to storehouse, such as when creating entitled ceshi Mysql databases, Mysql servers are connected first;
Then mysql is performed>create database ceshi;Complete the establishment of database.
It should be noted that above-mentioned establishment database is used for current automatic test, specifically it could be arranged to only
The executive agent for having this test case possesses access rights, that is, the database created is only surveyed for this automation
Examination is used.
Step 12:Test data is obtained, and the test data got is imported in the database;
Test data is typically the total data for needing in the method implementation procedure of automatic test to use, and it comes
Come from the corresponding testing requirement of test case., can be specifically from the survey of automatic test when obtaining test data
Try to obtain in code, after test data is obtained, be able to will be got by the import feature of database
Test data is imported in the database.For example, get a collection of test data, these test datas be by
Acquire, then be able to will be got by way of importing test data in the test code of test case
Test data imported into the database of establishment realize test data prepare.
It is specific when importing test data, it is possible to use one section of program in the code of test case will be got
Whole test datas are imported into the database that step 11 is created, and the test data of importing can be automatic
Change the initial value of the variate-value required in test process, or be all values of a certain token record etc..
Step 13:Data are obtained from the test data in the database to perform the test of automatic test
Method, and test result data is preserved in the database;
When the method for testing of automatic test is performed, that is, building test environment testing results use-case, test wrapper
The hardware environment that border can be run for software product, such as it is Windows2000 to require operating system system
Pack4 versions etc..Data wherein needed for test process are obtained from the test data in the database,
And test result data is stored in the database.
It should be noted that the test data in database includes all necessary data in test, test
Process is a continuous process, may can also be divided into multiple execution steps, may be only when each step is performed
It is to need partial data in above-mentioned test data or is total data, can be from when needing to use every time
Required data are obtained in above-mentioned database.
One group of test input that automatic test is designed typically to specific test purpose, performs condition,
And expected results.The test input of automatic test is to provide the various input conditions in test execution, root
According to the input condition in demand, the input of test case is determined.Operating procedure is to provide measuring executing process
Step.Expected results are the expected results for providing test execution, it is contemplated that result should be according in software requirement
Output is drawn.By the execution of test case, and then it can be found that the mistake of test object.If in reality
In test process, obtained actual test result data is not inconsistent with expected results data, then test does not pass through;
It is on the contrary then can consider test pass through.
Step 14:The database is accessed, according to expected results data to the test result in the database
Data carry out data check.
Because test result data is stored in above-mentioned database, the database is accessed, is generally accessed
Test result data in above-mentioned database is simultaneously verified it with expected results data.It is specific to access data
Intermediary's code of database can be created during storehouse via one or more layers by the test case of automatic test
Or middleware enters in database and then accesses test result data, and read out and sent after test result data
Return in test case to carry out data check.Wherein expected results data can generally be stored in automatic test
Test code in.
When the database is accessed in test execution to test result data progress data check, even if actual
Test result data is consistent with the expected results data tested, and generally also to check that the test of automatic test is used
Operation Log, system operation daily record and the system resource service condition of example, to judge whether test case performs
Success.The problem of output of comprehensive observation software product can be found that many hidden.
This method provided using embodiment 1, is created and is surveyed for currently automating first in automatic test
The database of examination, the test data got is imported in the database, then performs automatic test
Method of testing, finally visits again above-mentioned database and data check is carried out to test result data, automation every time
A set of database environment is all built during test automatically, the test data of this dependence is created, has ensured database
Stabilization and test data accuracy, so as to lift the stability of automatic test operation result.
In the step 11 of embodiment 1, the database for current automatic test of establishment specifically can be with
For memory database.Memory database can be exchanged for by using local memory resource test data prepare and
The real-time of data check.The real-time process performance of affairs of memory database is better than disk database.Phase
For disk database, by memory database, disk input and output are reduced, can be reached defeated with disk
Enter the processing speed that the traditional database based on output can not be intended in contrast.What memory database system was brought
Superior function be not only only that internally deposit read-write compare disk read-write it is fast on, it is often more important that, memory database
The design for having carried out new architecture is managed all in internal memory based on total data, in data buffer storage, quickly
Also it is correspondingly improved in terms of algorithm, parallel work-flow, so that data processing speed is typically than traditional number
It is many soon according to the data processing speed in storehouse, typically all more than 10 times, and then lift the survey of automatic test
Try efficiency.
Test data is obtained in the step 12 of embodiment 1, and the test data got importing is described
Before in database, the embodiment can also comprise the following steps:Created in the database of establishment automatic
Change the corresponding table structure of test data of test, institute in usual clear and definite test process before creating table structure
The type of the data needed and required database table structure.For example during automatic test need field
Entitled " LastName ", " FirstName ", " Address " and " Age " field, create name in database
Following sentence can be constantly write for the table structure of " Person ":
CREATE TABLE Person
(
LastName varchar,
FirstName varchar,
Address varchar,
Age int
)
By the corresponding table structure of the test data for creating automatic test, and then follow-up test can be facilitated
Data import and accessed database and carry out data check to test result data.
The database is accessed in the step 14 of embodiment 1, according to expected results data to the data
Test result data in storehouse is carried out after data check, and the embodiment can also comprise the following steps:Instead
Present check results.
After software test execution terminates, test activity is not over.Interpretation of result is essential important
Link, by the check results of feedback, and then the development to the analysis of test result to next round test job
There is very big reference.The crucial domain of software test result is exactly " problem description ", and this is orientation problem
Foundation.Problem description should include following sections content:Software merit rating, hardware configuration, test case
Input, operating procedure, at that time output, daily record of the correlation output information of output equipment and correlation etc..
Software merit rating includes OS Type version and patch release, the version of current tested software and benefit
Fourth version, associated support software, such as version and patch release of database software etc..Hardware configuration includes
The relevant parameter of the configuring condition of computer, such as CPU, internal memory and hard disk, other hardware parameters are according to survey
The actual conditions addition of example on probation.If using network in test, then the networking situation of network, network
Situations such as capacity, flow.Test case input operating procedure output.The correlation output information of output equipment
Include computer display, printer, tape etc. output equipment etc. including output equipment.Log information bag
Include the running log and user, the Operation Log of keeper of software.
In the above-described embodiments after feedback check result, methods described can also comprise the following steps:Delete
Test data in the database, test data here can be the total data in database certainly.
If memory database, the test data in memory database, and then reduction memory usage are deleted in time,
Reduce the use to system resource;If disk database, the number of results in disk database is deleted in time
According to, and then the occupancy of disk is reduced, equally play the effect used for reducing system resource.
In addition, after deleting the test data in the database, methods described can also comprise the following steps:
The code ends operation is tested, database is out of service.Relative to memory database, the test generation of test case
Memory database can terminate operation after code end of run, and then reduce the occupancy to internal memory, relative to disk
Database, after the test code end of run of test case, can be tied by way of deleting database
The operation in beam data storehouse.
In embodiments all before, creating can specifically use for the database of current automatic test
Automatic test code is run, the database of current automatic test is used for by testing results code establishing.
I.e. increase creates the relative program of database in the test code of automatic test, passes through automatic test generation
The operation of code automatically creates the database for current automatic test.
Embodiment 2
Based on identical inventive concept, embodiment 2 provides a kind of automated testing method, for improving certainly
The stability of dynamicization test run.The idiographic flow schematic diagram of this method is as shown in figure 3, comprise the steps:
Step 21:Testing results code establishing memory database;
When creating memory database, structure memory database can be added in the test code of automatic test
Correlative code, by testing results code call database create instrument creation be used for current automatic test
Memory database, the memory database of establishment can be SQLite memory databases or Altibase internal memory numbers
The memory database of some operation needs for meeting test case according to storehouse etc..
SQLite is a small-sized c program storehouse, realizes independent, embeddable, the SQL of zero configuration
Database engine.Not only committed memory is few, easy to operate quick and stable by SQLite.But SQLite
Some are eliminated it is believed that relatively useful characteristic, such as high concurrent, strict access control, abundant
Build-in function, storing process, complicated sql like language characteristic, XML and Java extension, super large
The other DATA REASONING of TERA-SCALE etc..
AltibaseTMMain Memory Database Management System (DBMS) can be to be provided in the preferential environment of affairs
The software solution of high-performance and high availability.Altibase provides limiting performance, fault-tolerant ability and affairs
The convenience of management, particularly in communication, Web bank, in real time securities trading, application and embedded system
Field.Altibase can play the potentiality of database management systems to greatest extent.
Step 22:The corresponding table structure of test data is created in the memory database of establishment;
By the corresponding table structure of the test data for creating automatic test, and then it can facilitate in step 23
Database, which is imported in test data and step 25, accesses database to test result data progress data check,
Wherein, total data required in usual clear and definite test process before obtaining test data is in data
Table structure in storehouse.
Step 23:Test data is obtained, and the test data got is imported in memory database;
When obtaining test data, specifically it can be obtained from the test code of automatic test, by test data
When importing memory database, it is possible to use one section of program in the code of test case is by needed for test process
Whole test datas imported into the memory database that step 21 is created, for example import test process in
The initial value of required variate-value, or be all values of a certain token record of storage etc..
Step 24:Data are obtained from the test data in memory database to perform the test of automatic test
Method, and test result data is stored in memory database;
When the method for testing of automatic test is specifically performed, that is, building test environment testing results use-case.Its
Data needed for middle test process are obtained from the test data in the memory database, and test result
Data are stored in the memory database.
Step 25:The memory database is accessed, according to expected results data in the memory database
Test result data carries out data check;
The memory database is accessed, test result data is generally accessed, it is entered with expected results data
Row compares, it is contemplated that result data can be generally stored in the test code of automatic test.In test execution
When the middle access memory database carries out data check to test result data, even if in actual test result
Deposit consistent with the expected results internal memory tested, generally also to check Operation Log, the system operation of test case
Daily record and system resource service condition, to judge whether test case runs succeeded.Comprehensive observation software
The problem of output of product can be found that many hidden.
Step 26:Feedback check result;
Carry out after data check, can be with feedback check result, after software test execution terminates, test activity
It is not over.Interpretation of result is essential important step, by the check results of feedback, and then right
Development of the analysis of test result to next round test job has very big reference.
Step 27:Delete the test data in the memory database;
The test data in memory database is deleted in time, and then reduces memory usage, improves system resource
Utilization ratio.
Step 28:The code ends operation is tested, memory database is out of service.
Memory database can terminate operation after the test code end of run of test case, and then reduce internal
The occupancy deposited.
The method provided using embodiment 2, due to creating memory database first in automatic test and creating
The corresponding table structure of test data is built, is performed after the test data got is imported in the memory database
The method of testing of automatic test, then accesses above-mentioned memory database and carries out data school to test result data
Test, the test data in memory database is deleted after last feedback check result and stops memory database fortune
OK, a set of internal storage data lab environment is all built during each automatic test service operation automatically, create this according to
Bad test data, has ensured the stabilization of database and the accuracy of test data, so as to lift automation
The stability of test run result, while by deleting the test data in memory database in time and stopping interior
Deposit data storehouse is run, and reduces the resource shared by automatic test.
The effect of the stability of lifting automatic test operation result is played for embodiment 2, specifically can be as
Shown in Fig. 4, the contrast with Fig. 1 in the prior art can be seen that in Fig. 4 automatic test server A and
Automatic test server B can be tested its corresponding test object respectively, test process not by should
The influence changed with server table C-structure in public database server, and then improve automatic test mistake
The stability of journey.
Embodiment 3
Based on identical inventive concept, embodiment 3 provides a kind of automatic test device, for improving certainly
The stability of dynamicization test run.As shown in figure 5, the device includes:Database creation module 31, test
Data preparation module 32, testing execution module 33 and result data correction verification module 34, wherein:
The database creation module 31, can be used for creating the database for current automatic test;
The test data preparation module 32, can be used for obtaining test data, and by the test number got
According in the importing database;
The testing execution module 33, can be used for from the test data in the database obtain data with
The method of testing of automatic test is performed, and test result data is preserved in the database;
The result data correction verification module 34, can be used for accessing the database, according to expected results data
Data check is carried out to the test result data in the database.
This method provided using embodiment 3, database creation module 31 is created first in automatic test
Build the database for current automatic test, test data preparation module 32 is by the test data got
Import in the database, then testing execution module 33 performs the method for testing of automatic test, finally
Result data correction verification module 34 accesses above-mentioned database and data check is carried out to test result data, every time certainly
Dynamicization testing service all builds a set of database environment automatically when running, and creates the test data of this dependence,
The stabilization of database and the accuracy of test data are ensured, so as to lift automatic test operation result
Stability.
In one embodiment, the database that database creation module 31 is created is specifically as follows internal memory number
According to storehouse.
It will be understood by those skilled in the art that embodiments herein can be provided as method, system or computer journey
Sequence product.Therefore, the application can using complete hardware embodiment, complete software embodiment or combine software and
The form of the embodiment of hardware aspect.Moreover, the application can be used wherein includes calculating one or more
Machine usable program code computer-usable storage medium (include but is not limited to magnetic disk storage, CD-ROM,
Optical memory etc.) on the form of computer program product implemented.
Embodiments herein is these are only, the application is not limited to.For people in the art
For member, the application can have various modifications and variations.It is all to be made within spirit herein and principle
Any modification, equivalent substitution and improvements etc., should be included within the scope of claims hereof.