zenstruck / messenger-test

Assertions and helpers for testing your symfony/messenger queues.
MIT License
218 stars 15 forks source link

Reset Transport *before* Tests #40

Closed rodnaph closed 2 years ago

rodnaph commented 2 years ago

Updates the InteractsWithMessenger trait to clear the TestTransport before each test, as well as after.

Previously, the transport was only reset after each test in a TestCase using this trait. If other tests run first though which send messages, but do not make messenger assertions (as the transport is overridden for the entire test environment), then the transport isn't cleared at all, so the first test to run in a test case with this trait will have the state from the previous tests.

I don't know if there's currently a reason for having it specifically after, is this a BC break? Is there a better solution? Is there a test I can add or update to verify this behaviour?

kbond commented 2 years ago

I believe #24 would also solve this issue but let's go with this PR for now.

rodnaph commented 2 years ago

Resetting before makes sense for the reason you describe. We should keep the @after though.

BTW, I merged #39, so if you rebase - the tests should pass.

Updated and rebased, thanks.

kbond commented 2 years ago

Thanks @rodnaph!