I'd like to make a assertions in unit tests to confirm that the telemetry meters Histogram<T>
and Counter<T>
are being called. If I have a reference to the meter instance that the unit test code is calling, is there a way to inspect it and confirm that the Record
or Add
methods are being called or not?
You can't test them directly, however, I don't think that's the way that they should be tested.
You can create a MeterListener that can listen to a specific metric and verify that you get the right outcome rather than the right value is passed. With this, you can pass in a Metric with a specific auto-generated name that you can assert against. Similar to the way that you'd test for Activity
.