IBM
Contents Index Previous Next



Exercise 3: Test Generation with Tree Walk


What You Will Learn

Preparations

If you have closed the SDL Suite or the Explorer UI temporarily, perform the following steps:

  1. Open the inres system in the Organizer.
  2. Start the Explorer UI.
  3. Open the inres explorer again.

If you have not quit the inres explorer, bring the application to its initial state now:

  1. Select Reset in the Options1 menu.

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:

  1. Click the Tree Walk button in the EXPLORE module.
    A Prompt dialog is displayed.
  2. Enter the value 10.
    This is the maximum number of minutes given to Autolink for computing reports. In fact, the state space exploration is much faster for simple protocols such as Inres.
    Another Prompt dialog is displayed.
  3. 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:01
    
    
    
    Target 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:

  1. Select MSC: Save Reports in the Autolink1 menu.
    A Select dialog is displayed.
  2. Select TreeWalk in order to save all TreeWalk reports.
  3. Click the OK button.
    A Prompt dialog is displayed.
  4. 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

  1. Select Reset in the Options1 menu.
    All options are reset and all generated test cases and reports are cleared.
  2. Select Test case: Generate in the Autolink1 menu.
  3. A Select dialog is displayed.
  4. Select Tutorial_Tree_00007.mpr.
  5. Click the OK button.
  6. Select Test case: Save in the Autolink1 menu.
    A Select dialog is displayed.
  7. Select Tutorial_Tree_00007.
  8. Click the OK button.
    A File name dialog is displayed.
  9. Select the TC directory by double-clicking.
  10. Type Tutorial_Tree_00007.gen in the File field.
  11. Click the OK button.
    The generated test case is stored on disk.

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.

  1. Select Reset in the Options1 menu.
  2. Select Test case: Load in the Autolink1 menu.
    A File name dialog is displayed.
  3. Select file Tutorial_Tree_00007.gen in the Files section.
  4. Click the OK button.
    The generated test case is loaded and identical constraints are merged (if there are identical constraints).
  5. Repeat steps 2 to 4 for all other test cases.
  6. Select Test suite: Save in the Autolink1 menu.
    A Prompt dialog is displayed.
  7. Type TreeWalk in the Test suite name field.
  8. Click the OK button.
    A File name dialog is displayed.
  9. Type TreeWalk.mp the File field.
  10. Click the OK button.
    Autolink saves the test suite file TreeWalk.mp.
    Now you may exit the Explorer:
  11. 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
Contents Index Previous Next