Skip to content

Commit 00aa9a9

Browse files
authored
Merge pull request #300345 from wsilveiranz/wsilveira-la-testing-framework
Add documentation for Logic Apps Automated Test Framework SDK
2 parents b9eceaa + cc9f657 commit 00aa9a9

20 files changed

+1302
-17
lines changed
Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
---
2+
title: ActionMock class
3+
description: Creates a mock instance for an action in a Standard logic app workflow for unit testing.
4+
services: logic-apps
5+
ms.suite: integration
6+
author: wsilveiranz
7+
ms.reviewer: estfan, azla
8+
ms.topic: reference
9+
ms.date: 06/10/2025
10+
---
11+
12+
# ActionMock class
13+
14+
**Namespace**: Microsoft.Azure.Workflows.UnitTesting.Definitions
15+
16+
This class creates a mock instance for an action in a Standard logic app workflow. The **`*ActionMock`** class provides multiple ways to create mock actions for testing Standard workflows with static outputs, error conditions, or dynamic behavior based on execution context.
17+
18+
## Usage
19+
20+
```C#
21+
// Simple mock action with success status
22+
var successAction = new ActionMock(TestWorkflowStatus.Succeeded, "SendEmail");
23+
24+
// A mock action with specific outputs
25+
var outputAction = new ActionMock(
26+
TestWorkflowStatus.Succeeded,
27+
"HttpRequest",
28+
new MockOutput {
29+
StatusCode = 200,
30+
Headers = JToken.Parse(@"{""Content-Type"": ""application/json""}"),
31+
Body = JToken.Parse(@"{""result"": ""success"", ""id"": 12345}")
32+
});
33+
34+
// Failed action with error information
35+
var failedAction = new ActionMock(
36+
TestWorkflowStatus.Failed,
37+
"DatabaseWrite",
38+
new TestErrorInfo(
39+
ErrorResponseCode.BadRequest,
40+
"Database connection failed"
41+
));
42+
43+
// Dynamic action that changes behavior based on execution context
44+
var dynamicAction = new ActionMock(
45+
(context) => {
46+
var inputs = context.ActionContext.ActionInputs;
47+
var amount = (int)inputs["amount"];
48+
49+
if (amount > 1000) {
50+
return new ActionMock(TestWorkflowStatus.Failed, "PaymentProcessing",
51+
new TestErrorInfo(ErrorResponseCode.BadRequest, "Amount exceeds limit"));
52+
}
53+
54+
return new ActionMock(TestWorkflowStatus.Succeeded, "PaymentProcessing",
55+
new MockOutput { Body = JToken.Parse(@"{""transactionId"": ""ABC123""}") });
56+
},
57+
"DynamicPaymentAction");
58+
```
59+
60+
## Constructors
61+
62+
### Constructor with static outputs
63+
64+
Creates a mock instance for **`ActionMock`** with static outputs.
65+
66+
```C#
67+
public ActionMock(TestWorkflowStatus status, string name = null, MockOutput outputs = null)
68+
```
69+
70+
| Name | Description | Type | Required |
71+
|---|---|---|---|
72+
| status | The mock action result status. | [TestWorkflowStatus](test-workflow-status-enum-definition.md) | Yes |
73+
| name | The mock action name. | string | No |
74+
| outputs| The mock static outputs. | MockOutput | No |
75+
76+
```C#
77+
// Example: Create a mock action with successful status and static outputs
78+
var outputs = new MockOutput {
79+
Body = JToken.Parse(@"{""result"": ""Operation completed""}"),
80+
StatusCode = 200
81+
};
82+
var actionMock = new ActionMock(TestWorkflowStatus.Succeeded, "ProcessData", outputs);
83+
```
84+
85+
### Constructor with error info
86+
87+
Creates a mock instance for **`ActionMock`** with static error info.
88+
89+
```C#
90+
public ActionMock(TestWorkflowStatus status, string name = null, TestErrorInfo error = null)
91+
```
92+
93+
|Name|Description|Type|Required|
94+
|---|---|---|---|
95+
|status|The mock action result status.|TestWorkflowStatus|Yes|
96+
|name|The mock action name.|string|No|
97+
|error|The mock action error info.|TestErrorInfo|No|
98+
99+
```C#
100+
// Example: Create an action mock with failed status and error information
101+
var errorInfo = new TestErrorInfo(
102+
ErrorResponseCode.InternalServerError,
103+
"Service temporarily unavailable"
104+
);
105+
var actionMock = new ActionMock(TestWorkflowStatus.Failed, "ExternalAPICall", errorInfo);
106+
```
107+
108+
### Constructor with callback function
109+
110+
Creates a mock instance for **`ActionMock`** with a callback function for dynamic outputs.
111+
112+
```C#
113+
public ActionMock(Func<TestExecutionContext, ActionMock> onGetActionMock, string name = null)
114+
```
115+
116+
|Name|Description|Type|Required|
117+
|---|---|---|---|
118+
|onGetActionMock|The callback function to get the mock action|Func&lt;[TestExecutionContext](test-execution-context-class-definition.md), [ActionMock](action-mock-class-definition.md)&gt;|Yes|
119+
|name|The mock action name|string|No|
120+
121+
```C#
122+
// Example: Create a mock action with dynamic outputs based on execution context
123+
var actionMock = new ActionMock(
124+
(context) => {
125+
var actionName = context.ActionContext.ActionName;
126+
var inputs = context.ActionContext.ActionInputs;
127+
// Determine outputs dynamically based on context
128+
if (actionName == "ValidateUser" && inputs["userId"]?.Value<int>() > 0) {
129+
return new ActionMock(
130+
TestWorkflowStatus.Succeeded,
131+
"ValidateUser",
132+
new MockOutput { Body = JToken.Parse(@"{""isValid"": true}") }
133+
);
134+
}
135+
136+
return new ActionMock(TestWorkflowStatus.Failed, "ValidateUser");
137+
},
138+
"ConditionalValidation");
139+
```
140+
141+
### JSON constructor
142+
143+
Creates a mock instance for **`ActionMock`** from JSON.
144+
145+
```C#
146+
internal ActionMock(TestWorkflowStatus status, string name = null, JToken outputs = null, TestErrorInfo error = null)
147+
```
148+
149+
|Name|Description|Type|Required|
150+
|---|---|---|---|
151+
|status|The mock action result status.|[TestWorkflowStatus](test-workflow-status-enum-definition.md)|Yes|
152+
|name|The mock action name.|string|No|
153+
|outputs|The mock outputs.|MockOutput|No|
154+
|error|The mock error.|[TestErrorInfo](test-error-info-class-definition.md)|No|
155+
156+
```C#
157+
// Example: Create a mock action from JSON
158+
var actionFromJson = JsonConvert.DeserializeObject<ActionMock>(File.ReadAllText(mockDataPath));
159+
```
160+
161+
## Properties
162+
163+
This class inherits the following properties from the **`OperationMock`** base class.
164+
165+
|Name|Description|Type|Required|
166+
|---|---|---|---|
167+
|Name|Gets or sets the name for the mock operation.|string|No|
168+
|Status|Gets or sets the operation status.|[TestWorkflowStatus](test-workflow-status-enum-definition.md)|No|
169+
|Outputs|Gets or sets a value that represents static output in JSON format.|JToken|No|
170+
|Error|Gets or sets the operation error.|[TestErrorInfo](test-error-info-class-definition.md)|No|
171+
172+
## Related content
173+
174+
- [TestActionExecutionContext](test-action-execution-context-class-definition.md)
175+
- [TestErrorInfo](test-error-info-class-definition.md)
176+
- [TestErrorResponseAdditionalInfo](test-error-response-additional-info-class-definition.md)
177+
- [TestExecutionContext](test-execution-context-class-definition.md)
178+
- [TestIterationItem](test-iteration-item-class-definition.md)
179+
- [TestWorkflowOutputParameter](test-workflow-output-parameter-class-definition.md)
180+
- [TestWorkflowRun](test-workflow-run-class-definition.md)
181+
- [TestWorkflowRunActionRepetitionResult](test-workflow-run-action-repetition-result-class-definition.md)
182+
- [TestWorkflowRunActionResult](test-workflow-run-action-result-class-definition.md)
183+
- [TestWorkflowRunTriggerResult](test-workflow-run-trigger-result-class-definition.md)
184+
- [TestWorkflowStatus](test-workflow-status-enum-definition.md)
185+
- [TriggerMock](trigger-mock-class-definition.md)
186+
- [UnitTestExecutor](unit-test-executor-class-definition.md)
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
title: Azure Logic Apps Automated Test SDK
3+
description: Reference documentation for the Azure Logic Apps Automated Test SDK classes and enums.
4+
services: logic-apps
5+
ms.suite: integration
6+
author: wsilveiranz
7+
ms.reviewer: estfan, azla
8+
ms.topic: conceptual
9+
ms.date: 06/10/2025
10+
---
11+
12+
# Azure Logic Apps Automated Test SDK
13+
14+
This SDK provides a comprehensive framework for unit testing Standard workflows in single-tenant Azure Logic Apps. You can create mock operations and data, run workflows in isolation, and validate execution results.
15+
16+
The SDK contains several key components that work together to provide a complete testing solution:
17+
18+
| Component | Description |
19+
|-----------|-------------|
20+
| **Test execution** | Core classes for running workflow tests |
21+
| **Mock data** | Classes for creating mock triggers and actions |
22+
| **Test context** | Classes that represent test execution state and context |
23+
| **Results** | Classes that contain workflow execution results and status information |
24+
| **Error handling** | Classes for managing test errors and exceptions |
25+
26+
## SDK classes and enums
27+
28+
| Class/Enum | Description | Type |
29+
|------------|-------------|------|
30+
| [UnitTestExecutor](unit-test-executor-class-definition.md) | Main entry point for executing unit tests for Standard workflows in Azure Logic Apps | Class |
31+
| [ActionMock](action-mock-class-definition.md) | Represents a mock action for workflow testing. | Class |
32+
| [TriggerMock](trigger-mock-class-definition.md) | Represents a mock trigger for workflow testing. | Class |
33+
| [TestActionExecutionContext](test-action-execution-context-class-definition.md) | Represents the execution context for a specific action in a test workflow. | Class |
34+
| [TestExecutionContext](test-execution-context-class-definition.md) | Represents the execution context for a test workflow. | Class |
35+
| [TestIterationItem](test-iteration-item-class-definition.md) | Represents an iteration item in a test workflow execution. | Class |
36+
| [TestWorkflowRun](test-workflow-run-class-definition.md) | Represents the result of a workflow test execution. | Class |
37+
| [TestErrorInfo](test-error-info-class-definition.md) | Contains detailed information about errors that occur during workflow testing. | Class |
38+
| [TestErrorResponseAdditionalInfo](test-error-response-additional-info-class-definition.md) | Contains more information about error responses in workflow testing. | Class |
39+
| [TestWorkflowOutputParameter](test-workflow-output-parameter-class-definition.md) | Represents an output parameter from a workflow test execution. | Class |
40+
| [TestWorkflowRunActionRepetitionResult](test-workflow-run-action-repetition-result-class-definition.md) | Represents the result of an action repetition in a workflow test run. | Class |
41+
| [TestWorkflowRunActionResult](test-workflow-run-action-result-class-definition.md) | Represents the result of an action execution in a workflow test run. | Class |
42+
| [TestWorkflowRunTriggerResult](test-workflow-run-trigger-result-class-definition.md) | Represents the result of a trigger execution in a workflow test run. | Class |
43+
| [TestWorkflowStatus](test-workflow-status-enum-definition.md) | Defines the possible status values for a test workflow execution. | Enum |
44+
45+
## Get started
46+
47+
To begin using the Azure Logic Apps Automated Test SDK, set up and run your workflow tests by starting with the [**`UnitTestExecutor`**](unit-test-executor-class-definition.md) class. Create test data with the [**`ActionMock`**](action-mock-class-definition.md) and [**`TriggerMock`**](trigger-mock-class-definition.md) classes, and validate your workflow behavior by examining the [**`TestWorkflowRun`**](test-workflow-run-class-definition.md) results.
48+
49+
## Key concepts
50+
51+
### Test execution flow
52+
53+
1. **Initialize**: Create a **`UnitTestExecutor`** object with your workflow definition and configuration files.
54+
55+
1. **Mock the data**: Create **`TriggerMock`** and **`ActionMock`** objects to simulate external dependencies.
56+
57+
1. **Execute**: Run the workflow using the **`RunWorkflowAsync()`** method.
58+
59+
1. **Validate**: Examine the **`TestWorkflowRun`** result to verify the expected behavior.
60+
61+
### Mock objects
62+
63+
Mock objects let you simulate external dependencies and control the data flow in your tests.
64+
65+
- **`TriggerMock`**: Simulates workflow triggers, such as HTTP requests, timers, and so on.
66+
- **`ActionMock`**: Simulates workflow actions, such as API calls, database operations, and so on.
67+
68+
### Test results
69+
70+
The SDK provides the following detailed information about test execution:
71+
72+
| Item | Description |
73+
|------|-------------|
74+
| **Status** | Overall workflow execution status |
75+
| **Actions** | Individual action execution results |
76+
| **Errors** | Detailed error information if execution fails |
77+
| **Output** | Workflow output parameters and values |
78+
79+
## Best practices
80+
81+
- Create comprehensive mock data that covers both success and failure scenarios.
82+
- Improve test readability by using meaningful names for your mock objects.
83+
- Validate both successful execution paths and error handling scenarios.
84+
- Organize your test files in a clear directory structure.
85+
- Use appropriate timeout values for your specific workflow requirements.
86+
87+
## Related content
88+
89+
- [Create unit tests from Standard workflow definitions in Azure Logic Apps with Visual Studio Code](create-unit-tests-Standard-workflow-definitions-visual-studio-code.md)
90+
- [Create unit tests from Standard workflow runs in Azure Logic Apps with Visual Studio Code](create-unit-tests-standard-workflow-runs-visual-studio-code.md)

articles/logic-apps/testing-framework/create-unit-tests-standard-workflow-definitions-visual-studio-code.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,14 @@ author: wsilveiranz
77
ms.author: wsilveira
88
ms.reviewer: estfan, azla
99
ms.topic: how-to
10-
ms.date: 04/14/2025
10+
ms.date: 06/09/2025
1111
# Customer intent: As logic app developer, I want to learn how to create a unit test that mocks the operations and outputs from a Standard workflow definition in Azure Logic Apps with Visual Studio Code.
1212
---
1313

14-
# Create unit tests from Standard workflow definitions in Azure Logic Apps with Visual Studio Code (Preview)
14+
# Create unit tests from Standard workflow definitions in Azure Logic Apps with Visual Studio Code
1515

1616
[!INCLUDE [logic-apps-sku-standard](../../../includes/logic-apps-sku-standard.md)]
1717

18-
> [!NOTE]
19-
>
20-
> This capability is in preview and is subject to the [**Supplemental Terms of Use for Microsoft Azure Previews**](https://azure.microsoft.com/support/legal/preview-supplemental-terms/).
21-
2218
Unit testing is an essential practice that keeps your app or solution reliable and accurate throughout the software development lifecycle. Unit tests help you efficiently and systematically validate the key components in your solution.
2319

2420
For Standard logic app workflows, you can create unit tests by using Visual Studio Code and the Azure Logic Apps (Standard) extension. This capability lets you use workflow definitions to create unit tests and tailor them to scenarios supported by your logic app solution - all without needing connections to any external services, systems, or APIs. This approach lets you test your workflows without having to interact with external services, systems, or APIs and provides the following benefits:
@@ -260,4 +256,4 @@ public CallExternalAPIActionMock CallExternalAPIActionMockOutputCallback(TestExe
260256

261257
## Related content
262258

263-
[Create unit tests from Standard workflow runs in Azure Logic Apps with Visual Studio Code](create-unit-tests-standard-workflow-runs-visual-studio-code.md)
259+
* [Create unit tests from Standard workflow runs in Azure Logic Apps with Visual Studio Code](create-unit-tests-standard-workflow-runs-visual-studio-code.md)

articles/logic-apps/testing-framework/create-unit-tests-standard-workflow-runs-visual-studio-code.md

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,14 @@ author: wsilveiranz
77
ms.author: wsilveira
88
ms.reviewer: estfan, azla
99
ms.topic: how-to
10-
ms.date: 04/24/2025
10+
ms.date: 06/09/2025
1111

1212
---
1313

14-
# Create unit tests from Standard workflow runs in Azure Logic Apps with Visual Studio Code (Preview)
14+
# Create unit tests from Standard workflow runs in Azure Logic Apps with Visual Studio Code
1515

1616
[!INCLUDE [logic-apps-sku-standard](../../../includes/logic-apps-sku-standard.md)]
1717

18-
> [!NOTE]
19-
>
20-
> This capability is in preview and is subject to the
21-
> [**Supplemental Terms of Use for Microsoft Azure Previews**](https://azure.microsoft.com/support/legal/preview-supplemental-terms/).
22-
2318
Unit testing is an essential practice that keeps your app or solution reliable and accurate throughout the software development lifecycle. Unit tests help you efficiently and systematically validate the key components in your solution.
2419

2520
For Standard logic app workflows, you can create unit tests by using Visual Studio Code and the Azure Logic Apps (Standard) extension. This capability lets you use previously executed workflow runs to create unit tests and tailor them to scenarios supported by your logic app solution. This approach provides the following benefits:
@@ -365,5 +360,5 @@ public CallExternalAPIActionMock CallExternalAPIActionMockOutputCallback(TestExe
365360

366361
## Related content
367362

368-
[Create unit tests from Standard workflow definitions in Azure Logic Apps with Visual Studio Code](create-unit-tests-Standard-workflow-definitions-visual-studio-code.md)
363+
* [Create unit tests from Standard workflow definitions in Azure Logic Apps with Visual Studio Code](create-unit-tests-Standard-workflow-definitions-visual-studio-code.md)
369364

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
title: TestActionExecutionContext class
3+
description: The execution context for a unit test action that contains action details and iteration information.
4+
services: logic-apps
5+
ms.suite: integration
6+
author: wsilveiranz
7+
ms.reviewer: estfan, azla
8+
ms.topic: reference
9+
ms.date: 06/10/2025
10+
---
11+
12+
# TestActionExecutionContext class
13+
14+
**Namespace**: Microsoft.Azure.Workflows.UnitTesting.Definitions
15+
16+
The execution context for a unit test action, this class stores information about the current action running in a test for a Standard logic app workflow. This information includes the action name, inputs, parent action context, and iteration details for looping scenarios.
17+
18+
## Properties
19+
20+
|Name|Description|Type|Required|
21+
|---|---|---|---|
22+
|ActionName|The current action name|string|Yes|
23+
|ActionInputs|The current action inputs|JToken|No|
24+
|ParentActionName|The current parent action name|string|No|
25+
|CurrentIterationInput|The current iteration input|[TestIterationItem](test-iteration-item-class-definition.md)|No|
26+
27+
## Related content
28+
29+
- [ActionMock Class Definition](action-mock-class-definition.md)
30+
- [TriggerMock Class Definition](trigger-mock-class-definition.md)
31+
- [TestErrorInfo Class Definition](test-error-info-class-definition.md)
32+
- [TestErrorResponseAdditionalInfo Class Definition](test-error-response-additional-info-class-definition.md)
33+
- [TestExecutionContext Class Definition](test-execution-context-class-definition.md)
34+
- [TestIterationItem Class Definition](test-iteration-item-class-definition.md)
35+
- [TestWorkflowOutputParameter Class Definition](test-workflow-output-parameter-class-definition.md)
36+
- [TestWorkflowRun Class Definition](test-workflow-run-class-definition.md)
37+
- [TestWorkflowRunActionRepetitionResult Class Definition](test-workflow-run-action-repetition-result-class-definition.md)
38+
- [TestWorkflowRunActionResult Class Definition](test-workflow-run-action-result-class-definition.md)
39+
- [TestWorkflowRunTriggerResult Class Definition](test-workflow-run-trigger-result-class-definition.md)
40+
- [TestWorkflowStatus Enum Definition](test-workflow-status-enum-definition.md)
41+
42+
- [UnitTestExecutor Class Definition](unit-test-executor-class-definition.md)

0 commit comments

Comments
 (0)