How can I use an existing sequence diagram for tests?

Sample model : Samples/CppSamples/TestConductor/TestingCookbook/CppCompositeCoffeeMachine_SDReuse

Reusing a sequence diagram for tests

TestConductor supports creating a new sequence diagram based test case from an existing sequence diagram (or test scenario). The user selects the test architecture the new test case will be created in and TestConductor automatically computes the mapping of instance lines from the source sequence diagram to the instances available in the test architecture and adjusts the message realizations accordingly. Optionally the user can provide mapping rules for the instance lines. An automatically generated mapping report is added to the newly created test case, containing detailed information about the applied mappings.

In order to create a test case from an existing sequence diagram the following steps are necessary:

  • Optionally: Create a new SDMapping with the rules for the mapping of instance lines between the original SD and the test architecture of the new test case (see below).
  • Optionally: Select the SDMapping to be applied by invoking the menu entry "Set as Active SDMapping" on this SDMapping. This automatically deactivates any other SDMapping to ensure only one SDMapping is active. If no mapping shall be applied, search for any SDMapping with the stereotype <<ActiveSDMapping>> and remove this stereotype from the SDMapping.
  • Select the test architecture the new test case shall be created in by setting one of its code generation configuration as active code generation configuration.
  • Right click on the sequence diagram and invoke the menu entry "Create TestCase from Scenario".

Generating an SDMapping

See this step by step example how to create and define an SDMapping. The existing sequence diagram FunctionalSpecification::ExecutionScope_FuncSpec::recorded_observation_functional shall be reused within the test architecture TPkg_Coffeemachine_BB. Note that this sequence diagram contains the two instance lines "itsAddict:Addict" and "itsCMSystem:CMSystem". So a suitable SDMapping has to be generated by the following steps:
  • Select the menu entry "Add New" -> "TestingProfile" -> "SDMapping" on the test package TPkg_Coffeemachine_BB.
  • Rename the new SDMapping to functional_view_to_designmodel.
  • Select the menu entry "Add New" -> "Testing Profile" -> "SDInstanceRealizationMapPair" on the SDMapping functional_view_to designmodel.
  • Rename the new SDInstanceRealizationMapPair to addict_to_TestComponent.
  • Open the feature dialog of the SDInstanceRealizationMapPair addict_to_TestComponent and go to the Tags tab. Set "origin" to "FunctionalSpecification::Addict". Set "target" to "TPkg_Coffeemachine_BB::TCon_Coffeemachine_Architecture::TC_at_pToUI_of_Coffeemachine".
  • Add another SDInstanceRealizationMapPair to the SDMapping functional_view_to_designmode.
  • Rename the new SDInstanceRealizationMapPair to CMSystem_to_Coffeemachine.
  • Open the feature dialog of the SDInstanceRealizationMapPair CMSystem_to_Coffeemachine and go to the Tags tab. Set "origin" to "FunctionalSpecification::CMSystem". Set "target" to "DesignModel::Coffeemachine".
  • Right click on the SDMapping functional_view_to_designmodel and select the menu entry "Set as Active SDMapping" in order to set this mapping as the active one.

The picture below shows the generated SDMapping

Screen capture

Mapping rules can be defined for different purposes: For one to one mapping between classifiers, for splitting an instance line of one classifier into multiple instance lines of different classifiers, or for merging multiple instance lines of different classifiers into one instance line of one classifier.

First Example : Mapping Pairs

The picture below shows a detail of the sequence diagram "recorded_observation_functional" that shall be used for creating a test case in the TPkg_Coffeemachine_BB test architecture. Note that this sequence diagram contains the instance lines "itsAddict:Addict" and "itsCMSystem:CMSystem".

Screen capture

The second picture for this example shows the active SDMapping "functional_view_to_designmodel" for the mapping of sequence diagram "recorded_observation_functional".

Screen capture

The third picture for this example shows a detail of the test case "SD_tc_recorded_observations_functinal" that is generated by the use of the menu entry "Create TestCase from Scenario". Each classifier from the original sequence diagram has been mapped to one classifier in the test architecture.

Screen capture

Second Example : Merge

The picture below shows a detail of the sequence diagram "recorded_wb_observation" that shall be used for creating a test case in the TPkg_Coffeemachine_BB test architecture. Note that this sequence diagram contains the instance lines ":UI", ":Control", ":WaterTank", ":CoffeeBeans", ":Grinder" and ":BrewingUnit".

Screen capture

The second picture for this example shows the active SDMapping "merge_wbview_to_gbtest" for the merging of instance line when mapping the sequence diagram "recorded_wb_observation" into the test architecture.

Screen capture

And the third picture for this example shows a detail of the test case "SD_tc_recorded_wb_observation" that is generated by the use of the menu entry "Create TestCase from Scenario". The picture shows that the original instance lines control, watertank, coffeebeans, grinder and brewingunit are merged to the instance line TCon_Coffeemachine.itsCoffeemachine :Coffeemachine within the resulting test case "SD_tc_recorded_wb_observation".

Screen capture

Third Example : Split

The picture below shows a detail of the sequence diagram "recorded_gb_observation" that shall be used for creating a test case in the TPkg_Coffeemachine_BB test architecture. Note that this sequence diagram contains the instance lines ":UI" and ":Coffeemachine".

Screen capture

The second picture for this example shows the active SDMapping "split_gbview_to_parts" for the splitting of an instance line when mapping sequence diagram "recorded_gb_observation" into the test architecture.

Screen capture

And the third picture for this example shows a detail of the test case "SD_tc_recorded_gb_observation" that is generated by the use of the menu entry "Create TestCase from Scenario". The picture shows that the original instance line :Coffeemachine is split into the instance lines :BrewingUnit, :Grinder, :CoffeeBean, :WaterTank and :Control within the resulting test case "SD_tc_recorded_gb_observation".

Screen capture