Skip to content

Commit adfa10a

Browse files
committed
use xref links
1 parent 6949bf0 commit adfa10a

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

docs/core/testing/unit-testing-mstest-writing-tests-testcontext.md

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,26 @@ The `TestContext` class provides properties about the test run along with method
3232

3333
The `TestContext` provides information about the test run, such as:
3434

35-
- `TestName` – the name of the currently executing test.
36-
- `CurrentTestOutcome` the result of the current test.
37-
- `FullyQualifiedTestClassName` the full name of the test class.
38-
- `TestRunDirectory` the directory where the test run is executed.
39-
- `DeploymentDirectory` the directory where the deployment items are located.
40-
- `ResultsDirectory` the directory where the test results are stored. Typically a subdirectory of the `TestRunDirectory`.
41-
- `TestRunResultsDirectory` the directory where the test results are stored. Typically a subdirectory of the `ResultsDirectory`.
42-
- `TestResultsDirectory` the directory where the test results are stored. Typically a subdirectory of the `ResultsDirectory`.
35+
- <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestName> – the name of the currently executing test.
36+
- <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.CurrentTestOutcome> - the result of the current test.
37+
- <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.FullyQualifiedTestClassName> - the full name of the test class.
38+
- <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestRunDirectory> - the directory where the test run is executed.
39+
- <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.DeploymentDirectory> - the directory where the deployment items are located.
40+
- <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.ResultsDirectory> - the directory where the test results are stored. Typically a subdirectory of the `TestRunDirectory`.
41+
- <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestRunResultsDirectory> - the directory where the test results are stored. Typically a subdirectory of the `ResultsDirectory`.
42+
- <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestResultsDirectory> - the directory where the test results are stored. Typically a subdirectory of the `ResultsDirectory`.
4343

4444
In MSTest 3.7 and later, the `TestContext` class also provides new properties helpful for `TestInitialize` and `TestCleanup` methods:
4545

46-
- `TestData` the data that will be provided to the parameterized test method or `null` if the test is not parameterized.
47-
- `TestDisplayName` - the display name of the test method.
48-
- `TestException` - the exception thrown by either the test method or test initialize, or `null` if the test method did not throw an exception.
46+
- <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.
47+
- <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.TestDisplayName> - the display name of the test method.
48+
- <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.
4949

5050
### Data-driven tests
5151

5252
In MSTest 3.7 and later, the property `TestData` can be used to access the data for the current test during `TestInitialize` and `TestCleanup` methods.
5353

54-
When targeting .NET framework, the `TestContext` enables you to retrieve and set data for each iteration in a data-driven test, using properties like `DataRow` and `DataConnection` (for datasource based tests).
54+
When targeting .NET framework, the `TestContext` enables you to retrieve and set data for each iteration in a data-driven test, using properties like `DataRow` and `DataConnection` (for [DataSource](xref:Microsoft.VisualStudio.TestTools.UnitTesting.DataSourceAttribute)-based tests).
5555

5656
Consider the following CSV file `TestData.csv`:
5757

@@ -68,7 +68,7 @@ You can use the `DataSource` attribute to read the data from the CSV file:
6868

6969
### Store and retrieve runtime data
7070

71-
You can use `TestContext.Properties` to store custom key-value pairs that can be accessed across different methods in the same test session.
71+
You can use <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.Properties?displayProperty=nameWithType> to store custom key-value pairs that can be accessed across different methods in the same test session.
7272

7373
```csharp
7474
TestContext.Properties["MyKey"] = "MyValue";
@@ -77,7 +77,7 @@ string value = TestContext.Properties["MyKey"]?.ToString();
7777

7878
### Associate data to a test
7979

80-
The `TestContext.AddResultFile` method allows you to add a file to the test results, making it available for review in the test output. This can be useful if you generate files during your test (for example, log files, screenshots, or data files) that you want to attach to the test results.
80+
The <xref:Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.AddResultFile(System.String)?displayProperty=nameWithType> method allows you to add a file to the test results, making it available for review in the test output. This can be useful if you generate files during your test (for example, log files, screenshots, or data files) that you want to attach to the test results.
8181

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

0 commit comments

Comments
 (0)