다음을 통해 공유


UnitTestExecutor 클래스

이 클래스는 단일 테넌트 Azure Logic Apps에서 표준 논리 앱 워크플로에 대한 단위 테스트를 실행하는 기능을 제공합니다. 이 클래스는 모의 데이터 및 사용자 지정 구성을 사용하여 워크플로 테스트를 실행하기 위한 주요 진입점 역할을 합니다.

네임스페이스

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 대한 새 인스턴스를 초기화합니다.

매개 변수

이름 유형 설명 필수
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

워크플로 정의 설정입니다.

재산 유형 설명 필수
WorkflowSettings TestWorkflowSettings 워크플로 테스트 실행에 대한 구성 설정

메서드

RunWorkflowAsync(TestMockDefinition, string, int)

지정된 모의 트리거 및 모의 작업과 함께 제공된 구성 파일을 사용하여 워크플로를 실행합니다.

매개 변수

이름 유형 설명 필수 기본값
testMock TestMockDefinition 모의 트리거 및 모의 작업이 포함된 테스트 모의 정의 -
customCodeFunctionFilePath 문자열 사용자 지정 코드 함수 파일의 경로 아니오
타임아웃InSeconds 정수 (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
);