Skip to content

Conversation

@bantonsson
Copy link
Contributor

Add negative test to tracing mock for Layer not calling on_register_dispatch

Copy link
Contributor

@hds hds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for this!

@hds hds merged commit 976fa55 into tokio-rs:main Nov 24, 2025
55 checks passed
hds added a commit that referenced this pull request Nov 24, 2025
In order to add a regression test, #3379 added support to `tracing-mock`
to expect calls to `on_register_dispatch` for both mock subscribers and
mock layers. A negative integration test for the layer case was included
in #3415. However, there are no negative doctests for this (and as per
my own suggestion, there's no negative test for the subscriber method
either as I wasn't sure it was possible).

After a bit of thought, I realised that we could include a negative test
for the `MockSubscriber`. This change adds that test as a doctest, since
we have those in almost all of our documentation and also includes the
already written negative test for the `MockLayer` to a doctest.
hds added a commit that referenced this pull request Nov 24, 2025
## Motivation

In order to add a regression test, #3379 added support to `tracing-mock`
to expect calls to `on_register_dispatch` for both mock subscribers and
mock layers. A negative integration test for the layer case was included
in #3415. However, there are no negative doctests for this (and as per
my own suggestion, there's no negative test for the subscriber method
either as I wasn't sure it was possible).

## Solution

After a bit of thought, I realised that we could include a negative test
for the `MockSubscriber`. This change adds that test as a doctest, since
we have those in almost all of our documentation and also includes the
already written negative test for the `MockLayer` to a doctest.
hds added a commit that referenced this pull request Nov 25, 2025
# 0.1.0-beta.2 (November 30, 2025)

### Added

- Add `on_register_dispatch` expectation for subscriber and layer mocks ([#3415])
- Add doctests for `on_register_dispatch` negative cases ([#3416])

[#3415]: https://github.com/tokio-rs/tracing/pull/#3415
[#3416]: https://github.com/tokio-rs/tracing/pull/#3416
hds added a commit that referenced this pull request Nov 26, 2025
# 0.1.0-beta.2 (November 26, 2025)

### Added

- Add `on_register_dispatch` expectation for subscriber and layer mocks ([#3415])
- Add doctests for `on_register_dispatch` negative cases ([#3416])

### Changed

- `tracing`: updated to 0.1.42 ([#3418])

[#3415]: https://github.com/tokio-rs/tracing/pull/#3415
[#3416]: https://github.com/tokio-rs/tracing/pull/#3416
[#3418]: https://github.com/tokio-rs/tracing/pull/#3418
hds added a commit that referenced this pull request Nov 26, 2025
# 0.1.0-beta.2 (November 26, 2025)

### Added

- Add `on_register_dispatch` expectation for subscriber and layer mocks ([#3415])
- Add doctests for `on_register_dispatch` negative cases ([#3416])

### Changed

- `tracing`: updated to 0.1.42 ([#3418])

[#3415]: https://github.com/tokio-rs/tracing/pull/#3415
[#3416]: https://github.com/tokio-rs/tracing/pull/#3416
[#3418]: https://github.com/tokio-rs/tracing/pull/#3418
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants