Conversation
epszaw
approved these changes
Jun 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds
Allure.TestingPlatform, a shared MTP integration layer that can be used directly as a standalone Allure adapter or embedded by framework-specific adapters.The implementation covers runtime registration, configuration discovery, CLI options, result writing, SDK messages and properties, correlation strategies, crash watchdog support, and base classes for custom MTP extensions.
Registration Modes
Allure.TestingPlatformsupports two registration modes:Standalone: the package acts as the primary Allure adapter for an MTP test project.Embedded: another adapter or SDK usesAllure.TestingPlatformas its runtime, writer, lifecycle, and message-processing layer.Both modes share the same runtime state machine and service registration pipeline.
Standalone Use And Self-Registration
Standalone use is the default package experience. The package ships an MSBuild self-registration hook:
Allure.TestingPlatform.AllureTestingPlatformBuilderHookTestingPlatformBuilderHookmetadata inbuildTransitiveAllure_TestingPlatformEnableSelfRegistration=trueWhen self-registration is enabled, Microsoft.Testing.Platform.MSBuild calls
AllureTestingPlatformBuilderHook.AddExtensions, which registersAllure.TestingPlatformin standalone mode with default options.Self-registration can be disabled in the test project:
When self-registration is disabled, standalone registration can still be performed explicitly:
or with custom options:
Standalone Configuration
Standalone registration is configured through
IStandaloneAllureRegistrationContext.Convenience helpers are available for common cases:
The lower-level configuration API allows replacing the resolved dependencies:
UseConfiguration(...): provide anAllureConfigurationfactory.SetIsEnabled(...): decide whether the runtime is enabled.UseWriter(...): provide anIAllureResultsWriter.UseTypeFormatters(...): provide parameter type formatters.DisableHostProcessWatchdog(): disable the crash watchdog through registration.Default configuration discovery reads, in order:
UseConfigurationFileALLURE_CONFIGenvironment variableallureConfig.jsonfrom the application base directoryIf the MTP result directory is available, the default Allure results directory is placed under it as
allure-results. The CLI--allure-results-directoryoption overrides the discovered configuration directory when the built-in configuration reader is used.Embedded Configuration
Embedded mode is intended for adapters that already integrate with Microsoft Testing Platform and want to reuse the Allure runtime.
Embedded registration uses
IEmbeddedAllureRegistrationContext, which inherits the standalone configuration options and adds SDK-specific hooks:UseCorrelation(...): provide a customICorrelationStrategy.SetSdkEventHandlers(...): subscribe to runtime events.UseMtpSessionCorrelation(): correlate messages by MTP session UID.UseTestNodeMetadataCorrelation(): correlate messages by test node metadata.UseLogger(...): provide the logger used by the adapter.UseLifecycle(...): provide anAllureLifecycle.AddEmbeddedAllurereturns anIAllureTestingPlatformRuntimeReferenceRegistry, so the embedding SDK can resolve the runtime reference associated with an MTPIServiceProvider.CLI Options
The adapter registers an MTP command-line options provider with these options:
--allurecontrols whether the Allure runtime is enabled. It defaults toon.--allure-watchdogcontrols the crash watchdog. It defaults toonand overrides the registration-time watchdog setting when supplied.--allure-results-directorysets the output directory for Allure result files. This is honored by the built-in configuration reader. If a custom configuration factory is supplied, it is up to that factory to honor the option.Messages And Properties
The SDK exposes MTP data messages that allow embedded adapters to describe Allure lifecycle operations without directly mutating the lifecycle:
AllureScopeStartMessage,AllureScopeStopMessage, andAllureScopeTestsMessageAllureBeforeFixtureStartMessageandAllureAfterFixtureStartMessageAllureFixtureUpdateMessageandAllureFixtureStopMessageAllureTestUpdateMessageMessages carry a
CorrelationUidand context identifiers such asScopeContextUid,FixtureContextUid, andTestContextUid. The data consumer uses these identifiers to buffer, route, and apply operations to the correct Allure lifecycle context.Messages are customized with Allure properties. The property set covers:
This gives framework-specific adapters a narrow public surface for producing Allure results while keeping lifecycle ordering and writer interaction inside
Allure.TestingPlatform.Correlation
Correlation connects MTP messages and Allure SDK messages that belong to the same logical test session. The motivation for using correlation is that the MTP identifier that serves the same purpose (namely, SessionUid) is inaccessible via the extension API in some test frameworks.
The public abstraction is:
A CorrelationUid is basically an alternative for SessionUid. It's expected to have a 1-1 correlation between these identifiers.
Built-in strategies include:
TestingPlatformSessionUidCorrelationStrategy: uses the MTPSessionUid.TestNodeMetadataCorrelationStrategy: reads a correlation value fromTestMetadataPropertywith keyAllure.TestingPlatform.CorrelationUidattached to aTestNodeUpdateMessage.Watchdog
The adapter includes
AllureTestingPlatformHostProcessWatchdog, an MTP test host process lifetime handler. When enabled, it writes a global Allure error if the test host process exits unexpectedly.The watchdog is enabled by default. Sometimes, it may cause the test application to behave unexpectedly, e.g., when a nested MTP application is created. Use the registration API to disable it:
or via the CLI:
Base Extension Classes
The SDK includes base classes for MTP extensions that need access to the Allure runtime.
AllureTestingPlatformExtensionimplements the common MTPIExtensionplumbing and exposes protected runtime dependencies:LoggerConfigurationWriterTypeFormattersLifecycleCorrelationStrategyConfiguredRuntimeLiveRuntimeUse this base class for extensions that consume an already configured or live runtime.
AllureTestingPlatformRuntimeControllerExtensionis for extensions that are responsible for configuring or starting the runtime. It wraps anIAllureTestingPlatformRuntimeController, configures the runtime fromIsEnabledAsync, and exposesEnsureRuntimeStarted()for process-lifetime hooks that may need to write results after a crash or other late event.The built-in data consumer, in-process runtime controller, and host process watchdog are implemented using these runtime abstractions.
Known limitations
Allure.TestingPlatform uses an isolated AllureLifecycle instance and manipulates the context asynchronously relative to test methods. This makes the current implementation of the runtime API unsupported. Fixing it requires decoupling the API from the AllureLifecycle static singleton. This is the subject of a follow-up PR.
Checklist