你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
此类提供在单租户 Azure 逻辑应用中运行标准逻辑应用工作流单元测试的功能。 该类用作使用模拟数据和自定义配置运行工作流测试的主要入口点。
Namespace
Microsoft.Azure.Workflows.UnitTesting
用法
可以使用 UnitTestExecutor
该类加载工作流定义,并使用测试数据运行工作流:
// Initialize with workflow file path
var executor = new UnitTestExecutor("path/to/workflow.json");
// Initialize with all configuration files
var executor = new UnitTestExecutor(
workflowFilePath: "path/to/workflow.json",
connectionsFilePath: "path/to/connections.json",
parametersFilePath: "path/to/parameters.json",
localSettingsFilePath: "path/to/local.settings.json"
);
// Execute workflow with test mocks
var testMock = new TestMockDefinition
{
TriggerMock = new TriggerMock { /* trigger configuration */ },
ActionMocks = new List<ActionMock> { /* action mocks */ }
};
var result = await executor.RunWorkflowAsync(testMock);
构造函数
UnitTestExecutor(string, string, string, string)
使用工作流和配置文件初始化 UnitTestExecutor
类的新实例。
参数
名称 | 类型 | DESCRIPTION | 必选 |
---|---|---|---|
workflowFilePath | 字符串 | 工作流定义文件的路径 | 是的 |
connectionsFilePath | 字符串 | 连接配置文件的路径 | 否 |
parametersFilePath | 字符串 | 参数配置文件的路径 | 否 |
localSettingsFilePath | 字符串 | 本地设置文件的路径 | 否 |
示例:
var executor = new UnitTestExecutor(
workflowFilePath: "MyWorkflow/workflow.json",
connectionsFilePath: "MyWorkflow/connections.json",
parametersFilePath: "MyWorkflow/parameters.json",
localSettingsFilePath: "local.settings.json"
);
性能
WorkflowSettings
工作流定义设置。
资产 | 类型 | DESCRIPTION | 必选 |
---|---|---|---|
WorkflowSettings | TestWorkflowSettings | 工作流测试执行的配置设置 | 是的 |
方法
RunWorkflowAsync(TestMockDefinition, string, int)
使用提供的配置文件和指定的模拟触发器和模拟作执行工作流。
参数
名称 | 类型 | DESCRIPTION | 必选 | 违约 |
---|---|---|---|---|
testMock | TestMockDefinition | 包含模拟触发器和模拟作的测试模拟定义 | 是的 | - |
customCodeFunctionFilePath | 字符串 | 自定义代码函数文件的路径 | 否 | Null |
timeoutInSeconds | 整数 (int) | 超时配置(以秒为单位) | 否 | DefaultUnitTestTimeoutSeconds |
退货
Task<TestWorkflowRun>
:表示返回工作流运行结果的异步作的任务。
示例:
var testMock = new TestMockDefinition
{
TriggerMock = new TriggerMock
{
Kind = "Http",
Outputs = new
{
body = new { message = "Test message" },
statusCode = 200
}
},
ActionMocks = new List<ActionMock>
{
new ActionMock
{
ActionName = "Send_an_email",
Kind = "Office365Outlook",
Outputs = new { status = "success" }
}
}
};
// Run with default timeout
var result = await executor.RunWorkflowAsync(testMock);
// Run with custom timeout and custom code
var result = await executor.RunWorkflowAsync(
testMock: testMock,
customCodeFunctionFilePath: "path/to/custom-functions.js",
timeoutInSeconds: 120
);
相关内容
- ActionMock 类定义
- TriggerMock 类定义
- TestActionExecutionContext 类定义
- TestExecutionContext 类定义
- TestIterationItem 类定义
- TestWorkflowRun 类定义
- TestErrorInfo 类定义
- TestErrorResponseAdditionalInfo 类定义
- TestWorkflowOutputParameter 类定义
- TestWorkflowRunActionRepetitionResult 类定义
- TestWorkflowRunActionResult 类定义
- TestWorkflowRunTriggerResult 类定义
- TestWorkflowStatus 枚举定义