Skip to main content
This guide covers all aspects of testing applications that use SimpleMessageBus, from unit testing message handlers to integration testing with real queue providers.

Overview

Testing messaging applications requires different strategies than traditional request-response applications. This guide covers:

Unit Testing

Testing message handlers in isolation

Integration Testing

Testing with real queue providers

End-to-End Testing

Testing complete message flows

Test Utilities

Using SimpleMessageBus.Breakdance for testing

Unit Testing Message Handlers

Basic Handler Testing

Test message handlers using mocks and dependency injection:

Testing Multi-Message Handlers

Test handlers that process multiple message types:

Testing Message Publishing

Test services that publish messages:

Integration Testing

Use test containers for integration testing with real infrastructure:
1

Set Up Test Container

Start a containerized instance of your message queue:
2

Configure Services

Configure SimpleMessageBus to use the test container:
3

Write Integration Tests

Test the complete message flow:

Using SimpleMessageBus.Breakdance

SimpleMessageBus.Breakdance provides testing utilities for easier testing:
1

Install the Package

Add the Breakdance testing package to your test project:
2

Use TestableMessagePublisher

Use the testable publisher for unit testing:
3

Leverage Assertion Methods

The TestableMessagePublisher provides various assertion methods:

End-to-End Testing

Complete Workflow Testing

Test entire message workflows from start to finish:

Performance Testing

Test message processing under load:

Test Utilities and Helpers

Custom Test Builders

Create builders for complex test data:

Test Fixtures

Create reusable test fixtures:

Best Practices

1. Test Isolation

Ensure tests don’t interfere with each other:

2. Deterministic Testing

Make tests deterministic by controlling time and random values:

3. Test Error Scenarios

Always test error conditions:

4. Verify Side Effects

Test all side effects of message processing:

Next Steps

Error Handling

Learn how to handle and test error scenarios

Performance Guide

Test and optimize performance

Configuration

Test different configurations

API Reference

Explore the complete API