A kind of component testing case generation method based on modelTechnical field
The present invention relates to software testing technology field, specifically a kind of component based on model(Unit)Test caseGeneration method.
Background technology
In recent ten years, software size constantly expands, and the complexity of software is continuously increased, the Application development environ-ment of software,Development scheme etc. is all widely used in change such as component technology.Under the overall background of this " change ", user is for software matterThe requirement of amount is also being improved.Therefore, as a kind of effective means for improving software quality, software testing technology is also required to adapt to simultaneouslyContinue to develop.Statistics shows:In software test expense, about 40% puts into test data, including test case generation andThe inspection of test result.In addition, the automaticity of test process also has direct influence for the efficiency of the practice of test.
With modeling technique(Especially UML)Application it is ripe, model-based testing turns into extensively should in practiceA kind of method.Here " model " can be the test model for designing a model or specially creating.In this methodIn, the description information based on model(Generally include workflow and traffic flow information)Test case data is produced, and by performingTest case is to check/assess test result to find potential trouble point in software.
Test cases technology is the basis of Experience of Software Testing Work, and no matter which kind of method of testing is directed to this problem.At present,Although existing many kinds method for generating test case, they still have very big distance apart from practical application.This is also current systemOne of principal element that about software testing technology develops.And in the world in some advanced Software Testing Tools, generally all avoidTest data auto generation problem, or a kind of automanual Test cases technology mode is at most provided.Therefore, both at home and abroad fromIn the enterprise of thing software test, mostly using artificial or computer-assisted way generation test case, their shortcoming is:
(1) Test cases technology needs to spend a large amount of expenses(Personnel, time etc.), and automaticity and efficiency are low;
(2) change of software logic can not be directly reflected into the renewal of test use cases, realize " on demand " safeguard intoThis height;
(3) although some Core Generators have reached a certain degree of automation, but realize excessively complexity, for userProfessional technique require it is higher.
In recent decades, as software quality problem becomes increasingly conspicuous, software test and the cost more and more higher safeguarded, workAmount is also increasing.Statistics shows that at home and abroad, test substantially achieves the 50% of software development total cost, sometimes even highUp to more than 80%, and wherein quite a few is an artificially generated the expense with maintenance work.
Test data auto generation is always one of target that software testing technology is pursued.Although domestic and international many sectionsScholar pays very big effort for this, still, and correlative study achievement is to smoothly practical application can also having relatively large distance.SeparatelyOutside, with the development of component technology, if it is possible to which the change " on demand " for component version generates test case, for improving structurePart regression test efficiency, quality of the software systems of Component- Based Development etc. all have highly important theoretical and realistic meaning.
The content of the invention
The technical assignment of the present invention is that there is provided a kind of component testing use based on model for above-mentioned the deficiencies in the prior artExample generation method.This method can carry out semantic automatic point according to given Software Design Model for the expression of its function logicAnalysis, and satisfactory test case set is generated by the model conversion method of data object, improve in software test and testThe tracking of use-case " on demand " generating process, backdating capability, can increase substantially the efficiency and automaticity of Test cases technology.
The invention is intended to by realizing Test cases technology with data object map based on designing a model,
The technical assignment of the present invention is realized in the following manner:A kind of component testing use-case generation side based on modelMethod, is characterized in comprising the following steps:
Step one:Designed a model according to selected UML, establishment can describe member function logic(Workflow)XML textShelves;
Step 2:In analysis workflow the status data that includes and its comprising data object, create data object semanticTable is described, the unrelated semantic feature of platform of data object is determined;
Step 3:According to the target platform of determination, the grammer for the data object analyzed and clearly bound with target platform is specialLevy, semantic span and constraint;The unrelated data object value mapping table related to platform of platform is created on this basis;
Step 4:The XML document of traversal description member function logic, automatically generates the workflow of counterpart member function logicSet;
Step 5:Based on the data object semantic description table created in step 2, change and generated in spread step fourWorkflow set, the unrelated test case set of generating platform;
Step 6:Based on the unrelated data object value mapping table related to platform of the platform created in step 3, forThe unrelated test case set of platform generated in step 5 carries out the conversion of data object, generates the test related to target platformUse-case set.
Preferably, step one, based on the uml diagram created, the XML description texts of manual creation reflection member function logicShelves:
When creating XML documents, according to each single item workflow in correspondence uml diagram, entered using semantic clearly XML tagRow translation and description:Using the respective element in predefined tag element descriptive model, including start node, end node,Intermediate node, branch node, cyclic node, aggregation node and parallel node, and recorded by Label_Config documentsAnd semantic annotations.
The tag element can be by user's self-defining and extension.
The component design model can be that third party creates, or the self-designed uml diagram of user, to clearGround describes the function logic of some section of component --- the different uml diagram of correspondence.
Step 2, each single item workflow in uml diagram clearly marks the state that each node is includedData, and the semantic description table NodeDescribeTable of manual creation data object:
The Expressive Features of the node state data include:State before node NodeNo, executionStatesBeforeExecution, input data set InputData and anticipated output data set ExpectOutputData;
Based on the Expressive Features of node state data, the set of data objects included in each status data is determinedDataObjectSet, wherein, each data object DataObject Expressive Features are:Data object nameObjectName, characteristic attribute set ObjectAttributes.
Obtained set of data objects is analyzed in step 3, object-oriented platform and step 2, the data pair based on determinationAs codomain and about beam analysis and the specific mapping state values of data object under target platform are automatically generated, and created on this basisData object is built by the unrelated value mapping table PItoPSMapTable related to platform of platform:
Wherein, the platform association attributes feature of data object includes:Parameter list paraList, parameter value domainValueDomain, state valid data state(Including bool types, true:Valid data;false:Invalid data), lead toCross the codomain of data object and about beam analysis, the corresponding mapping object of generation, and record its abnormal value set under target platformWith normal value set.
Step 4, program pass describes the XML document of member function logic, the corresponding test path set of generation workflowTestPaths, its basic implementation procedure is:
(1)Start node set Starts non-NULLs, then obtain a start node, and the method traveled through according to level obtains itChild nodes, and the start node is generated to the set of paths of child nodes;
(2)If a child nodes are end nodes, turn to(5);If the non-end node of child nodes, Ze Gai roadsFootpath out to be temporarily stored in Temps set;Until all child nodes of current start node are disposed;
(3)If temporary path set Temps is not sky, each temporary path in gathering Temps obtains its periproctThe child nodes of point, are then turned to(2);Otherwise, under steering(4);
(4)The workflow traversal that current start node starts is finished, if start node combination Starts is sky, is turned toUnder(5), otherwise, in steering(1), continue executing with;
(5)Respective path deposit TestPaths set, that is, generate test path set TestPaths.
Step 5, table is described based on the data object created in step 2(Including perform before state, input data set andAnticipated output data acquisition system), each executable path in test path set TestPaths is changed and extended,The unrelated test case set PiTestCases of generating platform, basic implementation procedure is as follows:
(1)If test path set TestPaths non-NULLs, an executable path is obtained;
(2)Obtain the node semantics created in the start node in current executable path, query steps two and describe tableNodeDescribeTable, with its corresponding status data Expressive Features(State before including performing, input data set and pre-Phase output data set)Replace the node;
(3)Order obtains the node semantics created in the next node in path, query steps two and describes tableNodeDescribeTable, with its corresponding status data Expressive Features(State before including performing, input data set and pre-Phase output data set)Replace the node;
Repeat(3), subsequent node is continued with, until all subsequent nodes are disposed, and the test of conversion generationUse-case deposit set PITestCases;
Repeat(1)-(3), until all paths are finished by conversion process in test path set TestPaths, andUltimately generate platform-independent test case set PITestCases.
Step 6, based on the unrelated data object value mapping table related to platform of the platform created in step 3PItoPSMapTable, the platform-independent test case set PITestCases generated successively in process step five, passes through numberAccording to the related test case set PSTestCases of transfer process automatic Generation Platform, basic implementation procedure is as follows:
(1)If set PITestCases non-NULLs, obtain under the unrelated test case PiTC of a platform, and steering(2);Otherwise, it is disposed;
(2)Obtain the unrelated number related to platform of the platform created in the first data object in PiTC, query steps threeAccording to object value mapping table PItoPSMapTable, with its corresponding platform relevant state data Expressive Features(State, defeated before performingEnter data acquisition system and anticipated output data acquisition system)The data object in PiTC is replaced,
(2)Step, which can be refined, to be described as:
A)Obtain first data object in PiTC;If without data object to be processed, turned to(3);
B)PItoPSMapTable is inquired about, its normal value set and abnormal value set is obtained, recording exceptional value number NUM,Normal value number only remembers 1;
C)NUM+1 PiTC backup is replicated, replaces first in NUM backup PiTC respectively with NUM abnormal Value DataData object, and NUM test case PiTC ' deposit set PSTestCases after replacing;
D)Normal value is randomly choosed from normal value set and replaces a backup PiTC, and this replace after test useExample PiTC ' out to be temporarily stored in PsTemp set;
E)Appoint from PsTemp and take a PiTC ', if getting next data object, PiTC ' replaces currentPiTC, and turn to A);If PsTemp is sky, turn to(3);
(3)Turn to(1), continue with next PiTC;
Repeat(1)-(3), finished until the unrelated test case of all platforms is processed in set PITestCases,And ultimately generate the related test case set PSTestCases of platform.
The method of the present invention is on the basis of component design model, member function logical description form and number based on XMLAccording to the platform of object is unrelated, platform associated description form mapping of refining, the automatic life of member unit test case data is realizedInto.There is beneficial effect following prominent compared with prior art:
(One)Same data object is the unrelated description form related to platform of platform under different phase, and between themRefine and be mapping through database bivariate table and be described and configure, process realize it is simple, should be readily appreciated that and use.
(Two)Platform-independent test case and executable road can inversely be traced back to by the related test case of platformFootpath source, this correctness for helping to implement test case validation verification and model based on feedback is assessed.
(Three)Only need to the renewal of XML content and related tables easy to use, you can different for component to completeThe Test cases technology work of version.Effectively increase component regression test, the efficiency of different editions component testing.
Brief description of the drawings
Fig. 1 is platform-independent data object meta-model in the inventive method;
Fig. 2 is the data object meta-model of platform correlation in the inventive method;
Fig. 3 is the unrelated generation schematic diagram to platform dependence test use-case of platform in the inventive method.
Embodiment
With reference to Figure of description with a kind of component testing use-case generation side based on model of the specific embodiment to the present inventionMethod is described in detail below.
Embodiment:
In the component testing case generation method based on model of the present invention, platform-independent data object meta-model is for example attachedShown in Fig. 1, the related data object meta-model of platform as shown in Figure 2, the data of the unrelated two kinds of forms related to platform of platformConversion generating process between object is as shown in Figure 3.It implements process and comprised the following steps:
Step one:Based on the uml diagram created, the XML of manual creation reflection member function logic describes document:
When creating XML documents, according to each single item workflow in correspondence uml diagram, entered using semantic clearly XML tagRow translation and description.Using predefined tag element correspondence descriptive model in element, including start node, end node,Intermediate node, branch node, cyclic node, aggregation node, parallel node etc..Tag element can be by user's self-defining and expansionExhibition.All tag elements are recorded and semantic tagger by Label_Config documents.
Step 2:Each single item workflow in uml diagram, clearly marks the state that each node is includedData, and the semantic description table NodeDescribeTable of manual creation data object:
The Expressive Features of the node state data include:State before node NodeNo, executionStatesBeforeExecution, input data set InputData and anticipated output data set ExpectOutputData;
Based on the Expressive Features of node state data, the set of data objects included in each status data is determinedDataObjectSet, wherein, each data object DataObject Expressive Features are:Data object nameObjectName, characteristic attribute set ObjectAttributes.
Step 3:Obtained set of data objects is analyzed in object-oriented platform and step 2, the data pair based on determinationAs codomain and about beam analysis and the specific mapping state values of data object under target platform are automatically generated, and created on this basisData object is built by the unrelated value mapping table PItoPSMapTable related to platform of platform:
Wherein, the platform association attributes feature of data object includes:Parameter list paraList, parameter value domainValueDomain, state valid data state(Including bool types, true:Valid data;false:Invalid data), lead toCross the codomain of data object and about beam analysis, the corresponding mapping object of generation, and record its abnormal value set under target platformWith normal value set.
Step 4:The XML document of traversal description member function logic, automatically generates the workflow of counterpart member function logicSet
Its basic implementation procedure is:
(1)Start node set Starts non-NULLs, then obtain a start node, and the method traveled through according to level obtains itChild nodes, and the start node is generated to the set of paths of child nodes;
(2)If a child nodes are end nodes, turn to(5);If the non-end node of child nodes, Ze Gai roadsFootpath out to be temporarily stored in Temps set;Until all child nodes of current start node are disposed;
(3)If temporary path set Temps is not sky, each temporary path in gathering Temps obtains its periproctThe child nodes of point, are then turned to(2);Otherwise, under steering(4);
(4)The workflow traversal that current start node starts is finished, if start node combination Starts is sky, is turned toUnder(5), otherwise, in steering(1), continue executing with;
(5)Respective path deposit TestPaths set, that is, generate test path set TestPaths.
Step 5:Table is described based on the data object created in step 2(Including perform before state, input data set andAnticipated output data acquisition system), each executable path in test path set TestPaths is changed and extended,The unrelated test case set PiTestCases of generating platform.
Basic implementation procedure is as follows:
(1)If test path set TestPaths non-NULLs, an executable path is obtained;
(2)Obtain the node semantics created in the start node in current executable path, query steps two and describe tableNodeDescribeTable, with its corresponding status data Expressive Features(State before including performing, input data set and pre-Phase output data set)Replace the node;
(3)Order obtains the node semantics created in the next node in path, query steps two and describes tableNodeDescribeTable, with its corresponding status data Expressive Features(State before including performing, input data set and pre-Phase output data set)Replace the node;
Repeat(3), subsequent node is continued with, until all subsequent nodes are disposed, and the test of conversion generationUse-case deposit set PITestCases;
Repeat(1)-(3), until all paths are finished by conversion process in test path set TestPaths, andUltimately generate platform-independent test case set PITestCases.
Step 6:Based on the unrelated data object value mapping table related to platform of the platform created in step 3PItoPSMapTable, the platform-independent test case set PITestCases generated successively in process step five, passes through numberAccording to the related test case set PSTestCases of transfer process automatic Generation Platform, basic implementation procedure is as follows:
(1)If set PITestCases non-NULLs, obtain under the unrelated test case PiTC of a platform, and steering(2);Otherwise, it is disposed;
(2)Obtain the unrelated number related to platform of the platform created in the first data object in PiTC, query steps threeAccording to object value mapping table PItoPSMapTable, with its corresponding platform relevant state data Expressive Features(State, defeated before performingEnter data acquisition system and anticipated output data acquisition system)The data object in PiTC is replaced,
(2)Step, which can be refined, to be described as:
A)Obtain first data object in PiTC;If without data object to be processed, turned to(3);
B)PItoPSMapTable is inquired about, its normal value set and abnormal value set is obtained, recording exceptional value number NUM,Normal value number only remembers 1;
C)NUM+1 PiTC backup is replicated, replaces first in NUM backup PiTC respectively with NUM abnormal Value DataData object, and NUM test case PiTC ' deposit set PSTestCases after replacing;
D)Normal value is randomly choosed from normal value set and replaces a backup PiTC, and this replace after test useExample PiTC ' out to be temporarily stored in PsTemp set;
E)Appoint from PsTemp and take a PiTC ', if getting next data object, PiTC ' replaces currentPiTC, and turn to A);If PsTemp is sky, turn to(3);
(3)Turn to(1), continue with next PiTC;
Repeat(1)-(3), finished until the unrelated test case of all platforms is processed in set PITestCases,And ultimately generate the related test case set PSTestCases of platform.