From 77ba3a22341121d04e4e1bb936cca903b78687b7 Mon Sep 17 00:00:00 2001 From: CharliesDevBot <364125269+CharliesDevBot@users.noreply.github.com> Date: Wed, 2 Dec 2026 15:11:28 -0800 Subject: [PATCH] Add settings for requesting and reporting an agent type Add SettingDefinitions.RequestedAgentType and SelectedAgentType, beside RequestedAgentName and SelectedAgentName. Runners can then ask for a kind of agent, such as InProcess, without knowing an agent's internal name, and see which kind the engine used. Values are the names of TestAgentType members, held as strings because PackageHelper does not serialize enum-valued settings. Co-Authored-By: Claude Opus 5.5 --- .../PackageSettingsTests.cs | 10 ++++++++++ src/NUnit.Engine.Api/SettingDefinitions.cs | 15 +++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/NUnit.Engine.Api.Tests/PackageSettingsTests.cs b/src/NUnit.Engine.Api.Tests/PackageSettingsTests.cs index 8a337a3..df4b373 100644 --- a/src/NUnit.Engine.Api.Tests/PackageSettingsTests.cs +++ b/src/NUnit.Engine.Api.Tests/PackageSettingsTests.cs @@ -37,6 +37,16 @@ public static void LookupSettingDefinitionFails() Assert.That(lookup, Is.Null); } + [TestCase("RequestedAgentType")] + [TestCase("SelectedAgentType")] + public static void AgentTypeSettingIsAnEmptyStringByDefault(string name) + { + var definition = SettingDefinitions.Lookup(name); + + Assert.That(definition, Is.TypeOf>()); + Assert.That(((SettingDefinition)definition).DefaultValue, Is.Empty); + } + [Test] public void AddKnownSettingUsingSettingDefinition() { diff --git a/src/NUnit.Engine.Api/SettingDefinitions.cs b/src/NUnit.Engine.Api/SettingDefinitions.cs index 46e8f6c..0813958 100644 --- a/src/NUnit.Engine.Api/SettingDefinitions.cs +++ b/src/NUnit.Engine.Api/SettingDefinitions.cs @@ -137,6 +137,21 @@ static SettingDefinitions() /// public static SettingDefinition SelectedAgentName { get; } = new(nameof(SelectedAgentName), string.Empty); + /// + /// Indicates the type of agent requested by the user. Values are the + /// names of members: "InProcess", + /// "LocalProcess" and "RemoteProcess". If not specified, any type + /// of agent may be used, except that tests only run in-process + /// when that is requested. + /// + public static SettingDefinition RequestedAgentType { get; } = new(nameof(RequestedAgentType), string.Empty); + + /// + /// Indicates the type of agent that was actually used, as the name + /// of a member. + /// + public static SettingDefinition SelectedAgentType { get; } = new(nameof(SelectedAgentType), string.Empty); + /// /// Bool flag indicating that the test should be run in a 32-bit process /// on a 64-bit system. By default, NUNit runs in a 64-bit process on