![]() |
![]() |
![]() |
![]() |
![]() |
Exercise 3: Test Generation with Tree Walk
What You Will Learn
- To create a large number of MSC test cases automatically
- To save and load generated test cases in Autolink
- To distribute test case generation
Preparations
If you have closed the SDL Suite or the Explorer UI temporarily, perform the following steps:
If you have not quit the inres explorer, bring the application to its initial state now:
Creating MSC Test Cases Automatically
In the previous exercises, you had to specify your MSC test cases manually. Creating test cases by hand gives you full control over what is tested.
However, you might not be interested in defining tests for particular aspects of your SDL system. Instead, you only wish to create a large number of test cases randomly which cover most symbols of the SDL system.
In this case, you can use the Tree Walk algorithm provided by Autolink to generate test cases automatically.
In the first step, a number of TreeWalk reports have to be computed:
- Click the Tree Walk button in the EXPLORE module.
- Enter the value 10.
- Enter the value 100.
- This is the percentage of symbol coverage that you want to reach when executing your test cases.
- A message similar to the one below will appear in the text area:
Tree Walk will stop after 10 minutes or after reaching 100% symbol coverage.Reports and symbol coverage table cleared.States: 2109. Reports: 3. Tree walk reports: 0 (+31). Coverage: 100.00%. Time: 000:00:01Target symbol coverage is reached.Tree Walk is stopped.Test report #1 of length 7 added.Test report #2 of length 8 added.Test report #3 of length 12 added.Test report #4 of length 16 added.Test report #5 of length 16 added.Test report #6 of length 20 added.Test report #7 of length 22 added.Test report #8 of length 30 added.Test report #9 of length 32 added.The output above states that nine reports have been generated. When traversing their corresponding paths, a total symbol coverage of 100 percent is reached. The Tree Walk command stops immediately when it reaches the targeted symbol coverage.
Since Autolink requires MSC test cases as input, you have to convert the TreeWalk reports into MSCs:
- Select MSC: Save Reports in the Autolink1 menu.
- Select TreeWalk in order to save all TreeWalk reports.
- Click the OK button.
- Enter Tutorial as test case name prefix.
- Autolink saves all TreeWalk reports as system level MSCs in distinct files in the test cases directory:
MSC test case is saved in file '/home/tutorial/inres/TC/Tutorial_Tree_00001.mpr'.MSC test case is saved in file '/home/tutorial/inres/TC/Tutorial_Tree_00002.mpr'.MSC test case is saved in file...MSC test case is saved in file'/home/tutorial/inres/TC/Tutorial_Tree_00009.mpr'.Generating the Test Cases
In the previous exercises you have learned how to generate internal test case representations from MSCs. If you want more than one test case, you can either compute all test cases in the test cases directory at once - by a single command - or compute one test case after another.
For large SDL systems, test generation may take some time. In this case, it is advantageous not to compute all test cases in a single explorer session. Instead, each test case (or a small number of test cases) should be computed separately, preferably in parallel on different machines.
To enable distributed test generation, Autolink allows to store internal test case representations on disk. After all test cases have been computed, their internal representations can be reloaded from disk and saved in a single test suite. While loading the test cases, Autolink checks them for consistency and merges identical constraints.
Generating and Saving a Single Test Case
- Select Reset in the Options1 menu.
- Select Test case: Generate in the Autolink1 menu.
- A Select dialog is displayed.
- Select Tutorial_Tree_00007.mpr.
- Click the OK button.
- Select Test case: Save in the Autolink1 menu.
- Select Tutorial_Tree_00007.
- Click the OK button.
- Select the TC directory by double-clicking.
- Type Tutorial_Tree_00007.gen in the File field.
- Click the OK button.
Repeat steps 1 to 11 for other TreeWalk test cases.
Saving the Test Suite
Once you have created all test cases and saved them in files, you can combine them and create a test suite.
- Select Reset in the Options1 menu.
- Select Test case: Load in the Autolink1 menu.
- Select file Tutorial_Tree_00007.gen in the Files section.
- Click the OK button.
- Repeat steps 2 to 4 for all other test cases.
- Select Test suite: Save in the Autolink1 menu.
- Type TreeWalk in the Test suite name field.
- Click the OK button.
- Type TreeWalk.mp the File field.
- Click the OK button.
- Select Exit in the File menu.
In order to take a look at the TTCN test suite, add the test suite to the Organizer just like you did in the first and second example above.
http://www.ibm.com/rational |
![]() |
![]() |
![]() |
![]() |