Skip to content

Conversation

@nohwnd
Copy link
Member

@nohwnd nohwnd commented Dec 11, 2025

Updated the date for MSTest v4 migration and added information about accessing non-existing properties in TestContext.Properties.

Related microsoft/testfx#6952


Internal previews

📄 File 🔗 Preview link
docs/core/testing/unit-testing-mstest-migration-v3-v4.md docs/core/testing/unit-testing-mstest-migration-v3-v4

Updated the date for MSTest v4 migration and added information about accessing non-existing properties in TestContext.Properties.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the MSTest v4 migration documentation to reflect the current date and adds important information about a breaking change in how TestContext.Properties handles non-existent properties. The update addresses a behavioral change where accessing a non-existent property now throws KeyNotFoundException instead of returning null.

Key changes:

  • Updated the document date from 07/22/2025 to 12/11/2025
  • Added new subsection documenting the breaking change for accessing non-existent properties in TestContext.Properties
  • Included code examples showing the behavior difference between MSTest 3.x and 4.x


#### Accessing non-existing property

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

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


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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community-contribution Indicates PR is created by someone from the .NET community. dotnet-fundamentals/svc

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant