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

TestMethodCommand

TestMethodCommand is the lowest level concrete command used to run actual test cases.
using NUnit.Framework.Interfaces; namespace NUnit.Framework.Internal.Commands { public class TestMethodCommand : TestCommand { private readonly TestMethod testMethod; private readonly object[] arguments; public TestMethodCommand(TestMethod testMethod) : base(testMethod) { this.testMethod = testMethod; arguments = testMethod.Arguments; } public override TestResult Execute(TestExecutionContext context) { object actual = RunTestMethod(context); if (testMethod.HasExpectedResult) Assert.AreEqual(testMethod.ExpectedResult, actual); context.CurrentResult.SetResult(ResultState.Success); return context.CurrentResult; } private object RunTestMethod(TestExecutionContext context) { return RunNonAsyncTestMethod(context); } private object RunNonAsyncTestMethod(TestExecutionContext context) { return testMethod.Method.Invoke(context.TestObject, arguments); } } }