IBM
Contents Index Previous Next



Exercise 2: Advanced Concepts


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:

Creating a Structured MSC Test Case

For a better understanding, a test case can be structured into different test steps. Typically, a test case consists of three parts:

In this section, you will create a test case with a preamble, a test body and a postamble. This test case will be identical to the one developed in Exercise 1: Basic Concepts except for its structural information.

Creating the Preamble

You can define structured MSC test cases in a similar way as you did in Exercise 1: Basic Concepts.

  1. Click the Navigator button in the EXPLORE module to start the Navigator.
    The Navigator window is displayed.
  2. Navigate through the system by double-clicking in turn on the following nodes:
    1, 1, 1, 1, 1, 1, 1, 1 (i.e. 8 times transition #1),
    3,
    1, 1, 1 (i.e. 3 times transition #1)
    Do not close the Navigator yet.
  3. Select MSC: Save Test Step in the Autolink1 menu to save the current path as an MSC test step.
    A prompt dialog is displayed.
  4. Type Preamble in the Test step name field.
  5. Click the OK button.
    Autolink saves a file called Preamble.mpr in the MSC test steps directory.

The preamble which you have just created is shown in Figure 73.

Creating the Test Body

You should also create the body of the MSC test case:

  1. Type define-root current in the input line to set the current root.
    The following message appears in the text area:
    Root of behaviour tree set to current system state
  2. Double-click the following transitions in the Navigator window:
    1, 1, 1, 1 (i.e. 4 times transition #1),
    10,
    1, 1, 1 (i.e. 3 times transition #1).
    Again, do not close the Navigator.
  3. Select MSC: Save Test Case in the Autolink1 menu to save the path as an MSC test case.
    Make sure that you save the path as a test case, not as test step!
    A Prompt dialog is displayed.
  4. Type Example2 in the Test case name field.
  5. Click the OK button.
    Autolink saves a file called Example2.mpr in the MSC test cases directory.

Now you have defined the body of the test case. See Figure 72.

Figure 72 : The MSC Example2 - test body

Creating the Postamble

Finally, you create the postamble of the MSC.

  1. Again, type define-root current in the input line to set the root.
    The following message appears in the text area:
    Root of behaviour tree set to current system state
    
    
    
  2. Navigate through the system by double-clicking in turn on the following nodes:
    2,
    1, 1, 1.
  3. Select MSC: Save Test Step in the Autolink1 menu.
    A Prompt dialog is displayed.
  4. Type Postamble in the Test step name field.
  5. Click the OK button.
    Autolink saves a file called Postamble.mpr in the MSC test steps directory.

You have now created the postamble of the test case, see Figure 73.

Figure 73 : Preamble and Postamble MSCs

Inserting MSC References

Before you can use MSC Example2 to generate a TTCN test case, you have to insert two global MSC references for the preamble and the postamble. To do this:

  1. Select Toggle MSC Trace in the Commands menu.
    The MSC Editor will start, showing a complete Explorer Trace.
  2. Open MSC Example2.mpr stored in directory TC.
  3. Make the MSC look like Figure 74, that is:
    • Insert two global MSC references, one above the first message and one after the last message.
    • Type Preamble and Postamble (without the file extension .mpr) as reference names.

Figure 74 : Example2

  1. Save the MSC diagram as Example2.msc.
    You have now created a complete structured MSC test case with a pre- and a postamble and you are ready to generate a TTCN test case from it.

In the previous steps, you have changed the root of the behavior tree to the beginning of the postamble. Even though it is not necessary for a direct translation, you should better reset it before continuing.

  1. Switch back to the Explorer UI window.
  2. Type Define-Root Original at the command line.
    The MSC Editor is started, but you do not have to bother about that. Select Toggle MSC Trace in the Commands menu to quit it.

You can list all MSC test cases and test steps currently stored on disk:

  1. Select MSC: List in the Autolink1 menu.
    The following output should appear in the text area:
    MSC test cases:
    
    Example1.mpr Example2.mpr Example2.msc 
    
    
    
    MSC test steps:
    
    Postamble.mpr Preamble.mpr  
    
    
    

It is also possible to remove test cases and test steps from disk. Since you do not need the temporary MSC Example2.mpr any more, you can delete it:

  1. Select MSC: Clear Test Case in the Autolink1 menu.
    A Select dialog is displayed.
  2. Select Example2.mpr.
  3. Click the OK button.
    Another Select dialog is displayed, asking you whether you really want to delete this MSC.
  4. Choose Yes.
  5. Click the OK button.

Defining an Autolink Configuration

Autolink allows to define a configuration which guides the naming and parameterization of constraints, the introduction of test suite parameters and constants and the grouping of test cases and test steps into a hierarchy of test groups. An Autolink configuration consists of a set of rules which have to be written by the user.

In this tutorial you will not learn how to write configuration rules. Instead you will use a pre-defined configuration that covers some aspects of an Autolink configuration. For a detailed descriptions of configuration rules and corresponding examples see Translation Rules and Test Suite Structure Rules.

In a first step you have to create a new command file which contains the Autolink configuration:

  1. Open a text editor.
    The choice of text editor depends on the operating system of your computer.
    Create a new file called config.com.
  2. Type in the following text:
    # -------------------------------
    
    #   Autolink configuration file
    
    #     for the inres protocol
    
    # -------------------------------
    
    
    
    Define-Autolink-Configuration
    
    
    
    TRANSLATE "ICONreq"
    
      CONSTRAINT NAME   "Connection_Request"
    
    END
    
    
    
    TRANSLATE "ICONconf"
    
      CONSTRAINT NAME   "Connection_Confirmation"
    
    END
    
    
    
    TRANSLATE "IDATreq"
    
      CONSTRAINT NAME   "Data_Request"
    
                 PARS   $1="Data"
    
      TESTSUITE  PARS   $1="DataValue"
    
    END
    
    
    
    
    
    TRANSLATE "IDISreq"
    
      CONSTRAINT NAME   "Disconnection_Request"
    
    END
    
    
    
    TRANSLATE "IDISind"
    
      CONSTRAINT NAME   "Disconnection_Indication"
    
    END
    
    
    
    TRANSLATE "MDATind" | "MDATreq"
    
      IF $1 == "{ id CC, *, * }" THEN
    
        CONSTRAINT NAME "Medium_Connection_Confirmation"
    
      END
    
      IF $1 == "{ id AK, *, * }" THEN
    
        CONSTRAINT NAME   "Medium_Acknowledge"
    
      END
    
      CONSTRAINT NAME   "c_" + $0
    
    END
    
    
    
    End
    
    
    
  3. Save the file in your current working directory.

Next, you have to load this configuration into the Explorer:

  1. Select Configuration: Load in the Autolink2 menu.
    A File name dialog is displayed.
  2. Select config.com in the Files section.
  3. Click the OK button.

If an error message is displayed, you have probably made a spelling mistake in the command file. In this case, correct your file and try to reload the configuration.

Translating the MSC into TTCN

In Generating the Test Case, you have learned how to generate an internal test case representation based on an MSC. For that purpose, a state space exploration has been started.

However, in some cases it is not possible to simulate an MSC, e.g. if the internal processes of the SDL system are not fully specified. In these cases, you have to translate an MSC test case directly into an internal test case representation (without performing a state space exploration).

Even though it should be possible to simulate the MSC Example2.msc, you will apply a direct translation in this exercise:

  1. Select Test Case: Translate in the Autolink1 menu.
    A Select dialog is displayed.
  2. Select Example2.msc.
  3. Click the OK button.
    Autolink analyses the preamble, the test body and the postamble and generates a complete, structured test case. The following output should appear in the text area:
    Current state is reset to root.
    
    
    
    MSC 'Example2' loaded.
    
    
    
    Constraints are checked for naming conflicts...
    
    
    
    Constraint 'c_MDATind' is renamed to 
    'c_MDATind_001'.
    
    Constraint 'c_MDATind' is renamed to 
    'c_MDATind_002'.
    
    Constraint 'c_MDATind' is renamed to 
    'c_MDATind_003'.
    
    
    
    Constraints with identical signal definitions are 
    merged automatically...
    
    
    
    ... done.
    
    
    

Take a look at the internal test case representation to see the difference with respect to test case Example1:

  1. Select Test Case: Print in the Autolink1 menu.
    A Select dialog is displayed.
  2. Choose Example2.
  3. Click the OK button.
  4. The output is:
    Example2
    
    
    
      0     IN Preamble
    
      1      ISAP1 ! ICONreq - Connection_Request
    
      2       MSAP2 ? MDATind - c_MDATind_003
    
      3        MSAP2 ! MDATreq - 
    
                  Medium_Connection_Confirmation
    
      4         ISAP1 ? ICONconf - 
    
                   Connection_Confirmation
    
      5          OUT Preamble
    
      6           ISAP1 ! IDATreq - 
                     Data_Request(DataValue)
    
      7 (P)        MSAP2 ? MDATind - c_MDATind_002
    
      8             MSAP2 ! MDATreq - Medium_Acknowledge
    
      9              IN Postamble
    
     10               ISAP1 ! IDISreq - 
    
                         Disconnection_Request
    
     11                ISAP1 ? IDISind - 
    
                          Disconnection_Indication
    
     12  P              MSAP2 ? MDATind - c_MDATind_001
    
     13                  OUT Postamble
    
     11                MSAP2 ? MDATind - c_MDATind_001
    
     12  P              ISAP1 ? IDISind - 
    
                           Disconnection_Indication
    
     13                  OUT Postamble
    
    
    
    Also take a look at the constraints to see what the translation rules in your configuration file have affected:
  5. Select Constraint: List in the Autolink2 menu.
    The following output will appear in the text area:
    Connection_Confirmation :
    
      ICONconf {  }
    
    Connection_Request :
    
      ICONreq {  }
    
    Data_Request(Data) :
    
      IDATreq { iSDUType1 Data }
    
    Disconnection_Indication :
    
      IDISind {  }
    
    Disconnection_Request :
    
      IDISreq {  }
    
    Medium_Acknowledge :
    
      MDATreq { mSDUType1 { id AK, num one, data 55 } }
    
    Medium_Connection_Confirmation :
    
      MDATreq { mSDUType1 { id CC, num zero, data 55 } }
    
    c_MDATind_001 :
    
      MDATind { mSDUType1 { id DR, num one, data 55 } }
    
    c_MDATind_002 :
    
      MDATind { mSDUType1 { id DT, num one, data 55 } }
    
    c_MDATind_003 :
    
      MDATind { mSDUType1 { id CR, num zero, data 0 } }
    

Saving the TTCN Test Suite

When a TTCN test suite is created, test steps can be stored in different formats. By default, test steps are put into the test step library. However, you might want to save them locally, i.e. attached to their test cases:

  1. Select Autolink: Test Steps Format in the Options2 menu.
    A Select dialog is displayed.
  2. Select Local.
  3. Click the OK button.

Now, you are ready to save the test suite:

  1. Select Test Suite: Save in the Autolink1 menu.
    A Prompt dialog is displayed.
  2. Type inres2_local in the Test suite name field.
  3. Click the OK button.
    A File name dialog is displayed.
  4. Type inres2_local.mp in the File field.
  5. Click the OK button.
    Autolink saves the test suite in file inres2_local.mp.

You may want to save the test suite in different formats. To do this:

  1. Select Autolink: Test Steps Format in the Options2 menu.
    A Select dialog is displayed.
  2. Select Global or Inline.
  3. Click the OK button.
  4. Save the test suite as above. You can save the current test suite as often as you like.

Merging With the Old Test Suite

It is possible to merge the new TTCN test case (with its constraints) with an existing test suite.

  1. Make sure that the inres test suite you created in the first part of this tutorial is opened in the TTCN Suite. This test suite contains test case Example1.
  2. On UNIX, select Autolink Merge from the SDT Link menu in the Browser.
    In Windows, select Autolink Merge from the File menu.
  3. In the dialog that is opened, select inres2_local.mp.
  4. Click Merge (UNIX) or OK (Windows).
    The test case and the constraints from the inres2_local.mp file will now be merged into the old test suite.

There are more possibilities to merge test cases: Autolink also provides commands to combine separately generated test cases within the Explorer. For a detailed description see Computing Test Cases.


http://www.ibm.com/rational
Contents Index Previous Next