Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more links to MSTest api docs #44716

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Evangelink
Copy link
Member

@Evangelink Evangelink commented Feb 7, 2025

@BillWagner BillWagner requested a review from gewarren February 7, 2025 15:15
@BillWagner
Copy link
Member

Adding @gewarren

Do you know why the xrefs are generating warnings here?

@gewarren
Copy link
Contributor

gewarren commented Feb 7, 2025

BTW, we have an extension for VS Code that inserts xrefs links. Do you know about it? It's a very helpful tool. https://github.com/IEvangelist/xref-helper/blob/main/README.md

@Evangelink
Copy link
Member Author

BTW, we have an extension for VS Code that inserts xrefs links. Do you know about it? It's a very helpful tool. IEvangelist/xref-helper@main/README.md

I wasn't aware of it!

@@ -81,4 +81,4 @@ The <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.AddResultFile

:::code language="csharp" source="snippets/testcontext/csharp/AddResultFile.cs":::

You can also use `TestContext.Write` or `TestContext.WriteLine` methods to write custom messages directly to the test output. This is especially useful for debugging purposes, as it provides real-time logging information within your test execution context.
You can also use <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.Write> or <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.WriteLine> methods to write custom messages directly to the test output. This is especially useful for debugging purposes, as it provides real-time logging information within your test execution context.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
You can also use <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.Write> or <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.WriteLine> methods to write custom messages directly to the test output. This is especially useful for debugging purposes, as it provides real-time logging information within your test execution context.
You can also use <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.Write*> or <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.WriteLine*> methods to write custom messages directly to the test output. This is especially useful for debugging purposes, as it provides real-time logging information within your test execution context.

Copy link
Contributor

@gewarren gewarren left a comment

Choose a reason for hiding this comment

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

I left some comments - but these are only suggestions that you can decide for yourself about.

@@ -29,7 +29,7 @@ Every test class must have the `TestClass` attribute, and every test method must

### `TestClassAttribute`

The [TestClass](<xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute>) attribute marks a class that contains tests and, optionally, initialize or cleanup methods.
The <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestClassAttribute> attribute marks a class that contains tests and, optionally, initialize or cleanup methods.
Copy link
Contributor

Choose a reason for hiding this comment

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

I actually prefer the original display here. It still uses an xref and the word "attribute" isn't repeated. (When you use an xref like that (with custom text), you don't actually need the angle brackets.)


The method should be an instance `public` method defined as `void`, `Task`, or `ValueTask` (starting with MSTest v3.3). It can optionally be `async` but should not be `async void`.

The method should have zero parameters, unless it's used with `[DataRow]`, `[DynamicData]` or similar attribute that provides test case data to the test method.
The method should have zero parameters, unless it's used with <xref:Microsoft.VisualStudio.TestTools.UnitTesting.DataRowAttribute>, <xref:Microsoft.VisualStudio.TestTools.UnitTesting.DynamicDataAttribute> or similar attribute that provides test case data to the test method.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
The method should have zero parameters, unless it's used with <xref:Microsoft.VisualStudio.TestTools.UnitTesting.DataRowAttribute>, <xref:Microsoft.VisualStudio.TestTools.UnitTesting.DynamicDataAttribute> or similar attribute that provides test case data to the test method.
The method should have zero parameters, unless it's marked with <xref:Microsoft.VisualStudio.TestTools.UnitTesting.DataRowAttribute>, <xref:Microsoft.VisualStudio.TestTools.UnitTesting.DynamicDataAttribute>, or a similar attribute that provides test case data to the test method.


It's possible to control the inheritance behavior: only for current class using `InheritanceBehavior.None` or for all derived classes using `InheritanceBehavior.BeforeEachDerivedClass`.
It's possible to control the inheritance behavior: only for current class using [InheritanceBehavior.None](<xref:Microsoft.VisualStudio.TestTools.UnitTesting.InheritanceBehavior>) or for all derived classes using [InheritanceBehavior.BeforeEachDerivedClass](<xref:Microsoft.VisualStudio.TestTools.UnitTesting.InheritanceBehavior>).
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
It's possible to control the inheritance behavior: only for current class using [InheritanceBehavior.None](<xref:Microsoft.VisualStudio.TestTools.UnitTesting.InheritanceBehavior>) or for all derived classes using [InheritanceBehavior.BeforeEachDerivedClass](<xref:Microsoft.VisualStudio.TestTools.UnitTesting.InheritanceBehavior>).
It's possible to control the inheritance behavior: only for current class using <xref:Microsoft.VisualStudio.TestTools.UnitTesting.InheritanceBehavior.None?displayProperty=nameWithType>, or for all derived classes using <xref:Microsoft.VisualStudio.TestTools.UnitTesting.InheritanceBehavior.BeforeEachDerivedClass?displayProperty=nameWithType>.

- `TestContext.TestData` - the data that will be provided to the parameterized test method or `null` if the test is not parameterized.
- `TestContext.TestDisplayName` - the display name of the test method.
- `TestContext.TestException` - the exception thrown by either the test method or test initialize, or `null` if the test method did not throw an exception.
- <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestData> - the data that will be provided to the parameterized test method or `null` if the test is not parameterized.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestData> - the data that will be provided to the parameterized test method or `null` if the test is not parameterized.
- <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestData?displayProperty=nameWithType> - the data that will be provided to the parameterized test method, or `null` if the test is not parameterized.

- `TestContext.TestDisplayName` - the display name of the test method.
- `TestContext.TestException` - the exception thrown by either the test method or test initialize, or `null` if the test method did not throw an exception.
- <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestData> - the data that will be provided to the parameterized test method or `null` if the test is not parameterized.
- <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestDisplayName> - the display name of the test method.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestDisplayName> - the display name of the test method.
- <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestDisplayName?displayProperty=nameWithType> - the display name of the test method.

- `TestContext.TestException` - the exception thrown by either the test method or test initialize, or `null` if the test method did not throw an exception.
- <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestData> - the data that will be provided to the parameterized test method or `null` if the test is not parameterized.
- <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestDisplayName> - the display name of the test method.
- <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestException> - the exception thrown by either the test method or test initialize, or `null` if the test method did not throw an exception.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestException> - the exception thrown by either the test method or test initialize, or `null` if the test method did not throw an exception.
- <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestException?displayProperty=nameWithType> - the exception thrown by either the test method or test initialize, or `null` if the test method did not throw an exception.

@@ -81,4 +81,4 @@ The <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.AddResultFile

:::code language="csharp" source="snippets/testcontext/csharp/AddResultFile.cs":::

You can also use `TestContext.Write` or `TestContext.WriteLine` methods to write custom messages directly to the test output. This is especially useful for debugging purposes, as it provides real-time logging information within your test execution context.
You can also use <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.Write*> or <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.WriteLine*> methods to write custom messages directly to the test output. This is especially useful for debugging purposes, as it provides real-time logging information within your test execution context.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
You can also use <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.Write*> or <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.WriteLine*> methods to write custom messages directly to the test output. This is especially useful for debugging purposes, as it provides real-time logging information within your test execution context.
You can also use <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.Write*?displayProperty=nameWithType> or <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.WriteLine*?displayProperty=nameWithType> methods to write custom messages directly to the test output. This is especially useful for debugging purposes, as it provides real-time logging information within your test execution context.

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

Successfully merging this pull request may close these issues.

4 participants