Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion docs/core/testing/unit-testing-mstest-migration-v3-v4.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: MSTest migration from v3 to v4
description: Learn about migrating to MSTest v4.
author: Youssef1313
ms.author: ygerges
ms.date: 07/22/2025
ms.date: 12/11/2025
---

# Migrate from MSTest v3 to v4
Expand Down Expand Up @@ -99,6 +99,20 @@ public static void ClassCleanup(TestContext testContext)

Previously, `TestContext.Properties` was an `IDictionary`. To provide better typing, it's now `IDictionary<string, object>`.

#### Accessing non-existing property
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The heading uses a gerund "Accessing", which should be avoided in titles. Consider changing this to a noun-based heading such as "Access to non-existing properties" or "Non-existing property access".

Copilot generated this review using guidance from repository custom instructions.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback


Accessing a non-existing property in the dictionary will now throw `KeyNotFoundException` rather than returning null.
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider simplifying this sentence to be more conversational and concise. Instead of "Accessing a non-existing property in the dictionary will now throw", consider "Accessing a non-existent property in the dictionary now throws" (using present tense instead of future tense with "will", and "non-existent" is the more common spelling).

Copilot generated this review using guidance from repository custom instructions.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback


```csharp
// in MSTest 3.x
var value = TestContext.Properties["NonExistent"]; // Returns null

// in MSTest 4.x
var value = TestContext.Properties["NonExistent"]; // Throws KeyNotFoundException
```

To check for existence of a property, use `TryGetValue` or `ContainsKey` methods.
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider simplifying this sentence to be more direct and conversational. Instead of "To check for existence of a property", consider "To check if a property exists" for clearer, more natural phrasing.

Copilot generated this review using guidance from repository custom instructions.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback


If you have calls to `TestContext.Properties.Contains`, update them to `TestContext.Properties.ContainsKey`.

### TestTimeout enum is removed
Expand Down
Loading