title | description | services | ms.suite | author | ms.author | ms.reviewer | ms.topic | ms.date |
---|---|---|---|---|---|---|---|---|
Test logic apps with mock data |
Set up static results for testing logic apps with mock data without affecting production environments |
logic-apps |
integration |
kevinlam1 |
klam |
estfan, logicappspm |
article |
05/13/2019 |
When testing your logic apps, you might not be ready to actually call or access apps, services, and systems for various reasons. Usually in these scenarios, you might have to run different condition paths, force errors, provide specific message response bodies, or even try skipping some steps. By setting up static results for an action in your logic app, you can mock output data from that action. Enabling static results on an action doesn't run the action, but returns the mock data instead.
For example, if you set up static results for the Outlook 365 send mail action, the Logic Apps engine just returns the mock data you specified as static results, rather than call Outlook and send an email.
-
An Azure subscription. If you don't have an Azure subscription, sign up for a free Azure account.
-
Basic knowledge about how to create logic apps
-
The logic app where you want to set up static results
-
If you haven't already, in the Azure portal, open your logic app in the Logic Apps Designer.
-
On the action where you want to set up static results, follow these steps:
-
In the action's upper-right corner, choose the ellipses (...) button, and select Static result, for example:
-
Choose Enable Static Result. For the required (*) properties, specify the mock output values you want to return for the action's response.
For example, here are the required properties for the HTTP action:
Property Description Status The action's status to return Status Code The specific status code to return Headers The header content to return To enter the mock data in JavaScript Object Notation (JSON) format, choose Switch to JSON Mode (
).
-
For optional properties, open the Select optional fields list, and select the properties that you want to mock.
-
-
When you're ready to save, choose Done.
In the action's upper-right corner, the title bar now shows a test beaker icon (
), which indicates that you've enabled static results.
To find previous runs that use mock data, see Find runs that use static results later in this topic.
If your logic app has a previous run with outputs you can reuse as mock outputs, you can copy and paste the outputs from that run.
-
If you haven't already, in the Azure portal, open your logic app in the Logic Apps Designer.
-
On your logic app's main menu, select Overview.
-
In the Runs history section, select the logic app run you want.
-
In your logic app's workflow, find and expand the action that has the outputs you want.
-
Choose the Show raw outputs link.
-
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.
-
Follow the steps for opening the Static result box for your action in Set up static results.
-
After the Static result box opens, choose either step:
-
In the JSON editor, paste your previously copied JSON.
-
When you're finished, choose Done. Or, to return to the designer, choose Switch Editor Mode (
).
Your logic app's runs history identifies the runs where the actions use static results. To find these runs, follow these steps:
-
On your logic app's main menu, select Overview.
-
In the right pane, under Runs history, find the Static Results column.
Any run that includes actions with results has the Static Results column set to Enabled, for example:
-
To view actions that use static results, select the run you want where the Static Results column is set to Enabled.
Actions that use static results show the test beaker (
) icon, for example:
Turning off static results doesn't throw away the values from your last setup. So, when you turn on static results the next time, you can continue using your previous values.
-
Find the action where you want to disable static outputs. In the action's upper-right corner, choose the test beaker icon (
).
-
Choose Disable Static Result > Done.
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
- Learn more about Azure Logic Apps