Skip to content

Commit 984c2c6

Browse files
EvangelinkCopilot
andcommitted
Preserve ignored data rows in UI test hosts
Reject unsupported deployment only after data-source and row ignore decisions. Track forwarded UI context APIs after the main rebase and document the distinct MSBuild wrapper exit contract. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent 0cf6e3b commit 984c2c6

9 files changed

Lines changed: 172 additions & 21 deletions

File tree

‎docs/decisions/shared-core-ui-contract.md‎

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ It builds on the merged [#12412](https://github.com/microsoft/testfx/pull/12412)
1818
- Modern UWP/WinUI tests with method/class `DeploymentItemAttribute`, including
1919
inherited attributes, return an ordinary failed-test result before any test
2020
body, through reflection, Rooting and ReflectionFree metadata providers.
21+
Ignored data sources and rows remain ignored for both folding strategies;
22+
unsupported deployment is rejected only for rows that would execute.
2123
Classic UWP uses netstandard core without that attribute.
2224
- No new handshake, launcher, cancellation or cleanup policy is introduced.
2325
Existing MTP result/exit aggregation handles the failure; unaffected tests
@@ -166,6 +168,100 @@ owns the composed activation/release-branch evidence. No CI result is credited
166168
for this head. The comparison source is restored and the primary worktree was
167169
never mutated for the counterfactual.
168170

171+
## Review corrections: 2026-11-16
172+
173+
The layer was rebased onto freshly fetched main
174+
`ddb33a558d5200030053e571dba7a65de476f317`, preserving the new ordinary
175+
Extensions deployment forwarder and all four real-UWP localization cases.
176+
The originally observed remote head was
177+
`7b382c059ea63629db1f53d72632399af60c74ed`.
178+
179+
The two live review findings concern separate boundaries:
180+
181+
- The Modern UWP helper invokes desktop MSBuild's `InvokeTestingPlatform`
182+
target. Its returned exit is MSBuild's failure code (1), not the direct
183+
host's `ExitCode.AtLeastOneTestFailed` (2). Keep 1 and name/document that
184+
boundary; the direct WinUI host still correctly asserts 2.
185+
- Checking deployment at `RunTestMethodAsync` entry bypasses both unfolded
186+
`TestDataSourceIgnoreMessage` and folded `ITestDataSourceIgnoreCapability`.
187+
The shared `ExecuteTestAsync` entry is after those decisions and the
188+
`ITestDataRow` ignore decision, but still before initialization or test bodies.
189+
Moving the existing check there preserves aggregation and per-row context
190+
ownership without adding another ignore implementation.
191+
192+
The existing three packed WinUI metadata-provider cases now include a folded
193+
method-level deployment source and an unfolded class-level deployment source.
194+
Each has one ignored and one active row. The TRX oracle binds each identity to
195+
its expected outcome, preserves the ignored reason, and checks that all six
196+
active deployment cases fail without the body marker. The metadata-provider
197+
control still passes. Each child should return 2 with six failed, one passed
198+
and two skipped results; the outer acceptance cases should pass.
199+
200+
The first rebased build exposed missing forwarded API declarations: all six
201+
directory getters on the three UI Extensions targets, plus five internal
202+
directory labels on classic UWP. These exact additions are recorded in the
203+
unshipped baselines; no shipped API, forwarder or diagnostic was removed.
204+
The corrected 37-project shipping/fixture closure packs successfully on all
205+
declared TFMs with zero warnings and passes package content/metadata verification.
206+
207+
The same three metadata-provider regressions executed in a separately packed
208+
pre-fix worktree and failed at the intended identity/outcome assertion:
209+
`FoldedDeployment` and `UnfoldedIgnoredRow` were failed, not ignored, and the
210+
folded active row was lost. All three execute and pass with the fix, alongside
211+
23 controls: **26 passed, 0 failed, 0 skipped**, outer exit 0. The independent
212+
execution plan and fresh TRX were reconciled. The same five `TestContextTests`
213+
also pass on net48, net10.0, net11.0 and WinUI: **20 passed, 0 failed, 0 skipped**.
214+
215+
The real app-model preflight passed without changing Developer Mode or removing
216+
existing registrations. An additional three-row Modern UWP activation attempt
217+
was blocked before activation: the packaged app-model controller could not load
218+
`Microsoft.Testing.Extensions.CodeCoverage` 18.13.0.0 and produced no child TRX.
219+
All three outer rows failed; this is a launch/provenance gap, not regression
220+
sensitivity or proof of the failed-deployment exit. The attempted plain WinUI
221+
MSBuild wrapper probe also lacked the `InvokeTestingPlatform` import and is not
222+
credited as execution proof. The wrapper's exit mapping is established by the
223+
helper and `InvokeTestingPlatformTask` source, not by those setup failures.
224+
225+
### Test-value evidence for the review correction
226+
227+
The tested executable delta is based on
228+
`0cf6e3b3dd85faa223ddd321d989bb49716ad9bb`; its source/test/API patch SHA-256 is
229+
`A49183C031816E90BFF56BF0D26DDBB8D9ACC10A0C2B8DF7237BF8B64C7A9866`.
230+
The isolated comparison retains the selected WinUI assertions, with test patch
231+
`20C2EDCC5F29F6E22AA4C1D45B9E00FBDDB2A91E3C45733EB9D33F7A328914EA`
232+
and API-only build support patch
233+
`BFDFD170690A64A2D3B38EBC2301E2EC71D55FDE08B1F527A997AF506A566A10`,
234+
but keeps the original early deployment guard. Its three selected cases all
235+
execute and fail at the intended assertion, outer exit 2, with no skipped cases.
236+
The final-source three-case rerun passes, outer exit 0.
237+
238+
Both variants use SDK `12.0.100-alpha.1.26562.108`, desktop MSBuild from
239+
Visual Studio `18.13.12409.143`, Release packages, and separate generated consumer
240+
caches. Each of the three copied WinUI runtimes matches its own packed runtime:
241+
SHA-256 `0E61177155B3844288F980C8F5184F3FCD4E69E101A9D8F903E9AB1FB4FA1007`
242+
before the fix and
243+
`4A801AA246303C6F550AAC6D11FDC464927313C697353B4B8A841D625C544E0E`
244+
with it. The adapter/framework package version is `5.0.0-dev`, MTP is `3.0.0-dev`.
245+
246+
Commands executed from the respective worktree roots:
247+
248+
```powershell
249+
.\build.cmd -pack -c Release -msbuildEngine vs -projects artifacts\validation\pr12446-pack.slnf -bl
250+
.\build.cmd -c Release -msbuildEngine vs -projects artifacts\validation\pr12446-tests.slnf -bl
251+
.\.dotnet\dotnet.exe test --project test\IntegrationTests\MSTest.Acceptance.IntegrationTests\MSTest.Acceptance.IntegrationTests.csproj -c Release --no-build --filter "FullyQualifiedName~MSTest.Acceptance.IntegrationTests.WinUITests.|FullyQualifiedName~MSTest.Acceptance.IntegrationTests.CoreFrameworkAssemblyTests.|FullyQualifiedName~WindowsApplicationModelPackageTests.PackedMSTestTestFramework_DeploymentItemAvailability|FullyQualifiedName~IgnoreTests.WhenSpecificDataSourceIsIgnoredViaIgnoreMessageProperty" -p:UsingDotNetTest=true -p:ArtifactsTestResultsDir=artifacts\TestResults\Release\review-green -bl:artifacts\log\Release\review-green.binlog --show-test-results all
252+
.\.dotnet\dotnet.exe test --project test\IntegrationTests\MSTest.Acceptance.IntegrationTests\MSTest.Acceptance.IntegrationTests.csproj -c Release --no-build --filter "FullyQualifiedName~WinUITests.DeploymentItemsFailBeforeBodiesIncludingInheritedAttributes" -p:UsingDotNetTest=true -p:ArtifactsTestResultsDir=artifacts\TestResults\Release\review-final-regressions -bl:artifacts\log\Release\review-final-regressions.binlog --show-test-results all
253+
```
254+
255+
These four commands exit 0. The pack filter includes the eight package-shape
256+
owners, the pack-time global-config generator, and all acceptance fixture package
257+
owners with their source dependencies (37 projects); the test filter includes
258+
the acceptance and framework-unit owners. The comparison uses the same pack
259+
filter, builds the acceptance project, and runs the same three-case selector
260+
into `review-red` instead of `review-final-regressions` (exit 2).
261+
The four framework unit hosts use
262+
`--treenode-filter "/*/*/TestContextTests/*"` with distinct TRX files; each exits 0.
263+
No historical CI result is credited for the rebased head.
264+
169265
## Delivery boundary
170266

171267
This layer targets main only. The series coordinator owns the subsequent package

‎src/Adapter/MSTestAdapter.PlatformServices/Execution/TestMethodRunner.Execution.cs‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

44
using Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Helpers;
5+
#if (WINDOWS_UWP || WIN_UI) && NET
6+
using Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.ObjectModel;
7+
#endif
58
using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices;
69
using Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.Interface;
710
using Microsoft.VisualStudio.TestTools.UnitTesting;
@@ -15,6 +18,24 @@ internal sealed partial class TestMethodRunner
1518
{
1619
private async Task<TestResult[]> ExecuteTestAsync(ITestContext executionContext, TestMethodInfo testMethodInfo)
1720
{
21+
#if (WINDOWS_UWP || WIN_UI) && NET
22+
IReflectionOperations reflection = PlatformServiceProvider.Instance.ReflectionOperations;
23+
if (reflection.IsAttributeDefined<DeploymentItemAttribute>(testMethodInfo.MethodInfo)
24+
|| reflection.IsAttributeDefined<DeploymentItemAttribute>(testMethodInfo.Parent.ClassType))
25+
{
26+
executionContext.SetOutcome(UnitTestOutcome.Failed);
27+
return
28+
[
29+
new TestResult
30+
{
31+
Outcome = UnitTestOutcome.Failed,
32+
DisplayName = _test.DisplayName,
33+
TestFailureException = new TestFailedException(UnitTestOutcome.Failed, Resource.DeploymentItemNotSupportedForUi),
34+
},
35+
];
36+
}
37+
#endif
38+
1839
TestResult[] results;
1940
try
2041
{

‎src/Adapter/MSTestAdapter.PlatformServices/Execution/TestMethodRunner.cs‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -314,24 +314,6 @@ internal async Task<TestResult[]> RunTestMethodAsync()
314314
throw ApplicationStateGuard.Unreachable();
315315
}
316316

317-
#if (WINDOWS_UWP || WIN_UI) && NET
318-
IReflectionOperations reflection = PlatformServiceProvider.Instance.ReflectionOperations;
319-
if (reflection.IsAttributeDefined<DeploymentItemAttribute>(_testMethodInfo.MethodInfo)
320-
|| reflection.IsAttributeDefined<DeploymentItemAttribute>(_testMethodInfo.Parent.ClassType))
321-
{
322-
_testContext.SetOutcome(UnitTestOutcome.Failed);
323-
return
324-
[
325-
new TestResult
326-
{
327-
Outcome = UnitTestOutcome.Failed,
328-
DisplayName = _test.DisplayName,
329-
TestFailureException = new TestFailedException(UnitTestOutcome.Failed, Resource.DeploymentItemNotSupportedForUi),
330-
},
331-
];
332-
}
333-
#endif
334-
335317
// Fast path for non-data-driven tests (the common case).
336318
// A single attribute scan replaces the two scans done by TryExecuteDataSourceBasedTestsAsync and
337319
// TryExecuteFoldedDataDrivenTestsAsync, and avoids allocating a List<TestResult> that would

‎src/TestFramework/TestFramework.Extensions/InternalAPI/uap10.0.16299/InternalAPI.Unshipped.txt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,10 @@
33
[MSTESTEXP]static Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.Current.set -> void (forwarded, contained in MSTest.TestFramework)
44
[MSTESTEXP]static Microsoft.VisualStudio.TestTools.UnitTesting.TestRun.SetCurrent(Microsoft.VisualStudio.TestTools.UnitTesting.ITestRunInfo? info) -> void (forwarded, contained in MSTest.TestFramework)
55
Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestRunCount.set -> void (forwarded, contained in MSTest.TestFramework)
6+
static readonly Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.DeploymentDirectoryLabel -> string! (forwarded, contained in MSTest.TestFramework)
67
static readonly Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.FullyQualifiedTestClassNameLabel -> string! (forwarded, contained in MSTest.TestFramework)
8+
static readonly Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.ResultsDirectoryLabel -> string! (forwarded, contained in MSTest.TestFramework)
79
static readonly Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestNameLabel -> string! (forwarded, contained in MSTest.TestFramework)
10+
static readonly Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestResultsDirectoryLabel -> string! (forwarded, contained in MSTest.TestFramework)
11+
static readonly Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestRunDirectoryLabel -> string! (forwarded, contained in MSTest.TestFramework)
12+
static readonly Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestRunResultsDirectoryLabel -> string! (forwarded, contained in MSTest.TestFramework)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
11
#nullable enable
2+
virtual Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.DeploymentDirectory.get -> string? (forwarded, contained in MSTest.TestFramework)
3+
virtual Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.ResultsDirectory.get -> string? (forwarded, contained in MSTest.TestFramework)
4+
virtual Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestResultsDirectory.get -> string? (forwarded, contained in MSTest.TestFramework)
5+
virtual Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestRunDirectory.get -> string? (forwarded, contained in MSTest.TestFramework)
6+
virtual Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestRunResultsDirectory.get -> string? (forwarded, contained in MSTest.TestFramework)
7+
virtual Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestTempDirectory.get -> string? (forwarded, contained in MSTest.TestFramework)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
11
#nullable enable
2+
virtual Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.DeploymentDirectory.get -> string? (forwarded, contained in MSTest.TestFramework)
3+
virtual Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.ResultsDirectory.get -> string? (forwarded, contained in MSTest.TestFramework)
4+
virtual Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestResultsDirectory.get -> string? (forwarded, contained in MSTest.TestFramework)
5+
virtual Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestRunDirectory.get -> string? (forwarded, contained in MSTest.TestFramework)
6+
virtual Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestRunResultsDirectory.get -> string? (forwarded, contained in MSTest.TestFramework)
7+
virtual Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestTempDirectory.get -> string? (forwarded, contained in MSTest.TestFramework)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
11
#nullable enable
2+
virtual Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.DeploymentDirectory.get -> string? (forwarded, contained in MSTest.TestFramework)
3+
virtual Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.ResultsDirectory.get -> string? (forwarded, contained in MSTest.TestFramework)
4+
virtual Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestResultsDirectory.get -> string? (forwarded, contained in MSTest.TestFramework)
5+
virtual Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestRunDirectory.get -> string? (forwarded, contained in MSTest.TestFramework)
6+
virtual Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestRunResultsDirectory.get -> string? (forwarded, contained in MSTest.TestFramework)
7+
virtual Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestTempDirectory.get -> string? (forwarded, contained in MSTest.TestFramework)

‎test/IntegrationTests/MSTest.Acceptance.IntegrationTests/ModernUwpTests.cs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,10 @@ await WindowsApplicationModelTestTools.ExecuteWithPackageCleanupAsync(
136136
packageIdentityName,
137137
TestContext.CancellationToken);
138138

139+
// InvokeTestingPlatform maps the host's failed-test exit (2) to an MSBuild failure (1).
140+
const int msbuildFailureExitCode = 1;
139141
Assert.AreEqual(
140-
unsupportedDeployment ? 1 : 0,
142+
unsupportedDeployment ? msbuildFailureExitCode : 0,
141143
run.ExitCode,
142144
$"MTP failed to execute the real Modern UWP project '{build.ProjectPath}'. TRX: '{run.TrxPath}'. " +
143145
$"Binlog: '{build.BinlogPath}'.{Environment.NewLine}Standard output:{Environment.NewLine}{run.StandardOutput}" +

‎test/IntegrationTests/MSTest.Acceptance.IntegrationTests/WinUITests.cs‎

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,22 @@ public async Task DeploymentItemsFailBeforeBodiesIncludingInheritedAttributes(st
6464
"--report-trx --report-trx-filename deployment.trx",
6565
cancellationToken: TestContext.CancellationToken);
6666
result.AssertExitCodeIs(ExitCode.AtLeastOneTestFailed);
67-
result.AssertOutputContainsSummary(failed: 4, passed: 1, skipped: 0);
6867
string reportPath = Assert.ContainsSingle(Directory.GetFiles(asset.TargetAssetPath, "deployment.trx", SearchOption.AllDirectories));
6968
XNamespace ns = "http://microsoft.com/schemas/VisualStudio/TeamTest/2010";
7069
var report = XDocument.Load(reportPath);
7170
XElement[] results = [.. report.Descendants(ns + "UnitTestResult")];
7271
Assert.AreSequenceEqual(
73-
["ClassDeployment:Failed", "InheritedClassDeployment:Failed", "InheritedMethodDeployment:Failed", "MetadataProviderIsSelected:Passed", "MethodDeployment:Failed"],
72+
[
73+
"ClassDeployment:Failed",
74+
"FoldedActiveRow:Failed",
75+
"FoldedDeployment:NotExecuted",
76+
"InheritedClassDeployment:Failed",
77+
"InheritedMethodDeployment:Failed",
78+
"MetadataProviderIsSelected:Passed",
79+
"MethodDeployment:Failed",
80+
"UnfoldedActiveRow:Failed",
81+
"UnfoldedIgnoredRow:NotExecuted",
82+
],
7483
results.Select(test => $"{test.Attribute("testName")!.Value}:{test.Attribute("outcome")!.Value}").Order(StringComparer.Ordinal));
7584
foreach (XElement failed in results.Where(test => (string?)test.Attribute("outcome") == "Failed"))
7685
{
@@ -80,6 +89,13 @@ public async Task DeploymentItemsFailBeforeBodiesIncludingInheritedAttributes(st
8089
Assert.DoesNotContain("DEPLOYMENT_BODY_EXECUTED", failed.Value);
8190
}
8291

92+
foreach (XElement ignored in results.Where(test => (string?)test.Attribute("outcome") == "NotExecuted"))
93+
{
94+
Assert.AreEqual("disabled", ignored.Descendants(ns + "Message").Single().Value);
95+
Assert.DoesNotContain("DEPLOYMENT_BODY_EXECUTED", ignored.Value);
96+
}
97+
98+
result.AssertOutputContainsSummary(failed: 6, passed: 1, skipped: 2);
8399
TestContext.WriteLine($"Packed WinUI deployment guard: {sourceGenMode}; TRX: {reportPath}");
84100
}
85101

@@ -179,6 +195,12 @@ public sealed class MethodDeploymentTests
179195
[DeploymentItem("not-deployed.txt")]
180196
public void MethodDeployment() => Assert.Fail("DEPLOYMENT_BODY_EXECUTED");
181197
198+
[TestMethod(UnfoldingStrategy = TestDataSourceUnfoldingStrategy.Fold)]
199+
[DeploymentItem("not-deployed.txt")]
200+
[DataRow(1, IgnoreMessage = "disabled")]
201+
[DataRow(2, DisplayName = "FoldedActiveRow")]
202+
public void FoldedDeployment(int value) => Assert.Fail("DEPLOYMENT_BODY_EXECUTED");
203+
182204
[TestMethod]
183205
public void MetadataProviderIsSelected()
184206
{
@@ -196,6 +218,11 @@ public sealed class ClassDeploymentTests
196218
{
197219
[TestMethod]
198220
public void ClassDeployment() => Assert.Fail("DEPLOYMENT_BODY_EXECUTED");
221+
222+
[TestMethod(UnfoldingStrategy = TestDataSourceUnfoldingStrategy.Unfold)]
223+
[DataRow(1, IgnoreMessage = "disabled", DisplayName = "UnfoldedIgnoredRow")]
224+
[DataRow(2, DisplayName = "UnfoldedActiveRow")]
225+
public void UnfoldedDeployment(int value) => Assert.Fail("DEPLOYMENT_BODY_EXECUTED");
199226
}
200227
201228
public abstract class MethodDeploymentBase

0 commit comments

Comments
 (0)