/// <summary> /// Usually this method shouldn't be invoked directly. Use <see cref="TestClass.Run"/> instead. If no test class has /// been specified in the constructor, this method only executes the method itself (but no class setup or teardown /// methods). /// </summary> public void Run(object testClassInstance, int testMethodIndex, ITestResultHandler resultHandler) { this.State = TestState.Running; resultHandler.OnTestMethodStarted(this, testMethodIndex); Exception outcomeError = null; if (this.Class.SetupMethod != null) { outcomeError = InvokeTestMethod(testClassInstance, this.Class.SetupMethod); } if (outcomeError == null) { // No error in the setup method outcomeError = InvokeTestMethod(testClassInstance, this.Method); if (outcomeError != null && IsExpectedException(this.Method, outcomeError)) { outcomeError = null; } if (this.Class.TeardownMethod != null) { var e = InvokeTestMethod(testClassInstance, this.Class.TeardownMethod); // Make sure we don't override the actual failure reson. if (e != null && outcomeError == null) { outcomeError = e; } } } SetOutcome(outcomeError); resultHandler.OnTestMethodEnded(this, testMethodIndex); }