How can I wait for a message to be consumed on MassTransit Test Harness?
Asked Answered
R

0

7

I'm performing integrations tests on my dotnet runtime and I am using MassTransit TestHarness to simulate a message broker. Everything works great, but I can't find an easy way to lock the tests main thread to wait for the messages to be consumed. Currently I'm using a loop with delay tasks, (which works), but was hoping for a more synchronous approach. Any suggestions?

This is the integration test app runtime setup:

integration test setup

I tried the following solution which works, but I wasn't able to have it working with the commented statement.

message consumption lock

Retriever answered 2/2, 2023 at 11:7 Comment(3)
Add your entire test to the question, or there isn't enough information to know. If your consumer takes a long time to produce or consume the message you can use SetTestTimeouts to increase the inactivity timeout.Buddhi
It's a .NET core Web API application integration test using the Microsoft application factory to execute the application. Have updated the post with more info. Meanwhile, your suggestions to use SetTestTimeouts worked, thank youLamination
There is a sample to integrate with WebApplicationFactory that might help you.Buddhi

© 2022 - 2024 — McMap. All rights reserved.