Skip to content

Testing

For testing purposes, the test modules should override the MassTransitModuleOptions to include the extension method UseInMemoryScheduler(). This method adds a fake scheduler instance to be used in the TestHarness from MassTransit.

Example:

C#
protected override void ConfigureBootstrapServices(HostBuilderContext context, IServiceCollection bootstrapServices)
{
    base.ConfigureBootstrapServices(context, bootstrapServices);

    //[...]
    bootstrapServices.Configure<MassTransitModuleOptions>(options =>
    {
        options.TransportOptions.AddTransportConfiguration((context, cfg) =>
        {
            cfg.UseInMemoryScheduler();
        });
    }
}