Skip to content

Files

Latest commit

 

History

History
273 lines (149 loc) · 15.1 KB

test-logic-apps-mock-data-static-results.md

File metadata and controls

273 lines (149 loc) · 15.1 KB
title description services ms.suite ms.reviewer ms.topic ms.date
Mock test workflows
Set up mock data to test workflows in Azure Logic Apps without affecting production environments.
logic-apps
integration
estfan, azla
how-to
10/08/2021

Test workflows with mock data in Azure Logic Apps (Preview)

Note

This capability is in preview and is subject to the Supplemental Terms of Use for Microsoft Azure Previews.

To test your workflows without actually calling or accessing live apps, data, services, or systems, you can set up and return mock values from actions. For example, you might want to test different action paths based on various conditions, force errors, provide specific message response bodies, or even try skipping some steps. Setting up mock data testing on an action doesn't run the action, but returns the mock data instead.

For example, if you set up mock data for the Outlook 365 send mail action, Azure Logic Apps just returns the mock data that you provided, rather than call Outlook and send an email.

This article shows how to set up mock data on an action in a workflow for the Logic App (Consumption) and the Logic App (Standard) resource type. You can find previous workflow runs that use these mock data and reuse existing action outputs as mock data.

Prerequisites

Enable mock data output

  1. In the Azure portal, open your logic app workflow in the designer.

  2. On the action where you want to return mock data, follow these steps:

    1. In the action's upper-right corner, select the ellipses (...) button, and then select Testing, for example:

      Screenshot showing the Azure portal, workflow designer, action shortcut menu, and "Testing" selected.

    2. On the Testing pane, select Enable Static Result (Preview). When the action's required (*) properties appear, specify the mock output values that you want to return as the action's response.

      The properties differ based on the selected action type. For example, the HTTP action has the following required properties:

      Property Description
      Status The action's status to return
      Status Code The specific status code to return as output
      Headers The header content to return

      Screenshot showing the "Testing" pane after selecting "Enable Static Result".

      [!TIP] To enter the values in JavaScript Object Notation (JSON) format, select Switch to JSON Mode (Icon for "Switch to JSON Mode").

    3. For optional properties, open the Select optional fields list, and select the properties that you want to mock.

      Screenshot showing the "Testing" pane with "Select optional fields" list opened.

  3. When you're ready, select Done.

    In the action's upper-right corner, the title bar now shows a test beaker icon (Icon for static result), which indicates that you've enabled static results.

    Screenshot showing an action with the static result icon.

    To find workflow runs that use mock data, review Find runs that use static results later in this topic.

  1. In the Azure portal, open your logic app workflow in the designer.

  2. On the designer, select the action where you want to return mock data so that the action details pane appears.

  3. After the action details pane opens to the right side, select Testing.

    Screenshot showing the Azure portal, workflow designer, action details pane, and "Testing" selected.

  4. On the Testing tab, select Enable Static Result (Preview). When the action's required (*) properties appear, specify the mock output values that you want to return as the action's response.

    The properties differ based on the selected action type. For example, the HTTP action has the following required properties:

    Property Description
    Status The action's status to return
    Status Code The specific status code to return as output
    Headers The header content to return

    Screenshot showing the "Testing" tab after selecting "Enable Static Result".

    [!TIP] To enter the values in JavaScript Object Notation (JSON) format, select Switch to JSON Mode (Icon for "Switch to JSON Mode").

  5. For optional properties, open the Select optional fields list, and select the properties that you want to mock.

    Screenshot showing the "Testing" pane with "Select optional fields" list opened.

  6. When you're ready, select Done.

    The action's lower-right corner now shows a test beaker icon (Icon for static result), which indicates that you've enabled static results.

    Screenshot showing an action with the static result icon on designer.

    To find workflow runs that use mock data, review Find runs that use static results later in this topic.


Find runs that use mock data

To find earlier workflow runs where the actions use mock data, review that workflow's run history.

  1. In the Azure portal, open your logic app workflow in the designer.

  2. On your logic app resource menu, select Overview.

  3. Under the Essentials section, select Runs history, if not already selected.

  4. In the Runs history table, find the Static Results column.

    Any run that includes actions with mock data output has the Static Results column set to Enabled, for example:

    Screenshot showing the workflow run history with the "Static Results" column.

  5. To view that actions in a run that uses mock data, select the run that you want where the Static Results column is set to Enabled.

    Actions that use static results show the test beaker (Icon for static result) icon, for example:

    Screenshot showing workflow run history with actions that use static result.

To find other workflow runs where the actions use mock data, you have to check each run.

  1. In the Azure portal, open your logic app workflow in the designer.

  2. On the workflow menu, select Overview.

  3. Under the Essentials section, select Run History, if not already selected.

  4. In the Run History table, select the run that you want to review.

    Screenshot showing the workflow run history.

  5. On the run details pane, check whether any actions show the test beaker (Icon for static result) icon, for example:

    Screenshot showing workflow run history with actions that use static result.


Reuse previous outputs as mock data

If you have a previous workflow run with outputs, you can reuse these outputs as mock data by copying and pasting those outputs from that run.

  1. In the Azure portal, open your logic app workflow in the designer.

  2. On your logic app resource menu, select Overview.

  3. Under the Essentials section, select Runs history, if not already selected. From the list that appears, select the workflow run that you want.

    Screenshot showing workflow run history.

  4. After the run details pane opens, expand the action that has the outputs that you want.

  5. In the Outputs section, select Show raw outputs.

  6. On the Outputs pane, copy either the complete JavaScript Object Notation (JSON) object or the specific subsection you want to use, for example, the outputs section, or even just the headers section.

  7. Review the earlier section about how to set up mock data for an action, and follow the steps to open the action's Testing pane.

  8. After the Testing pane opens, choose either step:

    • To paste a complete JSON object, next to the Testing label, select Switch to JSON Mode (Icon for "Switch to JSON Mode"):

      Screenshot showing "Switch to JSON Mode" icon selected to paste complete JSON object.

    • To paste just a JSON section, next to that section's label, such as Output or Headers, select Switch to JSON Mode, for example:

      Screenshot showing "Switch to JSON Mode" icon selected to paste a section from a JSON object.

  9. In the JSON editor, paste your previously copied JSON.

    Screenshot showing the pasted JSON in the editor.

  10. When you're finished, select Done. Or, to return to the designer, select Switch Editor Mode (Icon for "Switch Editor Mode").

  1. In the Azure portal, open your logic app workflow in the designer.

  2. On the workflow menu, select Overview.

  3. Under the Essentials section, select Run History, if not already selected.

  4. In the Run History table, select the run that you want to review.

    Screenshot showing the workflow run history.

  5. After the run details pane opens, select the action that has the outputs that you want.

  6. In the Outputs section, select Show raw outputs.

  7. On the Outputs pane, copy either the complete JavaScript Object Notation (JSON) object or the specific subsection you want to use, for example, the outputs section, or even just the headers section.

  8. Review the earlier section about how to set up mock data for an action, and follow the steps to open the action's Testing tab.

  9. After the Testing tab opens, choose either step:

    • To paste a complete JSON object, next to the Testing label, select Switch to JSON Mode (Icon for "Switch to JSON Mode"):

      Screenshot showing "Switch to JSON Mode" icon selected to paste complete JSON object.

    • To paste just a JSON section, next to that section's label, such as Output or Headers, select Switch to JSON Mode, for example:

      Screenshot showing "Switch to JSON Mode" icon selected to paste a section from a JSON object.

  10. In the JSON editor, paste your previously copied JSON.

    Screenshot showing the pasted JSON in the editor.

  11. When you're finished, select Done. Or, to return to the designer, select Switch Editor Mode (Icon for "Switch Editor Mode").


Disable mock data

Turning off static results on an action doesn't remove the values from your last setup. So, if you turn on static result again on the same action, you can continue using your previous values.

  1. In the Azure portal, open your logic app workflow in the designer. Find the action where you want to disable mock data.

  2. In the action's upper-right corner, select the test beaker icon (Icon for static result).

    Screenshot showing the action and the test beaker icon selected.

  3. Select Disable Static Result > Done.

    Screenshot showing the "Disable Static Result" selected.

  1. In the Azure portal, open your logic app workflow in the designer. Select the action where you want to disable mock data.

  2. In the action details pane, select the Testing tab.

  3. Select Disable Static Result > Done.

    Screenshot showing the "Disable Static Result" selected for Standard.


Reference

For more information about this setting in your underlying workflow definitions, see Static results - Schema reference for Workflow Definition Language and runtimeConfiguration.staticResult - Runtime configuration settings

Next steps