MT docs (here: https://masstransit-project.com/usage/testing.html) say that for testing a consumer using a container based configuration, we should do something like this:
await using var provider = new ServiceCollection()
.AddMassTransitTestHarness(cfg =>
{
cfg.AddConsumer<SubmitOrderConsumer>();
})
.BuildServiceProvider(true);
I have MassTransit 7.3.1 installed, but the sample code method AddMassTransitTestHarness
is nowhere to be found. What am I missing here?
CodePudding user response:
Method AddMassTransitTestHarness
is implemented in MassTransit
as the extension method for IServiceCollection
interface in DependencyInjectionTestingExtensions
class, which was introduced in version 8.0.0
What you are missing is 8 months of the package updates. Try upgrading MassTransit to the newest version.