Creating Test Cases

Objective

After completing this lesson, you will be able to create and execute a test case

Message Exchange, Overview

The main goal of the PIT tool is to ensure that an integration scenario behaves as expected. Therefore, the PIT tool compares the message processing results of an integration scenario with the corresponding data from a reference system. The comparison is done by verifying the message exchanges of the reference and the test scenario.

A message exchange describes how an incoming XI message (after the sender adapter stage) is processed and transformed into one or multiple outgoing XI messages. This message exchange also includes the response message processing for synchronous scenarios. The message exchange comprises all message parts (such as payloads, headers, and attachments) of incoming and outgoing XI messages.

Example of an Asynchronous Message Exchange

The figure illustrates the build of an asynchronous message exchange.

Example of a Synchronous Message Exchange

The figure illustrates the build of a synchronous message exchange.

You can configure and customize the comparison between message exchanges.

Defining Test Landscape

You must create test cases to be able to extract test data from a source system, process them in the PIT tool, inject them into the target system, and compare the test results with the reference data.

Any Process Integration system taking part in the tests either as test message provider or as target for message injection must be modeled in the PIT as a Test System.

A test system can be a source test system or a target test system or both.

Source Test System

The source system is the reference system within a process integration test. It defines the correct and expected behavior of integration scenarios selected for testing. Message exchanges extracted from the source system are considered to be the expected message processing results.

During configuration time, the PIT tool extracts the following data from the source systems:

  • Information on configuration objects available in the Integration Directory (Integrated Configuration, Integration Flow, or Receiver Determination).
  • Successfully processed Process Integration messages including their payload. These messages are later used as reference data for the test (Test Data Set).

Target Test System

The target test system is the system under test. To test integration scenarios on a target system, test messages are injected, and the message processing results are compared with the corresponding data from the source system. On the target system, the messages are processed by the standard pipeline of the Adapter Engine. The results of the execution are fetched by PIT subsequently.

Defining Test Cases

A Test Case is a central PIT modeling entity, which contains the actual configuration of your test, and it is required for a test execution. A test case corresponds to one message flow of one integration scenario.

You must create test cases to be able to extract test data from a source system, process them in the PIT tool, inject them into the target system, and compare the test results with the reference data.

In some cases, an integration scenario logically consists of several message exchanges (for example, bulk order resulting in multiple single orders including functional acknowledgment, or purchase order, advanced shipment notification, and invoice). In other words, when the scenario is executed, several message flows are involved that are executed in a sequence. Each message flow of this sequence should be configured in an own test case. A test case is always linked to a test system where it can be either executed or from which it can extract data.

The PIT Test Case Browser allows you define the scenario you want to test. A test case corresponds to one integration scenario, for example, one message exchange that should be tested. Sometimes an integration scenario logically consists of several message exchanges (for example bulk order – single order – confirmation), that means it consists of several message flows, which are executed in a row. Each message flow of this sequence should be configured in an own test case. A test case is always linked to a test system where it can be either executed or from which it can extract data

Configuration Objects

You assign configuration objects to your test case. A configuration object describes how the message flow is configured in the corresponding source or target system. It’s either an instance of an integrated configuration, an integration flow, or a receiver determination.

Note

With version 7.50 SP21, you cannot choose Integrated Configurations (ICons), which were created internally during the deployment of Integration Flows (IFlows). For more information, refer to note 3016101.

Typically, several configuration objects are assigned to a test case. Ideally, one test case contains one configuration object per test system participating in the test. Ensure that configuration objects assigned to one test case describe the same message flow, otherwise your test data could be useless or the test not operable.

Nevertheless, the same message flow can be configured differently in different systems. In a Process Integration dual stack/dual usage type system, the message flow is configured to go through the Integration Engine. It’s, therefore, described by loosely coupled configuration objects: a sender agreement, a receiver determination, an interface determination, and a receiver agreement. In an AEX system, the same message flow is configured as an integration flow or by using an integrated configuration object. The configuration can also be slightly different in each system, for example by using a different mapping.

The PIT configuration object only contains a reduced set of data from the original Integration Directory object: the header information, the sender and receiver configuration. It also contains some attributes from the communication channel, such as the Adapter Engine used.

Test Data

A test data set contains messages extracted from an SAP Process Integration system, and is used as reference data during test execution.

The PIT tool extracts the original message exchange with the inbound payload as well as the versions before and after mapping, from the source system. In case of synchronous communication, the same payload versions for the response are extracted as well.

A test data set can contain many messages, and a test case can contain many data sets that were extracted at a different point in time.

The PIT tool supports extraction of successfully processed messages only. But a log version of a message before and after a potential mapping must exist. Therefore, you have to enable message logging before starting message processing.

Message Preprocessing

Message preprocessing allows you to replace values in the payload or values of dynamic headers on the fly before the message is sent to the target system. The replacement can be valid for all system combinations or only for one specific system.

There are scenarios, where, for example, in addition to the message header, the name of a sender system is contained in the payload or in a dynamic header. PIT sets the message header automatically according to the configuration scenario. But values in the payload or dynamic header can’t be adjusted automatically. They are still equal to values in the source payload. If a particular dynamic header or XML node is used in a routing condition in the target system, the routing can fail or lead to a wrong result because of the unexpected value. This makes it impossible to test successfully.

Another use case for modifying the payload on the fly is if you want to test all possible routing paths in the target system, but it is very hard to create a test data set for each of the paths. You can artificially replace a value in the message to test each possible condition path using message preprocessing (assuming that the rest of the payload is valid as well).

Preprocessing Ruleset: Message preprocessing can be defined as part of a test case. You have to create a preprocessing ruleset to define substitution rules to apply to the message. A test case can contain many preprocessing rulesets. In the run configuration you can decide which preprocessing ruleset should be used at runtime. Only one preprocessing ruleset can be used per run

Preprocessing Rule: Each preprocessing ruleset contains at least one preprocessing rule. The rule is applicable to a specified area – currently you can choose between payload or dynamic header. It contains at least one preprocessing instruction with a specified substitution flavor (defined by substitution type):

Substitution Types

  • Constant value substitution:

    Allows you to replace a value independently of the source and target system combination.

    XpathSource ValueTarget Value
    /Address/StreetMaple StreetApple Street
    /Address/NameEllen AdamsEllen Jones
  • System-dependent value substitution:

    Allows you to replace a value dependent on target system (or even based on source/target system combination).

    XpathSource SystemSource ValueTarget SystemTarget Value
    /AddressDEVMaple StreetQUEApple Street
     DEVMaple StreetTSTOak Street
  • Replacement Rule:

    Substitution using a Replacement Rule can be regarded as a special case of a system-dependent value substitution.

    The figure PIT Add Rule shows an example of the Rule.

    Preprocessing Instructions

    Each preprocessing instrustion must contain either:

    • a valid Xpath expression that points to an XML node in the payload (for area = "Payload")
    • or name and namespace of a dynamic header (for area = "Dynamic Header")

You can combine preprocessing instructions pointing to the same or to different Xpath expressions/headers within one preprocessing rule.

At runtime, a value will only be replaced, if the corresponding XML node/header is found in the message and there is a suitable instruction for it. You cannot add or remove an XML node or header from the message.

Test Datasets

A test dataset contains messages extracted from an SAP Process Integration system, and is used as reference data during test execution. Typically a test dataset contains several messages, and is assigned to a test case. A test case itself can contain many datasets that were extracted at a different point in time.

Besides creating test datasets from scratch, you can also import an existing test dataset. Similarly, for later usage, test datasets can also be exported.

During the creation phase, you can select one of the available Extraction Types and, if needed, configure the extraction schedule:

  • Immediate one-time extraction: the extraction takes place once and as soon as you select Finish.
  • One-time extraction at scheduled date: the extraction takes place once and at a time and date you specify.
  • Periodic extraction at scheduled date (produces multiple test datasets): the extraction takes place at a time and date you specify (Start), recurs at defined intervals (Recurrence), and stops at defined point in time (End).

To work with the periodic extractions, use the Periodic Extraction Editor. The editor provides read-only information about a periodic extraction and its extracted test datasets.

With the dataset editor, you can now view, inspect, and check the content of extracted test datasets and perform basic modifications.

In the test dataset editor you can access the following information:

  • General section: name, description, time range, test system, and configuration object.
  • Test Messages table: complete list of successfully extracted test messages.
  • Message Exchange tree: the message exchange of a selected test message with all message elements (payload, dynamic header, attachments) of an PI-message's request (and response) part before and after mapping.
  • Content view: the content of a selected message element, for example an XML-based payload.

You can't change a test dataset anymore after its initial usage in a test run in order that subsequent test results stay comparable and consistent. As a consequence, you can only save a modified dataset if it isn’t used so far in any run configuration. Otherwise you can store it as a new test dataset.

You can also use the merge functionality of the Test Case Editor to conveniently combine the content of two or more compatible datasets into one single object.

Display Message Exchanges

The Message Structure Viewer shows the message exchange in graphical form. It's only available for message extracted or executed with the PIT tool version SP20 or later. You can open the Message Structure Viewer from all places where the message exchange is shown in tree form in the Test Dataset Editor or result overviews.

The Test Dataset Editor and the Execution and Verification Result overviews show the message exchange structure in textual form as a tree.

The Message Exchange Viewer provides you a graphical overview to understand complex message exchanges with a message split, or message exchanges with errors better.

The graphical message exchange structure reflects the processing steps in the XI pipeline. It contains the following elements:

  • The circles at the beginning and the end of the graphic represent sender and receivers of the message.
  • The rectangles represent the available message versions: the incoming message (BI version), and the outgoing messages (MS and AM version). Select the corresponding rectangle in the Properties view, to display the message header, dynamic header, payload, or attachment information for the message version.
  • Hexagons represent the processing steps of the XI pipeline, such as routing, mapping, receiver delivery, and response correlation (for synchronous exchanges only). Two or more outgoing connections denote a message split. If the processing of a step encounters an error, the element is highlighted with a red border and an exclamation mark icon. Select the element to see details about the error category and error code in the Properties view.
  • In a synchronous message exchange, a dashed line from the sender to the receiver (and the steps in between) represents the response processing path.

If you open the Message Structure Viewer from the Test Dataset editor, it only shows the structure of the selected message. If you open it from the result overview, you see the structure of the source and the target message one below the other, assuming that both structures are available.

Defining Test Suites

Test suites allows you to group test cases.

By using test suites, you can logically group test cases. You can, for example, create a test suite which contains test cases that are to be executed after each Support Package update. Or you create a test suite with different mapping tests.

A test case can be assigned to different test suites. A test suite can’t be assigned to another test suite.

Defining Run Configurations

A run configuration is defined as an executable subset of a test case.

Usually, many configuration objects are assigned to a test case. Some of the objects are defined as source and others as target. Generally, also several test data sets were extracted for one test case.

To execute a specific test, you need to specify unambiguously which test case is to be executed with which data set on which target system. A Test Case Run Configuration is a modeling entity that defines that information as a configuration object. It is as an executable artifact of a test case. You can have more than one run configurations per test case.

You can group run configurations into a Test Suite Run Configuration which gives you the possibility to execute several run configurations at once. It is an executable artifact of a test suite.

If you want schedule tests regularly, you need to use run configurations.

For a run configuration you can generate and download a summary to compile test results from a selected time frame in one text document in .docx format. The summary also provides useful statistics and graphs for your evaluation.

You can create a test execution summary the object types test suite run configuration and test case run configuration.

Retention and Protection of Data

To automate the deletion process of data you can define retention policies. With retention policies, you define when and if data will be deleted.

With the protect functionality, you can keep data from being deleted.

Retention Policy

A retention policy defines how long you keep data before it may be deleted automatically. Once the retention time expires, the data will be deleted by the deletion job. This way you can automatically delete data before they accumulate in the database, but at the same time you can mark important data as not needing to be deleted at all. A retention policy considers data that was generated during executions of Test Case Run Configurations and Test Suite Run Configurations, which you can see in the Job Browser and Action Log views.

Unless a different retention policy is created and assigned, the Default Policy is assigned to your job data and target messages. If the administrator hasn't done any changes to the default policy in their system, the default retention policy retains the data for an unlimited time frame unless it's deleted manually.

To view existing retention policies, in SAP NWDS go to Process IntegrationRetention Policies Overview, or go to WindowShow ViewRetention Policies View.

As a prerequisite for data to be deleted in accordance with a retention policy, your administrator must plan the background job PITDeletionJob regularly to execute the deletion. This job checks if retention time did run out for any data and deletes it. If no deletion job is planned, no data is deleted, even if the retention time has run out.

You can schedule PITDeletionJob at NetWeaver AdministratorOperationsJobsJava SchedulerTasks.

If the background deletion job might not delete the data, you can still delete the data manually.

Protecting Data from Deletion

You can protect results against deletion. If a job is protected, it may never be deleted automatically by the deletion job, even if the retention time has already expired according to the retention policy. It can only be deleted, either automatically or manually, once the protection is removed.

Note

You can only protect or remove protection from any jobs besides your own if the required actions are assigned to your role.

Restrictions and Unsupported Scenarios

The following restrictions apply to the PIT tool:

  • Adapter modules processing isn’t part of the test.
  • Business Process Management (BPM) is out of scope.
  • The PIT tool isn’t suitable to be used as load generator (to run performance tests)
  • The PIT tool must not be used to read, store, or process messages containing personal sensitive data.

The following scenarios are not supported by the PIT Tool:

  • Data extraction of unsuccessful messages.
  • Scenarios using integrated configuration or integration flow with sender or receiver wild card.
  • Scenarios with sync/async bridge and async/sync bridge.

Create and Execute a Test Case

Business Scenario

You want to migrate Process Integration Scenarios from SAP Process Integration (SAP PI 7.4) to SAP Process Orchestration (SAP PO 7.5). Therefore, you have to create test cases, collect data from your source system, and replay the test messages in your target system.

Exercise Information

Note

In this exercise, when the values include ##, replace the character with a two-digit number (01–30).

Exercise Options

You can perform this exercise in two ways:

  1. Live Environment: choose Start Exercise, and from the entry page choose Open PDF Document. Follow the steps described in this pdf in your own system landscape.
  2. Simulation: choose Start Exercise, and from the entry page choose Start Tutorial. Watch the step-by-step instructions within the simulation.

Note

We recommend running the simulation first.

Task 1: Create Test Systems

You want to create two Test Systems NWK_Target_## and RWP_Source_##. Therefore, first verify destinations in SAP NetWeaver Administrator, and use these destinations to create your Test Systems.

Steps

  1. Verify Connection settings in SAP NetWeaver Administrator

    1. Open the URL: http://nwktdc00.wdf.sap.corp:50000/dir

    2. Choose SAP NetWeaver Administrator, and logon with your user BIT500-## and your password, if required.

    3. Open ConfigurationInfrastructureDestinations.

    4. Verify the connection setting for the following connections. Note the URL or target host in the table below:

      Connection NameURL/Target Host
      PIT_SYSTEM 
      PI_NWK 
      RWP_Java 
      RWP_800_RFC 
  2. Open SAP Process Integration Test perspective in NWDS.

    1. In NWDS open WindowPerspectiveOpen PerspectiveOtherSAP Process Integration Test.

    2. Choose the Connect to PIT Test Tool button, and log on with your user BIT500-## and your password.

  3. Create a Source System

    1. In the Test System tab, choose Create new test system.

    2. Enter the values from the table below:

      Field NameValue
      NameNWK_Target_##
      Installation TypeAdvanced Adapter Engine Extended
      HTTP DestinationPI_NWK
    3. Choose Finish.

  4. Create a Target System

    1. In the Test System tab, choose Create new test system.

    2. Enter the values from the table below:

      Field NameValue
      NameRWP_Source_##
      Installation TypeDual Usage Type Installation
      HTTP DestinationRWP_Java
      RFC DestinationRWP_800_RFC

Task 2: Create a Test Case

Now you want to create a test case based on the created test systems.

Steps

  1. Create a new test Case TC_RWP_2_NWK_##.

    1. In the SAP Process Integration Test perspective navigate to the Test Catalog tab, and choose Create New Test Case.

    2. In the Create New Test Case window, enter TC_RWP_2_NWK_## into the Name field.

    3. Select the settings from the table below, and choose Next.

      Field NameValue
      Communication PatternAsynchronous
      Source Configuration Object TypeClassic Configuration
      Target Configuration Object TypeIntegration Flow
    4. In the Configuration of the Test Source screen, choose the Browse button and select RWP_Source_## as your source system and your BC_PIT_##_SND Business Component created in the exercise Create a Source Scenario in Task 1.

    5. Choose Next.

    6. In the Configuration of the Test Target screen, choose the Browse button, and select NWK_Target_## as your target system and your iFlow_MaterialA_MaterialsB_##_PIT IFlow created in the exercise Create a Target Scenario.

    7. Choose Finish.

    8. In the Test Case Editor, verify your settings under the Configuration Objects tab.

  2. Fetch a Test Data Set

    1. In the Test Case Editor switch to the Test Data tab, and choose the Add Test Dataset... button.

    2. In the Add Dataset window, enter DS_MaterialA_MaterialsB_## as Name.

    3. Choose the Browse button to select your test system RWP_Source_##.

    4. Choose Next.

    5. Select Immediate One-Time Selection, and choose Next.

    6. In the Specify Message Filter screen, set a valid date and time.

      Field NameValue
      From<Current Date> / <12:00:00 AM>
      To<Current Date> / <Current Time>
      Maximum Number of MessagesDo not change the given value.
    7. Choose Next.

    8. In the Restrict the list of messages to extract select at least one message you have already send in the exercise Create a Source Scenario in task 2 Create some test messages.

    9. Choose Finish.

  3. Define your Test Run

    1. From the menu, choose RunRun Configurations.

    2. Double-click on PIT Test Case.

    3. Enter RC_MaterialA_MaterialsB_## as Name for your configuration.

    4. To choose your Test Case, use the Browse button.

    5. In the Select Test Case window, select MaterialA_MaterialsB_##, and choose OK.

    6. All other fields will be filled automatically. Verify your entries with the table below:

      Field NameValue
      Test CaseTC_RWP_2_NWK_##
      Test DatasetDS_MaterialA_MaterialsB_##
      Target SystemNWK_Target_##
      Target Configuration ObjectiFlow_MaterialA_MaterialsB_##_PIT
      Message DeliveryFlag set for Stop Message Before Delivering to Receiver
    7. Choose Apply.

    8. Choose Close.

  4. Execute your Test Run

    1. From the menu, choose RunRun Configurations.

    2. Navigate to PIT Test Case, and select your Test Case RC_MaterialA_MaterialsB_##.

    3. Choose Run.

    4. The Run Configurations window disappears.

    5. A new entry in the Job Browser appears.

    6. Once the job is finished successfully, you will see Successful in the Job Result column.

Log in to track your progress & complete quizzes