diff --git a/test/WorkflowCore.IntegrationTests/Scenarios/MiddlewareScenario.cs b/test/WorkflowCore.IntegrationTests/Scenarios/MiddlewareScenario.cs index 1c6929209..530b94a58 100644 --- a/test/WorkflowCore.IntegrationTests/Scenarios/MiddlewareScenario.cs +++ b/test/WorkflowCore.IntegrationTests/Scenarios/MiddlewareScenario.cs @@ -136,6 +136,12 @@ public async Task Should_run_all_workflow_and_step_middleware() // Workflow should complete without errors status.Should().Be(WorkflowStatus.Complete); UnhandledStepErrors.Count.Should().Be(0); + + // Wait for post middleware to complete + while (_workflowMiddleware.Any(x => !x.HasCompleted)) + { + await Task.Delay(500); + } // Each middleware should have run _workflowMiddleware.Should()