Skip to content

Commit a61e785

Browse files
EvangelinkCopilot
andauthored
Update public samples for MSTest 4.4.1 (#11332)
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent d03b4b4 commit a61e785

11 files changed

Lines changed: 27 additions & 36 deletions

File tree

‎samples/public/DemoMSTestSdk/ProjectUsingAspire/global.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
"runner": "Microsoft.Testing.Platform"
44
},
55
"msbuild-sdks": {
6-
"MSTest.Sdk": "4.4.0"
6+
"MSTest.Sdk": "4.4.1"
77
}
88
}

‎samples/public/DemoMSTestSdk/ProjectUsingMSTestRunner/global.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
"runner": "Microsoft.Testing.Platform"
44
},
55
"msbuild-sdks": {
6-
"MSTest.Sdk": "4.4.0"
6+
"MSTest.Sdk": "4.4.1"
77
}
88
}

‎samples/public/DemoMSTestSdk/ProjectUsingPlaywright/global.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
"runner": "Microsoft.Testing.Platform"
44
},
55
"msbuild-sdks": {
6-
"MSTest.Sdk": "4.4.0"
6+
"MSTest.Sdk": "4.4.1"
77
}
88
}

‎samples/public/DemoMSTestSdk/ProjectUsingVSTest/global.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
"runner": "VSTest"
44
},
55
"msbuild-sdks": {
6-
"MSTest.Sdk": "4.4.0"
6+
"MSTest.Sdk": "4.4.1"
77
}
88
}

‎samples/public/DemoMSTestSdk/ProjectWithNativeAOT/global.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
"runner": "Microsoft.Testing.Platform"
44
},
55
"msbuild-sdks": {
6-
"MSTest.Sdk": "4.4.0"
6+
"MSTest.Sdk": "4.4.1"
77
}
88
}

‎samples/public/Directory.Build.props‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
<PropertyGroup>
44
<AspireTestingVersion>13.4.6</AspireTestingVersion>
5-
<CodeCoverageVersion>18.9.0</CodeCoverageVersion>
6-
<MSTestVersion>4.3.2</MSTestVersion>
5+
<CodeCoverageVersion>18.11.0</CodeCoverageVersion>
6+
<MSTestVersion>4.4.1</MSTestVersion>
77
<!--
88
MSTestAOTVersion pins the compatible experimental MSTest.Engine and MSTest.SourceGeneration
99
pair used by the non-SDK Native AOT runner sample (mstest-runner/NativeAotRunner).
@@ -16,14 +16,14 @@
1616
<MSTestEngineVersion>$(MSTestAOTVersion)</MSTestEngineVersion>
1717
<MSTestSdkAOTVersion>2.0.0-alpha.26358.12</MSTestSdkAOTVersion>
1818
<PlaywrightVersion>1.61.0</PlaywrightVersion>
19-
<TestingPlatformVersion>2.3.2</TestingPlatformVersion>
19+
<TestingPlatformVersion>2.4.1</TestingPlatformVersion>
2020
<!--
2121
Microsoft.Testing.Extensions.PackagedApp deploys and launches a packaged Windows (UWP/WinUI)
2222
test host. The latest published package predates its alignment with the testing platform version,
2323
so this sample pins that package separately.
2424
-->
2525
<MicrosoftTestingExtensionsPackagedAppVersion>1.0.0-alpha.26363.8</MicrosoftTestingExtensionsPackagedAppVersion>
26-
<VSTestVersion>18.8.0</VSTestVersion>
26+
<VSTestVersion>18.9.0</VSTestVersion>
2727
<GenerateDocumentationFile>false</GenerateDocumentationFile>
2828
<NoWarn>$(NoWarn);SA0001;EnableGenerateDocumentationFile</NoWarn>
2929
</PropertyGroup>

‎samples/public/ReliableTestSuite/EnvironmentPricingTests.cs‎

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,15 @@ namespace ReliableTestSuite;
1212
/// share state with every other test in the process. Left unguarded under method-level
1313
/// parallelization, one test's write would race another's read - the classic flaky failure.
1414
///
15-
/// WITH THIS SAMPLE'S PINNED MSTest 4.3 PACKAGES: the blunt-but-correct tool is
16-
/// [DoNotParallelize]. It guarantees the class runs with nothing else, but it is all-or-nothing:
17-
/// the class is serialized against the ENTIRE suite and deferred to the end of the run, even
18-
/// against tests that never touch the environment.
15+
/// THIS SAMPLE USES [DoNotParallelize] to show the blunt-but-correct tool. It guarantees the class
16+
/// runs with nothing else, but it is all-or-nothing: the class is serialized against the ENTIRE
17+
/// suite and deferred to the end of the run, even against tests that never touch the environment.
1918
///
20-
/// AVAILABLE AFTER UPGRADING THE FRAMEWORK PACKAGES TO MSTest 4.4: the precise tool is
21-
/// [ResourceLock]. It names the exact resource that is shared, so the scheduler serializes only
22-
/// tests that declare the SAME key and lets everything else run concurrently. The full migration
23-
/// is a one-for-one swap - you REMOVE [DoNotParallelize] and ADD [ResourceLock] (keeping both
24-
/// would just re-serialize the class):
19+
/// ALSO AVAILABLE IN MSTest 4.4: [ResourceLock] is the precise tool for this shared state. It names
20+
/// the exact resource that is shared, so the scheduler serializes only tests that declare the SAME
21+
/// key and lets everything else run concurrently. The migration is a one-for-one swap - REMOVE
22+
/// [DoNotParallelize] and ADD [ResourceLock] (keeping both would just re-serialize the class):
2523
///
26-
/// // [compiles once MSTestVersion in ../Directory.Build.props is 4.4 or later]
2724
/// [TestClass]
2825
/// [ResourceLock(WellKnownResources.EnvironmentVariables)] // exclusive by default
2926
/// public sealed class EnvironmentPricingTests { ... }

‎samples/public/ReliableTestSuite/FlakyDependencyTests.cs‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ namespace ReliableTestSuite;
1515
///
1616
/// Use it deliberately and visibly, never as the default. On MSTest 4.4+ under
1717
/// Microsoft.Testing.Platform each attempt is reported, so a retried test surfaces as "flaky"
18-
/// rather than a clean green - that visibility is the point. (On 4.3.x a retried-then-passed
19-
/// test reports as an ordinary pass, so the retry is easier to forget it is there.) If you find
20-
/// yourself adding [Retry] to hide a race in your OWN code, stop and fix the race; the earlier
21-
/// steps are how.
18+
/// rather than a clean green - that visibility is the point. If you find yourself adding [Retry]
19+
/// to hide a race in your OWN code, stop and fix the race; the earlier steps are how.
2220
///
2321
/// (Also distinct from the Microsoft.Testing.Extensions.Retry orchestrator's
2422
/// --retry-failed-tests, which re-runs failed tests in a fresh host process. If you combine

‎samples/public/ReliableTestSuite/README.md‎

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ shared-state bugs. Each file then demonstrates one rung of the reliability ladde
99

1010
| File | Technique | Why it matters |
1111
| --- | --- | --- |
12-
| `OrderExportTests.cs` | **Eliminate** — per-test unique temp directory | No shared resource ⇒ no lock needed ⇒ full parallelism. The cheapest concurrency bug is the one that cannot exist. (After the framework package pin moves to MSTest 4.4, `TestContext.TestTempDirectory` can manage this for you.) |
13-
| `EnvironmentPricingTests.cs` | **Coordinate** — `[DoNotParallelize]` with the pinned MSTest 4.3 packages, `[ResourceLock(WellKnownResources.EnvironmentVariables)]` after upgrading them to 4.4 | Genuinely process-global state must be serialized. `[ResourceLock]` serializes *only* the tests that share the named resource, not the whole suite. |
12+
| `OrderExportTests.cs` | **Eliminate** — per-test unique temp directory | No shared resource ⇒ no lock needed ⇒ full parallelism. The cheapest concurrency bug is the one that cannot exist. (With MSTest 4.4.1, `TestContext.TestTempDirectory` can manage this for you.) |
13+
| `EnvironmentPricingTests.cs` | **Coordinate** — `[DoNotParallelize]`, with `[ResourceLock(WellKnownResources.EnvironmentVariables)]` as the precise alternative | Genuinely process-global state must be serialized. `[ResourceLock]` serializes *only* the tests that share the named resource, not the whole suite. |
1414
| `PlatformSpecificTests.cs` | **Gate** — `[OSCondition]`, `[CICondition]`, `[ExecutableCondition]` | A test that silently early-returns on the wrong OS reports a false pass. Conditions report *not run* for the right reason. |
1515
| `CancellableWorkTests.cs` | **Bound time** — `[Timeout(CooperativeCancellation = true)]` + `TestContext.CancellationToken` | A test that can hang has no place in a reliable suite; cooperative cancellation stops the work cleanly. No `Thread.Sleep`. |
1616
| `FlakyDependencyTests.cs` | **Contain** — `[Retry]` | Retry makes a nondeterministic test pass more often; it does **not** make it deterministic. Last resort for residual, external flakiness only. |
@@ -27,13 +27,9 @@ resource locks, and only then contain whatever residual nondeterminism you could
2727
## `[ResourceLock]` note
2828

2929
`[ResourceLock]` and `WellKnownResources` ship in the **MSTest 4.4 framework packages**. This sample
30-
uses `MSTest.Sdk` **4.4.0** from `../global.json`, but `../Directory.Build.props` independently pins
31-
the MSTest framework and adapter packages to **4.3.2** through `MSTestVersion`. The available APIs
32-
therefore remain those from MSTest 4.3. The sample demonstrates the coordination step with
33-
`[DoNotParallelize]` and shows the exact `[ResourceLock]` upgrade in the comments of
34-
`EnvironmentPricingTests.cs`. Once `MSTestVersion` moves to 4.4 or later, the migration is a
35-
one-for-one swap: **remove** `[DoNotParallelize]` and **add** `[ResourceLock(...)]` (keeping both
36-
would just re-serialize the class).
30+
uses `MSTest.Sdk` and framework packages **4.4.1**. `EnvironmentPricingTests.cs` deliberately keeps
31+
`[DoNotParallelize]` to demonstrate blanket serialization and shows `[ResourceLock]` as the precise
32+
alternative in its comments. Switching between them is a one-for-one attribute replacement.
3733

3834
`[ResourceLock]` limitations worth stating up front:
3935

@@ -56,8 +52,8 @@ would just re-serialize the class).
5652
same seed. To reproduce a race deterministically, reduce parallelism (or serialize the suspects)
5753
first, then use the seed to pin the order. In CI you should **rotate the seed** (or leave it unset)
5854
so runs keep exploring new orderings instead of freezing on one.
59-
- With the framework packages pinned to **MSTest 4.3.x**, a retried-then-passed test reports as an
60-
ordinary pass. After `MSTestVersion` moves to **4.4+**, it surfaces as *flaky* instead.
55+
- With the framework packages pinned to **MSTest 4.4.1**, a retried-then-passed test surfaces as
56+
*flaky* instead of reporting as an ordinary pass.
6157

6258
## Run it
6359

‎samples/public/global.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
"runner": "Microsoft.Testing.Platform"
44
},
55
"msbuild-sdks": {
6-
"MSTest.Sdk": "4.4.0"
6+
"MSTest.Sdk": "4.4.1"
77
}
88
}

0 commit comments

Comments
 (0)