Completing Model Coverage
Completing model element coverage: Creating a new ATGConfiguration
In order to generate additional test cases covering also the uncovered transitions 2 amd 4 as well as reception evReset and operation init, we now can create an additional ATGConfiguration.
We open the ATG main window using menu 'Tools->Automatic Test Generator' or using 'Apply ATG' of the context menu on the TestContext TCon_TheTestCalc. Then, in the ATG main dialog, we right-click the ATGComponent and choose New Test Generation Configuration:
Before we can define the interface of the new ATGConfiguration, we have to clean the TestPackage - for reasons of data consistency, ATG refuses to synchronzie with a TestArchitecture in updated status.
In the dialog appearing on 'Clean TestPackage' asking "Delete also all Result Reports within selected package?", we click 'No' in order to keep the reports.
Instead of invoking 'Clean TestPackage' manually on the TestPackage, one can alternatively invoke 'Synchronize ATG Data with Application' on the newly created ATGConfiguration in the ATG browser. ATG then detects that the TestArchitecture has been populated with test artifacts and prompts the user to clean the TestPackage (note that this alternative has no option to keep the reports).
After applying 'Clean TestPackage' on the TestArchitecture, we synchronize the new ATGConfiguration with Rhapsody:
Now we can define the interface for test case generation:
-
We right-click class TheTestCalc in Input Interfaces and choose Set Interface of selected Class according to TestContext from the context menu.
- We define the arguments for receptions to be driven by ATG as follows:
- We define the arguments for reception evOperand:
- int No : [0-3];1.
Recall that valid registers are only adressed using No==1 or No==2. 0 and 3 are, hence, invalid arguments as register numbers.
-
int Val : [-32767-32767];#20
- int No : [0-3];1.
- We define the arguments for reception evOperation:
-
int op : [0-5];1.
Recall that only 1-4 denote valid operations. 0 and 5 will produce errors.
-
- Note that evReset is checked by default. ATG will send event evReset to TheTestCalc when generating test cases.
- We define the arguments for reception evOperand:
-
We right-click class TC_at_OutputsPt_of_TheTestClass in Traced Instances and Messages and choose Set Interface of selected Class according to TestContext from the context menu.
-
Next we have to define the coverage criterion for test case generation: We switch to tab Coverage Definition and check the box for class TheTestCalc (meaning that model element coverage for class TheTestCalc will be the coverage criterion for test case generation).
Now we can generate test cases for the ATGConfiguration NewConfiguration1
Summarizing coverage in the ATGComponent
After generating test cases and closing the generation dialog, we can see on the General tab for ATGConfiguration NewConfiguration1 that ATG has covered 93 of 106 model elements.
For ATGConfiguration NewConfiguration0 ATG has covered 103 of 106 model elements:
These model element coverages are summarized to 100% model element coverage for ATGComponent TPkg_TheTestCalc_TPkg_TheTestCalc_Comp_DefaultConfig:
Exporting test cases selectively
In the browser part of the ATG main window we inspect the covered model elements of ATGConfiguration NewConfiguration1 and recognize that transitions 2 in TheTestCalc::TestBehaviorSpecification and 4 in TheTestCalc::TestBehaviorSpecification, as well as operation init are covered. Moreover, we see that operation init and transition 2 in TheTestCalc::TestBehaviorSpecification are covered by the same test case (Test case 21).
By right-clicking operation init and transition 4 in TheTestCalc::TestBehaviorSpecification, respectively, and choosing Export Test Cases to Rhapsody from the context menu, we export the desired test cases to Rhapsody, aiming at completing the model coverage for TestContext TCon_TheTestCalc.
Re-Executing TestContext TCon_TheTestCalc
Re-Executing TestContext TCon_TheTestCalc - again, we are prompted for update and build - now yields 100% model element coverage.