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

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; using System.Runtime.CompilerServices; namespace NUnit.Framework.Internal.Commands { internal class ApplyChangesToContextCommand : BeforeTestCommand { [NullableContext(1)] public ApplyChangesToContextCommand(TestCommand innerCommand, IApplyToContext change) : base(innerCommand) { BeforeTest = change.ApplyToContext; } } }