Context
coverlet.MTP currently generates coverage reports from its ITestHostProcessLifetimeHandler. Another MTP extension that needs those reports cannot safely use the same callback because registration order between independent extensions is not guaranteed. This is the race reported in microsoft/testfx#8904 for ReportGenerator.Mtp.
Microsoft.Testing.Platform has now merged a first-class coverage message and consumer model in microsoft/testfx#9896, planned for the currently unreleased MTP 2.4.0:
TestCoverageReportMessage publishes the path and format of a generated report.
TestCoverageMessage publishes covered/coverable counts by scope and metric.
TestCoverageThresholdMessage publishes threshold evaluations.
ITestCoverageResult exposes the correlated reports, measurements, and thresholds to consumers.
ITestCoverageCapabilities lets consumers detect enabled coverage producers.
Request
Once coverlet.MTP can target MTP 2.4.0, could it adopt these contracts?
At minimum, CollectorExtension could implement IDataProducer, advertise TestCoverageReportMessage in DataTypesProduced, and publish one message on IMessageBus after each on-disk coverage report is successfully written. Publishing TestCoverageMessage for Coverlet's summary metrics and TestCoverageThresholdMessage for its threshold results would also let MTP's built-in terminal and CI reporters consume Coverlet data consistently.
ReportGenerator.Mtp could then consume the report references through ITestCoverageResult during ITestSessionLifetimeHandler.OnTestSessionFinishingAsync (or consume TestCoverageReportMessage directly), removing the cross-extension lifetime-handler ordering dependency and file-glob polling.
Relevant design: RFC 019 — Code coverage messages & consumer model.
Context
coverlet.MTPcurrently generates coverage reports from itsITestHostProcessLifetimeHandler. Another MTP extension that needs those reports cannot safely use the same callback because registration order between independent extensions is not guaranteed. This is the race reported in microsoft/testfx#8904 for ReportGenerator.Mtp.Microsoft.Testing.Platform has now merged a first-class coverage message and consumer model in microsoft/testfx#9896, planned for the currently unreleased MTP 2.4.0:
TestCoverageReportMessagepublishes the path and format of a generated report.TestCoverageMessagepublishes covered/coverable counts by scope and metric.TestCoverageThresholdMessagepublishes threshold evaluations.ITestCoverageResultexposes the correlated reports, measurements, and thresholds to consumers.ITestCoverageCapabilitieslets consumers detect enabled coverage producers.Request
Once
coverlet.MTPcan target MTP 2.4.0, could it adopt these contracts?At minimum,
CollectorExtensioncould implementIDataProducer, advertiseTestCoverageReportMessageinDataTypesProduced, and publish one message onIMessageBusafter each on-disk coverage report is successfully written. PublishingTestCoverageMessagefor Coverlet's summary metrics andTestCoverageThresholdMessagefor its threshold results would also let MTP's built-in terminal and CI reporters consume Coverlet data consistently.ReportGenerator.Mtp could then consume the report references through
ITestCoverageResultduringITestSessionLifetimeHandler.OnTestSessionFinishingAsync(or consumeTestCoverageReportMessagedirectly), removing the cross-extension lifetime-handler ordering dependency and file-glob polling.Relevant design: RFC 019 — Code coverage messages & consumer model.