Skip to content

Commit 95cc5b1

Browse files
[Internal] Tests: Adds MSTest v3.7.3 upgrade from v1.x (#5743)
## Changes Upgrades MSTest from v1.x to v3.7.3 across core test projects, matching the FaultInjection project which already uses v3.7.3. ### Package upgrades | Project | MSTest Before | MSTest After | Test SDK Before | Test SDK After | |---|---|---|---|---| | \Microsoft.Azure.Cosmos.Tests\ | 1.2.0 | **3.7.3** | 16.2.0 | **17.12.0** | | \Microsoft.Azure.Cosmos.EmulatorTests\ | 1.3.2 | **3.7.3** | 16.2.0 | **17.12.0** | | \Microsoft.Azure.Cosmos.Performance.Tests\ | 1.2.0 | **3.7.3** | N/A | N/A | ### Class-level test parallelization Added \[assembly: Parallelize(Scope = ExecutionScope.ClassLevel)]\ to unit tests for intra-process parallelism (12 workers on CI agents). ### MSTest v3 analyzer/API fixes - **MSTEST0002** (4): Removed \[TestClass]\ from private nested \Implementation\ classes — tests discovered via public outer wrapper classes - **MSTEST0003** (8): Removed \[TestMethod]\ from abstract base class parameterized methods — invoked by outer class wrappers with \[DataRow]\ - **MSTEST0014** (2): Added missing \[TestMethod]\ to \TriggersTests.ValidatePreTriggerTest\ and \CosmosItemIntegrationTests.ExecuteTransactionalBatch_WhenBinaryEncodingEnabled_ShouldCompleteSuccessfully\ — these had \[DataRow]\ but no \[TestMethod]\, so were not being discovered/run - **CS0411/CS1503** (3): Fixed \Assert.AreNotEqual\ type inference (Guid→string, int→TimeSpan, Uri→string) ### Custom RetriableTestClass (preserved) The emulator tests' custom \TestClassAttribute\ providing automatic retry is preserved — it's fully compatible with v3. MSTest v3's \[Retry]\ is method-level only and cannot replicate assembly-wide retry without touching hundreds of methods. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent fbd7d28 commit 95cc5b1

15 files changed

Lines changed: 19 additions & 28 deletions

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosItemIntegrationTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ public async Task AddressRefreshTimeoutTest()
381381
}
382382
}
383383

384+
[TestMethod]
384385
[Owner("dkunda")]
385386
[TestCategory("MultiRegion")]
386387
[DataRow(true, DisplayName = "Test scenario when binary encoding is enabled at client level.")]
@@ -2243,7 +2244,7 @@ public async Task ClinetOverrides0msRequestTimeoutValueForPPAF()
22432244

22442245
CrossRegionHedgingAvailabilityStrategy strat = cosmosClient.DocumentClient.ConnectionPolicy.AvailabilityStrategy as CrossRegionHedgingAvailabilityStrategy;
22452246
Assert.IsNotNull(strat);
2246-
Assert.AreNotEqual(0, strat.Threshold);
2247+
Assert.AreNotEqual(TimeSpan.Zero, strat.Threshold);
22472248
}
22482249

22492250

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/CosmosItemTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2390,7 +2390,7 @@ public async Task ItemRequestOptionAccessConditionTest(bool binaryEncodingEnable
23902390
Assert.IsNotNull(responseMessage);
23912391
Assert.IsNull(responseMessage.Content);
23922392
Assert.AreEqual(HttpStatusCode.PreconditionFailed, responseMessage.StatusCode, responseMessage.ErrorMessage);
2393-
Assert.AreNotEqual(responseMessage.Headers.ActivityId, Guid.Empty);
2393+
Assert.AreNotEqual(Guid.Empty.ToString(), responseMessage.Headers.ActivityId);
23942394
Assert.IsTrue(responseMessage.Headers.RequestCharge > 0);
23952395
Assert.IsFalse(string.IsNullOrEmpty(responseMessage.ErrorMessage));
23962396
Assert.IsTrue(responseMessage.ErrorMessage.Contains("One of the specified pre-condition is not met"));
@@ -2407,7 +2407,7 @@ public async Task ItemRequestOptionAccessConditionTest(bool binaryEncodingEnable
24072407
{
24082408
Assert.IsNotNull(e);
24092409
Assert.AreEqual(HttpStatusCode.PreconditionFailed, e.StatusCode, e.Message);
2410-
Assert.AreNotEqual(e.ActivityId, Guid.Empty);
2410+
Assert.AreNotEqual(Guid.Empty.ToString(), e.ActivityId);
24112411
Assert.IsTrue(e.RequestCharge > 0);
24122412
string expectedResponseBody = $"{Environment.NewLine}Errors : [{Environment.NewLine} \"One of the specified pre-condition is not met. Learn more: https://aka.ms/CosmosDB/sql/errors/precondition-failed\"{Environment.NewLine}]{Environment.NewLine}";
24132413
Assert.AreEqual(expectedResponseBody, e.ResponseBody);

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Fluent/ContainerSettingsTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ await databaseForConflicts.DefineContainer(containerName, partitionKeyPath)
497497
containerSettings = containerResponse.Resource;
498498
Assert.IsNotNull(containerSettings.ConflictResolutionPolicy);
499499
Assert.AreEqual(ConflictResolutionMode.Custom, containerSettings.ConflictResolutionPolicy.Mode);
500-
Assert.AreEqual(UriFactory.CreateStoredProcedureUri(databaseForConflicts.Id, containerName, sprocName), containerSettings.ConflictResolutionPolicy.ResolutionProcedure);
500+
Assert.AreEqual(UriFactory.CreateStoredProcedureUri(databaseForConflicts.Id, containerName, sprocName).ToString(), containerSettings.ConflictResolutionPolicy.ResolutionProcedure);
501501
Assert.IsTrue(string.IsNullOrEmpty(containerSettings.ConflictResolutionPolicy.ResolutionPath));
502502
}
503503
finally

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/Microsoft.Azure.Cosmos.EmulatorTests.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@
6262
<PackageReference Include="System.Security.SecureString" Version="4.3.0" />
6363
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.0" />
6464
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="2.1.0" />
65-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
65+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
6666
<PackageReference Include="Moq" Version="4.8.2" />
67-
<PackageReference Include="MSTest.TestAdapter" Version="1.3.2" />
68-
<PackageReference Include="MSTest.TestFramework" Version="1.3.2" />
67+
<PackageReference Include="MSTest.TestAdapter" Version="3.7.3" />
68+
<PackageReference Include="MSTest.TestFramework" Version="3.7.3" />
6969
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
7070
<PackageReference Include="System.Reflection" Version="4.3.0" />
7171
</ItemGroup>

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.EmulatorTests/TriggersTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ await this.scripts.CreateTriggerStreamAsync(
153153
}
154154

155155

156+
[TestMethod]
156157
[DataRow(TriggerOperation.Create, false, DisplayName = "TriggerOperation - Create with Binary encoding disabled.")]
157158
[DataRow(TriggerOperation.Create, true, DisplayName = "TriggerOperation - Create with Binary encoding enabled.")]
158159
[DataRow(TriggerOperation.Upsert, false, DisplayName = "TriggerOperation - Upsert with Binary encoding disabled.")]

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Performance.Tests/Microsoft.Azure.Cosmos.Performance.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="9.0.0" />
2222
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.0.0" />
2323
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" />
24-
<PackageReference Include="MSTest.TestFramework" Version="1.2.0" />
24+
<PackageReference Include="MSTest.TestFramework" Version="3.7.3" />
2525
<PackageReference Include="Moq" Version="4.13.1" />
2626
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
2727
<PackageReference Include="OpenTelemetry" Version="1.10.0" />
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// ------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All rights reserved.
3+
// ------------------------------------------------------------

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Microsoft.Azure.Cosmos.Tests.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@
5454
<PackageReference Include="FluentAssertions" Version="5.10.3" />
5555
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.1.1" />
5656
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.7.1" />
57-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
57+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
5858
<PackageReference Include="Moq" Version="4.8.3" />
59-
<PackageReference Include="MSTest.TestAdapter" Version="1.2.0" />
60-
<PackageReference Include="MSTest.TestFramework" Version="1.2.0" />
59+
<PackageReference Include="MSTest.TestAdapter" Version="3.7.3" />
60+
<PackageReference Include="MSTest.TestFramework" Version="3.7.3" />
6161
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
6262
<PackageReference Include="coverlet.msbuild" Version="2.8.1">
6363
<PrivateAssets>all</PrivateAssets>

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Pagination/BufferedPartitionRangeEnumeratorTests.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ public async Task TestMoveNextAndBufferPageAsync(bool aggressivePrefetch, bool e
9595
await implementation.TestMoveNextAndBufferPageAsync(aggressivePrefetch, exercisePrefetch);
9696
}
9797

98-
[TestClass]
9998
private sealed class Implementation : PartitionRangeEnumeratorTests<ReadFeedPage, ReadFeedState>
10099
{
101100
private const int Iterations = 1;
@@ -105,7 +104,6 @@ public Implementation()
105104
{
106105
}
107106

108-
[TestMethod]
109107
public async Task TestSplitAsync(bool aggressivePrefetch, bool exercisePrefetch)
110108
{
111109
int numItems = 100;
@@ -143,7 +141,6 @@ public async Task TestSplitAsync(bool aggressivePrefetch, bool exercisePrefetch)
143141
Assert.AreEqual(numItems, parentIdentifiers.Count + childIdentifiers.Count);
144142
}
145143

146-
[TestMethod]
147144
public async Task TestBufferPageAsync(bool aggressivePrefetch, bool exercisePrefetch)
148145
{
149146
int numItems = 100;

Microsoft.Azure.Cosmos/tests/Microsoft.Azure.Cosmos.Tests/Pagination/DocumentContainerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ public async Task TestCrudAsync()
254254
CosmosObject item = CosmosObject.Parse("{\"pk\" : 42 }");
255255
Record record = await documentContainer.CreateItemAsync(item, cancellationToken: default);
256256
Assert.IsNotNull(record);
257-
Assert.AreNotEqual(Guid.Empty, record.Identifier);
257+
Assert.AreNotEqual(Guid.Empty.ToString(), record.Identifier);
258258

259259
// Try to read it back
260260
Record readRecord = await documentContainer.ReadItemAsync(

0 commit comments

Comments
 (0)