Page MenuHomePhabricator

Simplify asserting expected stats in unit / integration tests
Open, Needs TriagePublic

Description

As a developer working on code that uses statslib / StatsFactory to emit stats, I want to be able to test that it emits the right stats. (This is especially relevant if I’m migrating existing code from statsd to statslib – see T350592, with an example test for T359248 – and there are existing tests for the metrics that should be kept.)

Right now, there’s no fantastic way to do this yet. HashBagOStuffTest (suggested by @colewhite) comes pretty close, and it’s nice how the expected data can be specified as a single string, but the setup seems a bit longer than you’d like, and it also relies on some code that’s not currently stable to use in extensions (StatsFactory isn’t currently stable to construct, but that code needs new StatsFactory() to inject a custom $statsCache and $emitter). It would be nice to offer a better way to set this kind of test up.