<PackageReference Include="NUnit" Version="3.11.0" />

ApplyChangesToContextCommand

ContextSettingsCommand applies specified changes to the TestExecutionContext prior to running a test. No special action is needed after the test runs, since the prior context will be restored automatically.
using NUnit.Framework.Interfaces; namespace NUnit.Framework.Internal.Commands { internal class ApplyChangesToContextCommand : BeforeTestCommand { public ApplyChangesToContextCommand(TestCommand innerCommand, IApplyToContext change) : base(innerCommand) { BeforeTest = delegate(TestExecutionContext context) { change.ApplyToContext(context); }; } } }