### Real-life Example: Filter Methods with Wildcards and OS Property Source: https://github.com/microsoft/testfx/blob/main/docs/mstest-runner-graphqueryfiltering/graph-query-filtering.md Filter methods starting with 'MyTestMethod' across any namespace or class within 'MyAssembly', where the OS property is 'Linux'. ```text /MyAssembly/*/*/MyTestMethod*[OS=Linux] ``` -------------------------------- ### Real-life Example: Filter with Namespace Wildcard and Recursive Property Filter Source: https://github.com/microsoft/testfx/blob/main/docs/mstest-runner-graphqueryfiltering/graph-query-filtering.md Filter nodes from 'MyAssembly' with any namespace starting with 'MyNamespace', and any class, where the OS property is 'Linux'. ```text /MyAssembly/MyNamespace*/**[OS=Linux] ``` -------------------------------- ### Install Microsoft.Testing.Extensions.AzureFoundry Source: https://github.com/microsoft/testfx/blob/main/src/Platform/Microsoft.Testing.Extensions.AzureFoundry/PACKAGE.md Use this command to add the Microsoft.Testing.Extensions.AzureFoundry package to your project. ```dotnetcli dotnet add package Microsoft.Testing.Extensions.AzureFoundry ``` -------------------------------- ### Real-life Example: Filter Methods by Name and OS Property Source: https://github.com/microsoft/testfx/blob/main/docs/mstest-runner-graphqueryfiltering/graph-query-filtering.md Filter methods starting with 'MyTestMethod' in a specific class and namespace, with the OS property set to 'Linux'. ```text /MyAssembly/MyNamespace/MyClass/MyTestMethod*[OS=Linux] ``` -------------------------------- ### Install the package Source: https://github.com/microsoft/testfx/blob/main/src/Platform/Microsoft.Testing.Extensions.Logging/PACKAGE.md Install the Microsoft.Testing.Extensions.Logging package using the .NET CLI. ```dotnetcli dotnet add package Microsoft.Testing.Extensions.Logging ``` -------------------------------- ### DeploymentItem Attribute Usage Example Source: https://github.com/microsoft/testfx/blob/main/docs/RFCs/009-DeploymentItem-Attribute.md Provides a C# code example demonstrating how to use the DeploymentItem attribute at both the class and method levels, including specifying absolute paths, relative paths, and custom output directories. ```APIDOC ## Example ```csharp [TestClass] [DeploymentItem(@"C:\classLevelDepItem.xml")] //absolute path public class UnitTest1 { [TestMethod] [DeploymentItem(@"..\..\methodLevelDepItem1.xml")] //relative path [DeploymentItem(@"C:\DataFiles\methodLevelDepItem2.xml", "DataFiles")] //custom output path public void TestMethod1() { String textFromFile = File.ReadAllText("classLevelDepItem.xml"); } } ``` ``` -------------------------------- ### Install wasm-tools-net10 workload Source: https://github.com/microsoft/testfx/blob/main/samples/WasiPlayground/README.md Install the 'wasm-tools-net10' workload manually, as it's only needed for `dotnet publish` and not for the repo's `dotnet build`. ```cmd .\.dotnet\dotnet.exe workload install wasm-tools-net10 ``` -------------------------------- ### Usage example Source: https://github.com/microsoft/testfx/blob/main/src/Platform/Microsoft.Testing.Extensions.Logging/PACKAGE.md Example of how to configure and use Microsoft.Testing.Extensions.Logging in a test application. ```csharp using Microsoft.Extensions.Logging; using Microsoft.Testing.Extensions; using Microsoft.Testing.Platform.Builder; ITestApplicationBuilder builder = await TestApplication.CreateBuilderAsync(args); builder.AddMicrosoftExtensionsLogging(logging => { logging.AddConsole(); logging.AddDebug(); }); using ITestApplication app = await builder.BuildAsync(); return await app.RunAsync(); ``` -------------------------------- ### Template-Based Naming Example Source: https://github.com/microsoft/testfx/blob/main/docs/microsoft.testing.platform/ArtifactNamingHelper.md Demonstrates how to use placeholders for dynamic file name generation. Placeholder matching is case-sensitive. ```text {pname}_{pid}_{time}_hang.dmp ``` -------------------------------- ### Install Microsoft.Testing.Platform Package Source: https://github.com/microsoft/testfx/blob/main/src/Platform/Microsoft.Testing.Platform/PACKAGE.md Use this command to add the Microsoft.Testing.Platform package to your .NET project. ```dotnetcli dotnet add package Microsoft.Testing.Platform ``` -------------------------------- ### Start Test Host Process Source: https://github.com/microsoft/testfx/blob/main/docs/RFCs/017-TestHost-Launcher.md Launches the test host process using the provided ProcessStartInfo. This is the standard method but has limitations for advanced scenarios. ```csharp using IProcess testHostProcess = process.Start(processStartInfo); ``` -------------------------------- ### Install a logging provider package Source: https://github.com/microsoft/testfx/blob/main/src/Platform/Microsoft.Testing.Extensions.Logging/PACKAGE.md Install a Microsoft.Extensions.Logging provider package, such as Console. ```dotnetcli dotnet add package Microsoft.Extensions.Logging.Console ``` -------------------------------- ### Install Microsoft.Testing.Extensions.TrxReport Package Source: https://github.com/microsoft/testfx/blob/main/src/Platform/Microsoft.Testing.Extensions.TrxReport/PACKAGE.md Use this command to add the Microsoft.Testing.Extensions.TrxReport package to your project. ```dotnetcli dotnet add package Microsoft.Testing.Extensions.TrxReport ``` -------------------------------- ### Line 1: Assertion Prefix and Summary Example Source: https://github.com/microsoft/testfx/blob/main/docs/RFCs/012-Structured-Assertion-Messages.md Demonstrates the first line of an assertion failure, combining a universal prefix with a concise summary of the issue. ```text Assertion failed. Expected values to be equal. ``` -------------------------------- ### Install the package Source: https://github.com/microsoft/testfx/blob/main/src/Platform/Microsoft.Testing.Extensions.HtmlReport/PACKAGE.md Installs the Microsoft.Testing.Extensions.HtmlReport package using the .NET CLI. ```dotnetcli dotnet add package Microsoft.Testing.Extensions.HtmlReport ``` -------------------------------- ### Usage Example: Test Framework with Flaky Test Analysis Source: https://github.com/microsoft/testfx/blob/main/docs/microsoft.testing.platform/001-AI-Extensibility.md An example demonstrating how a test framework can use the `IChatClient` to analyze flaky tests. ```APIDOC ## Test Framework Flaky Test Analysis Example ### Description This example shows how a test framework can leverage the `IChatClient` to analyze flaky tests and report potential root causes. ### Key Components - `MyTestFramework` class implementing `ITestFramework`. - `ExecuteRequestAsync` method orchestrates test execution and AI analysis. - `AnalyzeFlakyTestsAsync` method constructs a prompt and calls the chat client to get an analysis. ### Usage Flow 1. Execute tests and collect results. 2. Retrieve `IChatClientProvider` from the service provider. 3. If a provider is available, create an `IChatClient` instance. 4. Identify flaky tests from the results. 5. Construct a prompt with details of flaky tests. 6. Call `chatClient.GetResponseAsync` to get the AI analysis. 7. Report the analysis. ### Benefits for Extension Authors - **No AI-specific infrastructure**: Simply call `GetChatClientAsync()` and use the `IChatClient` interface. - **Works with any provider**: Compatible with Azure OpenAI, OpenAI, local models, or custom providers. - **Graceful degradation**: Extensions can detect AI unavailability and skip AI-powered features. - **Feature detection**: Check `SupportsToolCalling` for advanced capabilities. ``` -------------------------------- ### Install the package Source: https://github.com/microsoft/testfx/blob/main/src/Platform/Microsoft.Testing.Extensions.CrashDump/PACKAGE.md Installs the Microsoft.Testing.Extensions.CrashDump package using the .NET CLI. ```dotnetcli dotnet add package Microsoft.Testing.Extensions.CrashDump ``` -------------------------------- ### Custom Environment Variable Provider Example Source: https://github.com/microsoft/testfx/blob/main/docs/microsoft.testing.platform/002-TestConfig-EnvironmentVariables.md Before the `environmentVariables` section was introduced, custom environment variable providers were required. This example shows the boilerplate code needed to implement `ITestHostEnvironmentVariableProvider` and register it with the test builder. ```csharp internal sealed class MyEnvProvider : ITestHostEnvironmentVariableProvider { // ~50 lines of boilerplate to read appsettings/IConfiguration and call SetVariable. } builder.TestHost.AddEnvironmentVariableProvider(_ => new MyEnvProvider(...)); ``` -------------------------------- ### Add OpenTelemetry Package Source: https://github.com/microsoft/testfx/blob/main/src/Platform/Microsoft.Testing.Extensions.OpenTelemetry/PACKAGE.md Installs the Microsoft.Testing.Extensions.OpenTelemetry package using the .NET CLI. ```dotnetcli dotnet add package Microsoft.Testing.Extensions.OpenTelemetry ``` -------------------------------- ### Install Microsoft.Testing.Extensions.HangDump Package Source: https://github.com/microsoft/testfx/blob/main/src/Platform/Microsoft.Testing.Extensions.HangDump/PACKAGE.md Use this command to add the HangDump extension package to your project. ```dotnetcli dotnet add package Microsoft.Testing.Extensions.HangDump ``` -------------------------------- ### Add Microsoft.Testing.Extensions.Telemetry Package Source: https://github.com/microsoft/testfx/blob/main/src/Platform/Microsoft.Testing.Extensions.Telemetry/PACKAGE.md Install the Microsoft.Testing.Extensions.Telemetry package using the .NET CLI. ```dotnetcli dotnet add package Microsoft.Testing.Extensions.Telemetry ``` -------------------------------- ### Add AzureDevOpsReport Package Source: https://github.com/microsoft/testfx/blob/main/src/Platform/Microsoft.Testing.Extensions.AzureDevOpsReport/PACKAGE.md Installs the Microsoft.Testing.Extensions.AzureDevOpsReport package using the .NET CLI. ```dotnetcli dotnet add package Microsoft.Testing.Extensions.AzureDevOpsReport ``` -------------------------------- ### Initialize Test Runner Source: https://github.com/microsoft/testfx/blob/main/docs/mstest-runner-protocol/001-protocol-intro.md The `initialize` request is used to start the test runner and communicate client capabilities. The server responds with its own capabilities. ```APIDOC ## POST /initialize ### Description Initializes the test runner and negotiates capabilities between the client and server. This request is based on the Language Server Protocol (LSP) `initialize` request, extended for testing features. ### Method POST ### Endpoint /initialize ### Request Body #### Parameters - **processId** (PID) - Required - The process ID of the parent process that started the server. Null if not started by another process. - **clientInfo** (object) - Required - Information about the client. - **name** (string) - Required - The name of the client. - **version** (string) - Required - The client's protocol version, following semver. - **capabilities** (object) - Required - Client capabilities for testing features. - **testing** (object) - Required - Namespace for testing capabilities. - **debuggerProvider** (boolean) - Optional - If true, the client supports `client/attachDebugger` and `client/launchDebugger` requests. - **batchLoggingSupport** (boolean) - Optional - If true, the client can receive batched log messages via `client/log`. - **attachmentsSupport** (boolean) - Optional - If true, the client supports the `testing/testUpdates/attachments` request. - **callbackProvider** (object) - Optional - If present, the client provides a port for child processes to connect. - **port** (integer) - Required - The port number for callbacks. ### Request Example ```json { "processId": 12345, "clientInfo": { "name": "TestClient", "version": "1.0.0" }, "capabilities": { "testing": { "debuggerProvider": true, "batchLoggingSupport": true, "attachmentsSupport": true, "callbackProvider": { "port": 5000 } } } } ``` ### Response #### Success Response (200) - **serverInfo** (object) - Information about the server. - **name** (string) - The name of the server. - **version** (string) - The server's protocol version. - **capabilities** (object) - Server capabilities for testing. - **testing** (object) - Namespace for testing capabilities. - **experimental_multiRequestSupport** (boolean) - Optional - If true, the server can handle multiple discover/run requests, allowing the client to keep the process alive. - **attachmentsProvider** (boolean) - Optional - If true, the server will send attachments with test updates. #### Response Example ```json { "serverInfo": { "name": "TestServer", "version": "1.0.0" }, "capabilities": { "testing": { "experimental_multiRequestSupport": true, "attachmentsProvider": true } } } ``` ``` -------------------------------- ### Add Microsoft.Testing.Extensions.CtrfReport Package Source: https://github.com/microsoft/testfx/blob/main/src/Platform/Microsoft.Testing.Extensions.CtrfReport/PACKAGE.md Install the CTRF report extension package using the .NET CLI. ```dotnetcli dotnet add package Microsoft.Testing.Extensions.CtrfReport ``` -------------------------------- ### Publish WasiPlayground sample Source: https://github.com/microsoft/testfx/blob/main/samples/WasiPlayground/README.md Publish the WasiPlayground sample from the repo root using the specified project file, configuration, and target framework. ```cmd .\.dotnet\dotnet.exe publish samples\WasiPlayground\WasiPlayground.csproj -c Debug -f net10.0 ``` -------------------------------- ### Filter Nodes by Property Value Not Starting With Source: https://github.com/microsoft/testfx/blob/main/docs/mstest-runner-graphqueryfiltering/graph-query-filtering.md Use `/**[Key!=Value*]` to find nodes where the property value does not start with 'Value'. Example: `/**[P2!=A*]`. ```text /**[P2!=A*] ``` -------------------------------- ### Filter Nodes by Property Value Prefix Source: https://github.com/microsoft/testfx/blob/main/docs/mstest-runner-graphqueryfiltering/graph-query-filtering.md Use `/**[Key=Value*]` to find nodes where the property value starts with 'Value'. Example: `/**[P2=A*]`. ```text /**[P2=A*] ``` -------------------------------- ### POST /initialize Source: https://github.com/microsoft/testfx/blob/main/docs/mstest-runner-protocol/001-protocol-intro.md Requests the server to establish client/server configuration and handshake the set of supported features. ```APIDOC ## POST /initialize ### Description Request sent to server to establish the client/server configuration and handshake the set of features. ### Method POST ### Endpoint /initialize ### Request Body - **capabilities** (object) - Required - The capabilities supported by the client. - **version** (string) - Required - The version of the protocol supported by the client. - **supportsRunTests** (boolean) - Optional - Indicates if the client supports running tests. - **supportsDiscovery** (boolean) - Optional - Indicates if the client supports test discovery. ### Request Example ```json { "jsonrpc": "2.0", "id": 1, "method": "initialize", "params": { "capabilities": { "version": "1.0", "supportsRunTests": true, "supportsDiscovery": true } } } ``` ### Response #### Success Response (200) - **capabilities** (object) - The capabilities supported by the server. - **version** (string) - The version of the protocol supported by the server. - **supportsRunTests** (boolean) - Indicates if the server supports running tests. - **supportsDiscovery** (boolean) - Indicates if the server supports test discovery. #### Response Example ```json { "jsonrpc": "2.0", "id": 1, "result": { "capabilities": { "version": "1.0", "supportsRunTests": true, "supportsDiscovery": true } } } ``` ``` -------------------------------- ### Combine Path Filters Source: https://github.com/microsoft/testfx/blob/main/docs/mstest-runner-graphqueryfiltering/graph-query-filtering.md Combine path filtering operators using '&' for AND and '()' for grouping. Example: '/A/(B*)&(!*C)' selects nodes under A starting with B and not ending with C. ```text /A/(B*)&(!*C) ``` -------------------------------- ### TestHostLaunchContext Class Source: https://github.com/microsoft/testfx/blob/main/docs/RFCs/017-TestHost-Launcher.md The TestHostLaunchContext class encapsulates all the information required to launch a test host process, including file name, arguments, environment variables, and working directory. ```APIDOC ## TestHostLaunchContext Class ### Description Represents the context for launching a test host, containing all necessary details prepared by the platform. ### Class `Microsoft.Testing.Platform.Extensions.TestHostControllers.TestHostLaunchContext` ### Properties - **FileName** (string) - The default test host executable path the platform would have started. - **Arguments** (IReadOnlyList) - Arguments, already including the test host controller PID option. - **EnvironmentVariables** (IReadOnlyDictionary) - The final environment for the test host, after all `ITestHostEnvironmentVariableProvider` ran. Includes the controller↔host IPC pipe name the host must connect back on. - **WorkingDirectory** (string?) - The working directory, or null to inherit the current one. ``` -------------------------------- ### Launch Test Host Under Debugger Source: https://github.com/microsoft/testfx/blob/main/docs/RFCs/017-TestHost-Launcher.md Launches a test host process and attaches a debugger to it. The process is started with a specific environment variable to ensure it suspends upon startup, allowing the debugger to attach before execution begins. The debugger is then resumed. ```csharp public async Task LaunchTestHostAsync( TestHostLaunchContext context, CancellationToken cancellationToken) { var psi = new ProcessStartInfo(context.FileName) { UseShellExecute = false }; foreach (string arg in context.Arguments) psi.ArgumentList.Add(arg); foreach (var kvp in context.EnvironmentVariables.Where(kv => kv.Value is not null)) psi.Environment[kvp.Key] = kvp.Value; // skip unset (null) vars psi.Environment["DOTNET_DefaultDiagnosticPortSuspend"] = "1"; // start suspended Process p = Process.Start(psi)!; await DebuggerLauncher.AttachAsync(p.Id, cancellationToken); // e.g. vsdbg / WinDbg / dlv await DebuggerLauncher.ResumeAsync(p.Id, cancellationToken); return new ProcessHandleAdapter(p); } ``` -------------------------------- ### PrivateObject Get Methods Source: https://github.com/microsoft/testfx/blob/main/src/TestFramework/TestFramework.Extensions/PublicAPI/net462/PublicAPI.Shipped.txt Methods for getting private fields, properties, and array elements. ```APIDOC ## PrivateObject Get Methods ### Description Methods for retrieving the values of private fields, properties, and array elements of the wrapped object. ### Properties - `RealType.get -> System.Type` - `Target.get -> object` - `Target.set -> void` ### Methods - `GetArrayElement(string name, params int[] indices) -> object` - `GetArrayElement(string name, BindingFlags bindingFlags, params int[] indices) -> object` - `GetField(string name) -> object` - `GetField(string name, BindingFlags bindingFlags) -> object` - `GetFieldOrProperty(string name) -> object` - `GetFieldOrProperty(string name, BindingFlags bindingFlags) -> object` - `GetProperty(string name, params object[] args) -> object` - `GetProperty(string name, BindingFlags bindingFlags, params object[] args) -> object` - `GetProperty(string name, BindingFlags bindingFlags, Type[] parameterTypes, object[] args) -> object` - `GetProperty(string name, Type[] parameterTypes, object[] args) -> object` ### Parameters - **name** (string) - Required - The name of the field, property, or array element. - **bindingFlags** (System.Reflection.BindingFlags) - Optional - Flags that specify how the search for the member is conducted. - **indices** (int[]) - Required for `GetArrayElement` - The indices of the array element to retrieve. - **args** (object[]) - Optional - Arguments to pass to the property getter. - **parameterTypes** (System.Type[]) - Optional - An array of Type objects that represent the number, order, and type of the parameters of the property getter. ``` -------------------------------- ### Build and run the test Docker image Source: https://github.com/microsoft/testfx/blob/main/samples/public/mstest-runner/RunInDocker/README.md Builds the Docker image containing the tests and then runs it. This executes the integration tests against the application. The output shows the test execution details and results. ```cli RunInDocker> docker build . -t my-server-tests RunInDocker> docker run my-server-tests Microsoft(R) Testing Platform Execution Command Line Tool Version: 1.0.0-preview.23622.9+fe96e7475 (UTC 2023/12/22) RuntimeInformation: linux-x64 - .NET 8.0.0 Copyright(c) Microsoft Corporation. All rights reserved. info: Microsoft.Hosting.Lifetime[14] Now listening on: http://[::]:8080 info: Microsoft.Hosting.Lifetime[0] Application started. Press Ctrl+C to shut down. info: Microsoft.Hosting.Lifetime[0] Hosting environment: Production info: Microsoft.Hosting.Lifetime[0] Content root path: /test/test info: Microsoft.AspNetCore.Hosting.Diagnostics[1] Request starting HTTP/1.1 GET http://localhost:8080/hello - - - info: Microsoft.AspNetCore.Routing.EndpointMiddleware[0] Executing endpoint 'HTTP: GET /hello' info: Microsoft.AspNetCore.Routing.EndpointMiddleware[1] Executed endpoint 'HTTP: GET /hello' info: Microsoft.AspNetCore.Hosting.Diagnostics[2] Request finished HTTP/1.1 GET http://localhost:8080/hello - 200 - text/plain;+charset=utf-8 73.5556ms Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1, Duration: 1.7s - MyServer.Tests.dll (linux-x64 - .NET 8.0.0) ``` -------------------------------- ### IterativeTestMethodAttribute Example Source: https://github.com/microsoft/testfx/blob/main/docs/RFCs/003-Customize-Running-Tests.md An example of a custom attribute that runs a test method multiple times for stability validation. ```APIDOC ## IterativeTestMethodAttribute Example ### Description This example demonstrates creating a custom `IterativeTestMethodAttribute` that extends `TestMethodAttribute` to execute a test method a specified number of times, useful for stability testing. ### Method `Execute(ITestMethod testMethod)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```csharp [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] public class IterativeTestMethodAttribute : TestMethodAttribute { private int stabilityThreshold; public IterativeTestMethodAttribute(int stabilityThreshold) { this.stabilityThreshold = stabilityThreshold; } public override TestResult[] Execute(ITestMethod testMethod) { var results = new List(); for(int count = 0; count < this.stabilityThreshold; count++) { var currentResults = base.Execute(testMethod); results.AddRange(currentResults); } return results.ToArray(); } } ``` ### Response #### Success Response (200) - **TestResult[]** - An array of TestResult objects from all iterations. #### Response Example ```csharp // Usage in a test class [TestClass] public class LongRunningScenarios() { [IterativeTestMethod(5)] public void LongRunningTest() { // Test logic } } ``` ``` -------------------------------- ### Register TestHostLauncher Source: https://github.com/microsoft/testfx/blob/main/docs/RFCs/017-TestHost-Launcher.md Register the TestHostLauncher extension with the builder. This is a prerequisite for using any of the launch functionalities. ```csharp builder.TestHostControllers.AddTestHostLauncher(sp => new MyLauncher(sp)); ``` -------------------------------- ### Build MSTest with Help Option Source: https://github.com/microsoft/testfx/blob/main/docs/dev-guide.md Invoke the build script with the '-help' or '-h' flag to display available build options. On Unix-like systems, arguments can be prefixed with a single '-' or double '--'. ```shell build.cmd -help ``` -------------------------------- ### Install the package Source: https://github.com/microsoft/testfx/blob/main/src/Platform/Microsoft.Testing.Extensions.Retry/PACKAGE.md Command to add the Microsoft.Testing.Extensions.Retry package to a project. ```dotnetcli dotnet add package Microsoft.Testing.Extensions.Retry ``` -------------------------------- ### Run WasiPlayground with wasmtime Source: https://github.com/microsoft/testfx/blob/main/samples/WasiPlayground/README.md Execute the 'dotnet.wasm' binary using 'wasmtime'. The '-S http' flag is required because the runtime imports 'wasi:http'. Ensure you are in the AppBundle directory. ```cmd cd artifacts\bin\WasiPlayground\Debug\net10.0\wasi-wasm\AppBundle wasmtime run -S http --dir . -- dotnet.wasm WasiPlayground ``` -------------------------------- ### DoesNotStartWith Assertions Source: https://github.com/microsoft/testfx/blob/main/src/TestFramework/TestFramework/PublicAPI/PublicAPI.Shipped.txt Methods to assert that a string does not start with a specified prefix. ```APIDOC ## Assert.DoesNotStartWith ### Description Asserts that a string does not start with the specified prefix. ### Method Various overloads available (e.g., static) ### Endpoint N/A (This is a library assertion method, not an API endpoint) ### Parameters - **notExpectedPrefix** (string) - Required - The prefix that the string should not start with. - **value** (string) - Required - The string to check. - **comparisonType** (StringComparison) - Optional - Specifies the culture, case, and sort rules to be used for the comparison. - **message** (string) - Optional - A message to display if the assertion fails. - **notExpectedPrefixExpression** (string) - Optional - The source code of the notExpectedPrefix expression. - **valueExpression** (string) - Optional - The source code of the value expression. ### Response #### Success Response No explicit return value for successful assertion; execution continues. #### Response Example N/A ``` -------------------------------- ### AssemblyFixtureProviderAttribute Source: https://github.com/microsoft/testfx/blob/main/src/TestFramework/TestFramework/PublicAPI/PublicAPI.Unshipped.txt Attribute to specify a fixture type for assembly-level setup and teardown. ```APIDOC ## AssemblyFixtureProviderAttribute Constructor ### Description Initializes a new instance of the AssemblyFixtureProviderAttribute class. ### Method Signature Microsoft.VisualStudio.TestTools.UnitTesting.AssemblyFixtureProviderAttribute(System.Type! fixtureType) -> void ## AssemblyFixtureProviderAttribute.FixtureType Property ### Description Gets the type of the fixture associated with this attribute. ### Property Signature Microsoft.VisualStudio.TestTools.UnitTesting.AssemblyFixtureProviderAttribute.FixtureType.get -> System.Type! ``` -------------------------------- ### Launch Test Host Elevated (Run as Administrator) Source: https://github.com/microsoft/testfx/blob/main/docs/RFCs/017-TestHost-Launcher.md Launches a test host process with elevated privileges (Run as Administrator). This requires setting UseShellExecute to true and specifying the 'runas' verb. Note that when UseShellExecute is true, per-process environment variables cannot be passed directly; the launcher must find an alternative method to deliver them to the host. ```csharp public Task LaunchTestHostAsync( TestHostLaunchContext context, CancellationToken cancellationToken) { var psi = new ProcessStartInfo(context.FileName) { UseShellExecute = true, // required for the UAC "runas" verb Verb = "runas", }; foreach (string arg in context.Arguments) psi.ArgumentList.Add(arg); // NOTE: UseShellExecute = true cannot pass per-process env vars; an elevated launcher // must forward context.EnvironmentVariables another way (e.g. a temp response file the // host reads, or a broker that sets them) so the host still finds the controller pipe. Process p = Process.Start(psi)!; return Task.FromResult(new ProcessHandleAdapter(p)); } ``` -------------------------------- ### Interface for Test Host Launcher Extension Source: https://github.com/microsoft/testfx/blob/main/docs/RFCs/017-TestHost-Launcher.md Implement this interface to control how the out-of-process test host is launched, replacing the default Process.Start behavior. The platform provides prepared launch context. ```csharp namespace Microsoft.Testing.Platform.Extensions.TestHostControllers; /// /// Allows an extension to control how the out-of-process test host is launched, /// replacing the platform's default Process.Start behavior. /// [Experimental("TPEXP", UrlFormat = "https://aka.ms/testingplatform/diagnostics#{0}")] public interface ITestHostLauncher : ITestHostControllersExtension // : IExtension { /// /// Creates and starts the test host. The platform has already prepared the file name, /// arguments, and environment variables (including the controller IPC pipe name) carried by /// . The implementation must return a handle the platform can monitor. /// Task LaunchTestHostAsync( TestHostLaunchContext context, CancellationToken cancellationToken); } ``` -------------------------------- ### Test Host Launch Context Structure Source: https://github.com/microsoft/testfx/blob/main/docs/RFCs/017-TestHost-Launcher.md This sealed class encapsulates all information required to launch a test host process. It includes the executable path, arguments, environment variables, and working directory. ```csharp [Experimental("TPEXP", UrlFormat = "https://aka.ms/testingplatform/diagnostics#{0}")] public sealed class TestHostLaunchContext { public TestHostLaunchContext( string fileName, IReadOnlyList arguments, IReadOnlyDictionary environmentVariables, string? workingDirectory); /// The default test host executable path the platform would have started. public string FileName { get; } /// Arguments, already including the test host controller PID option. public IReadOnlyList Arguments { get; } /// /// The final environment for the test host, after all /// ran. Includes the /// controller↔host IPC pipe name the host must connect back on. /// public IReadOnlyDictionary EnvironmentVariables { get; } /// The working directory, or null to inherit the current one. public string? WorkingDirectory { get; } } ``` -------------------------------- ### POST /client/launchDebugger Source: https://github.com/microsoft/testfx/blob/main/docs/mstest-runner-protocol/001-protocol-intro.md Requests a client to launch a process with a debugger attached to it. ```APIDOC ## POST /client/launchDebugger ### Description Requests a client to launch a process with debugger attached to it. ### Method POST ### Endpoint /client/launchDebugger ### Request Body - **processId** (integer) - Required - The process ID to attach the debugger to. - **debuggerType** (string) - Optional - The type of debugger to attach (e.g., 'CoreClr', 'Managed'). ### Request Example ```json { "jsonrpc": "2.0", "id": 4, "method": "client/launchDebugger", "params": { "processId": 12345, "debuggerType": "Managed" } } ``` ### Response #### Success Response (200) (No specific result data is expected, success indicates the request was processed.) #### Response Example ```json { "jsonrpc": "2.0", "id": 4, "result": null } ``` ``` -------------------------------- ### Collection Multi-Line Rendering Example Source: https://github.com/microsoft/testfx/blob/main/docs/RFCs/012-Structured-Assertion-Messages.md Demonstrates how collections exceeding 120 characters are rendered with one element per line for better readability. Both expected and actual collections use the same rendering style. ```text actual: [ "a very long element name that takes up space", "another lengthy element value here", "and a third one" ] ``` -------------------------------- ### LinePositionSpan Source: https://github.com/microsoft/testfx/blob/main/src/Platform/Microsoft.Testing.Platform/PublicAPI/PublicAPI.Shipped.txt Represents a span of text defined by start and end line positions. ```APIDOC ## LinePositionSpan ### Description Represents a span of text defined by start and end line positions. ### Constructors - `LinePositionSpan()` - `LinePositionSpan(LinePosition start, LinePosition end)` ### Properties - **Start** (LinePosition) - Gets the starting line position of the span. ``` -------------------------------- ### LinePositionSpan Source: https://github.com/microsoft/testfx/blob/main/src/Platform/Microsoft.Testing.Platform/PublicAPI/PublicAPI.Shipped.txt Represents a span of text defined by a start and end line position. ```APIDOC ## LinePositionSpan ### Description Represents a span of text defined by a start and end line position. ### Properties - **End** (Microsoft.Testing.Platform.Extensions.Messages.LinePosition) - Gets the end line position of the span. ``` -------------------------------- ### Configuration Options Source: https://github.com/microsoft/testfx/blob/main/src/Platform/Microsoft.Testing.Platform/PublicAPI/PublicAPI.Shipped.txt Options for configuring the testing platform. ```APIDOC ## Class Microsoft.Testing.Platform.Builder.ConfigurationOptions ### Description Provides options for configuring the application's configuration sources. ### Method N/A ### Endpoint N/A ### Parameters N/A ### Response N/A ``` ```APIDOC ## GET /api/configuration/options/configurationSources ### Description Gets the configuration sources options. ### Method GET ### Endpoint /api/configuration/options/configurationSources ### Parameters N/A ### Response #### Success Response (200) - **ConfigurationSources** (Microsoft.Testing.Platform.Builder.ConfigurationSourcesOptions!) - The configuration sources options. #### Response Example ```json { "configurationSources": {} } ``` ``` ```APIDOC ## Class Microsoft.Testing.Platform.Builder.ConfigurationSourcesOptions ### Description Configures the sources for application configuration. ### Method N/A ### Endpoint N/A ### Parameters N/A ### Response N/A ``` ```APIDOC ## POST /api/configuration/sourcesOptions/registerEnvironmentVariablesConfigurationSource ### Description Enables or disables the registration of environment variables as a configuration source. ### Method POST ### Endpoint /api/configuration/sourcesOptions/registerEnvironmentVariablesConfigurationSource ### Parameters #### Request Body - **register** (bool) - Required - True to register environment variables, false otherwise. ### Response #### Success Response (200) - **void** - Indicates the operation was successful. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Add JUnitReport Package Source: https://github.com/microsoft/testfx/blob/main/src/Platform/Microsoft.Testing.Extensions.JUnitReport/PACKAGE.md Install the JUnitReport extension package using the .NET CLI. ```dotnetcli dotnet add package Microsoft.Testing.Extensions.JUnitReport ``` -------------------------------- ### Build MSTest on Windows Source: https://github.com/microsoft/testfx/blob/main/docs/dev-guide.md Execute the build script for Windows to compile the MSTest project. This is the recommended method for building the repository. ```shell build.cmd ``` -------------------------------- ### ITestHostProcessLifetimeHandler Interface Source: https://github.com/microsoft/testfx/blob/main/src/Platform/Microsoft.Testing.Platform/PublicAPI/PublicAPI.Shipped.txt Handles events related to the test host process lifecycle, before it starts. ```APIDOC ## ITestHostProcessLifetimeHandler Interface ### Description Manages the lifecycle of the test host process, allowing execution of logic before the process starts. ### Methods - **BeforeTestHostProcessStartAsync**(cancellationToken: CancellationToken): Task ``` -------------------------------- ### ITestSessionLifetimeHandler Interface Source: https://github.com/microsoft/testfx/blob/main/src/Platform/Microsoft.Testing.Platform/PublicAPI/PublicAPI.Shipped.txt Handles events related to the test session's lifecycle, before and after the session starts. ```APIDOC ## ITestSessionLifetimeHandler Interface ### Description Provides methods to hook into the start and finish of a test session. ### Methods - **OnTestSessionFinishingAsync**(testSessionContext: ITestSessionContext): Task - **OnTestSessionStartingAsync**(testSessionContext: ITestSessionContext): Task ``` -------------------------------- ### Install Microsoft.Testing.Extensions.HotReload Package Source: https://github.com/microsoft/testfx/blob/main/src/Platform/Microsoft.Testing.Extensions.HotReload/PACKAGE.md Use this command to add the Hot Reload extension package to your .NET project. ```dotnetcli dotnet add package Microsoft.Testing.Extensions.HotReload ``` -------------------------------- ### Schema Versions Object Example Source: https://github.com/microsoft/testfx/blob/main/docs/testconfig.schema.md This JSON snippet demonstrates how the SchemaStore catalog entry can be configured to support multiple frozen versions of a schema side by side using a 'versions' object. ```json { "versions": { "v4": "https://raw.githubusercontent.com/microsoft/testfx/main/docs/testconfig.schema.json" } } ```