-
Notifications
You must be signed in to change notification settings - Fork 291
Description
Summary
As a test framework, xUnit.net wants to do some things differently based on whether you're running in an interactive mode or not (meaning, running inside of Test Explorer or some other environment that expects to enumerate tests, present a UI to the user, and then run specific tests).
Background and Motivation
Today, there are two conditions where this information is valuable.
-
When running interactively, we want to pre-enumerate all test rows, so the user can run individual test rows. When running non-interactively, this is a waste of time and resources and causes the test discovery to be slower.
-
MTP does not offer a node state for "tests which were not run" (in our case, this generally means a test was marked as Explicit). When running interactively, we must try to "guess" the user's intent when running a subset of tests whether they're asking to run just explicit tests or not, since there is no gesture in the UI regarding explicit tests. When running non-interactively, we can rely on the user to pass our
--explicitswitch to indicate whether they want to run explicit tests or not. This reason this is important is that, from a usability perspective, we don't want to report any test result for a test that wasn't run, so that it'll stay in the "not run" state in the Test Explorer UX, whereas we want to report the test as skipped todotnet testto remind the user that the test was not run (since there's no MTP test node state for "not run").
Prior to .NET SDK 10, the MTP team had told me to detect the --server switch to indicate that we were running interactively. Now with .NET SDK 10, both dotnet test and Test Explorer are using --server, and the new recommendation is to parse the argument to --server to determine this.
There should be a simple and unchanging way to determine this situation.
Proposed Feature
Add an API to query the information we need to know.
The simplest version would be just to query for an "interactive" flag: Test Explorer would set this, and dotnet test would not.
I don't think a more complex "server capabilities" style API would be appropriate here, because both situations seem relatively specific to xUnit.net (especially the explicit test support).