Yin
Yin

Reputation: 301

What is the best way to perform integration test?

Is there anyway to let rebus publish all message synchronously so that I can assert on some value after all message have been processed?

Or what is the best way to do an integration test:

  1. Publish event
  2. handle by saga, send command
  3. Handle command, publish another event
  4. Saga marked as completed
  5. the another event handler update the database
  6. assert or database

Thanks

Regards

Yin

Upvotes: 1

Views: 462

Answers (1)

mookid8000
mookid8000

Reputation: 18628

For testing a single saga and its behavior you should take a look at the blog post I wrote, Unit testing sagas with Rebus, which is an example on how SagaFixture and FakeBus can be used - I think it supports everything you're mentioning that you want to test.

If you're interested in testing more complicated scenarios, possibly involving other handlers and longer message correspondences etc, you might benefit from some strategic use of ManualResetEvent - Rebus has several integration tests that start up a bus and do some stuff, doing a resetEvent.Set() when the scenario is over - this way, the test can do a resetEvent.WaitOne(timeout) to block while the test is running and continue immediately when it's over.

Upvotes: 1

Related Questions