public override void RunTestMethod(TestCaseResult testResult) #endif { object[] arguments = _arguments != null ? _arguments : new object[] { null }; Reflect.InvokeMethod(this.Method, this.Fixture, arguments); testResult.Success(); // If no exception occured }
protected internal virtual void ProcessException(Exception exception, TestCaseResult testResult) { if (!ExceptionExpected) { RecordException(exception, testResult); return; } if (IsExpectedExceptionType(exception)) { if (IsExpectedMessageMatch(exception)) { if (exceptionHandler != null) { Reflect.InvokeMethod(exceptionHandler, this.Fixture, exception); } testResult.Success(); } else { testResult.Failure(WrongTextMessage(exception), GetStackTrace(exception)); } } else if (IsAssertException(exception)) { testResult.Failure(exception.Message, exception.StackTrace); } else { testResult.Failure(WrongTypeMessage(exception), GetStackTrace(exception)); } }
protected override internal void ProcessException(Exception exception, TestCaseResult testResult) { if (expectedException.Equals(exception.GetType())) { if (expectedMessage != null && !expectedMessage.Equals(exception.Message)) { string message = string.Format("Expected exception to have message: \"{0}\" but received message \"{1}\"", expectedMessage, exception.Message); testResult.Failure(message, exception.StackTrace); } else { testResult.Success(); } } else if (exception is Framework.AssertionException) { RecordException(exception,testResult); } else { string message = "Expected: " + expectedException.Name + " but was " + exception.GetType().Name; testResult.Failure(message, exception.StackTrace); } return; }
protected override internal void ProcessException(Exception exception, TestCaseResult testResult) { if (expectedException.Equals(exception.GetType())) { if (expectedMessage != null && !expectedMessage.Equals(exception.Message)) { string message = string.Format("Expected exception to have message: \"{0}\" but received message \"{1}\"", expectedMessage, exception.Message); testResult.Failure(message, exception.StackTrace); } else { testResult.Success(); } } else if (exception is Framework.AssertionException) { RecordException(exception, testResult); } else { string message = "Expected: " + expectedException.Name + " but was " + exception.GetType().Name; testResult.Failure(message, exception.StackTrace); } return; }
protected internal virtual void ProcessNoException(TestCaseResult testResult) { if (ExceptionExpected) { testResult.Failure(NoExceptionMessage(), null); } else { testResult.Success(); } }
public override void Run(TestCaseResult result) { if (ShouldRun) { DateTime start = DateTime.Now; try { List<string> expectedLines = CreateStringList(WomDocument.Parse(_expected)); WomDocument parseResult = ParseWikiText(_source); List<string> actualLines = CreateStringList(parseResult); CompareStringLists(expectedLines, actualLines); result.Success(); } catch (Exception ex) { if (ex is NunitException) { ex = ex.InnerException; } if (testFramework.IsIgnoreException(ex)) { result.NotRun(BuildMessage(ex), BuildStackTrace(ex)); } else { result.Failure(BuildMessage(ex), BuildStackTrace(ex)); } } finally { DateTime stop = DateTime.Now; TimeSpan span = stop.Subtract(start); result.Time = (double)span.Ticks / (double)TimeSpan.TicksPerSecond; } } else { result.NotRun(this.IgnoreReason); } }
public void ClearResults() { TestCaseResult testCaseResult = new TestCaseResult( testCaseInfo ); testCaseResult.Success(); TestSuiteResult testSuiteResult = new TestSuiteResult( fixtureInfo, "MockTestFixture" ); testSuiteResult.AddResult( testCaseResult ); testSuiteResult.RunState = RunState.Executed; TestSuiteTreeNode node1 = new TestSuiteTreeNode( testSuiteResult ); TestSuiteTreeNode node2 = new TestSuiteTreeNode( testCaseResult ); node1.Nodes.Add( node2 ); Assert.AreEqual( TestSuiteTreeNode.SuccessIndex, node1.ImageIndex ); Assert.AreEqual( TestSuiteTreeNode.SuccessIndex, node1.SelectedImageIndex ); Assert.AreEqual( TestSuiteTreeNode.SuccessIndex, node2.ImageIndex ); Assert.AreEqual( TestSuiteTreeNode.SuccessIndex, node2.SelectedImageIndex ); node1.ClearResults(); Assert.AreEqual( TestSuiteTreeNode.InitIndex, node1.ImageIndex ); Assert.AreEqual( TestSuiteTreeNode.InitIndex, node1.SelectedImageIndex ); Assert.AreEqual( TestSuiteTreeNode.InitIndex, node2.ImageIndex ); Assert.AreEqual( TestSuiteTreeNode.InitIndex, node2.SelectedImageIndex ); }
protected internal override void ProcessNoException(TestCaseResult testResult) { testResult.Success(); }
protected internal virtual void ProcessException(Exception exception, TestCaseResult testResult) { if (!ExceptionExpected) { RecordException(exception, testResult); return; } if (IsExpectedExceptionType(exception)) { if (IsExpectedMessageMatch(exception)) { if ( exceptionHandler != null ) Reflect.InvokeMethod( exceptionHandler, this.Fixture, exception ); testResult.Success(); } else { testResult.Failure(WrongTextMessage(exception), GetStackTrace(exception)); } } else if (IsAssertException(exception)) { testResult.Failure(exception.Message, exception.StackTrace); } else { testResult.Failure(WrongTypeMessage(exception), GetStackTrace(exception)); } }
public void SetResult_Success() { TestSuiteTreeNode node = new TestSuiteTreeNode( testCaseInfo ); TestCaseResult result = new TestCaseResult( testCaseInfo ); result.Success(); node.Result = result; Assert.AreEqual( TestSuiteTreeNode.SuccessIndex, node.ImageIndex ); Assert.AreEqual( TestSuiteTreeNode.SuccessIndex, node.SelectedImageIndex ); Assert.AreEqual( "Success", node.StatusText ); }
private TestSuiteResult MockSuiteResult(string suiteName, bool failure) { TestSuiteResult result = new TestSuiteResult(suiteName); result.Time = time; result.RunState = RunState.Executed; TestSuiteResult level1SuiteA = new TestSuiteResult("level 1 A"); result.AddResult(level1SuiteA); level1SuiteA.RunState = RunState.Executed; TestSuiteResult level1SuiteB = new TestSuiteResult("level 1 B"); result.AddResult(level1SuiteB); level1SuiteB.RunState = RunState.Executed; testCase = new TestCaseResult("a test case"); if(failure) testCase.Failure("argument exception",null); else testCase.Success(); level1SuiteA.AddResult(testCase); testCase = new TestCaseResult("a successful test"); testCase.Success(); level1SuiteB.AddResult(testCase); testCase = new TestCaseResult("a not run test"); testCase.Ignore("test not run"); level1SuiteB.AddResult(testCase); return result; }
protected internal virtual void ProcessNoException(TestCaseResult testResult) { if ( ExceptionExpected ) testResult.Failure(NoExceptionMessage(), null); else testResult.Success(); }
public virtual void RunTestMethod(TestCaseResult testResult) { _testCase.Execute(); testResult.Success(); }
void ReportResult (string failureMessage, string stackTrace, TestCaseResult res) { if (_inverseResult) { if (failureMessage != null) res.Success (); else res.Failure ("The following test was FIXED: "+_testid, null); } else { if (failureMessage != null) res.Failure (failureMessage, stackTrace); else res.Success (); } }
private void doTestCase(TestCaseResult testResult) { try { RunTestMethod(testResult); testResult.Success(); } catch (Exception ex) { if (ex is NunitException) ex = ex.InnerException; if (testFramework.IsIgnoreException(ex)) testResult.NotRun(ex.Message, BuildStackTrace(ex)); else RecordException(ex, testResult); } }
public override void RunTestMethod(TestCaseResult testResult) { var module = GetModule (); if (module == null) return; Reflect.InvokeMethod (Method, Fixture, new object [] { module }); testResult.Success (); }
public override void Run (TestCaseResult res) { string type = _test.GetAttribute ("TYPE"); if (type == "error") res.Success (); Uri baseUri = new Uri (_test.BaseURI); Uri testUri = new Uri (baseUri, _test.GetAttribute ("URI")); bool nonValidatingPassed = TestNonValidating (testUri.ToString ()); bool validatingPassed = TestValidating (testUri.ToString ()); bool isok = isOK (type, nonValidatingPassed, validatingPassed); string message=""; if (_inverseResult) { isok = !isok; message = "The following test was FIXED:\n"; } if (isok) res.Success (); else { message += "type:"+type; message += " non-validating passed:"+nonValidatingPassed.ToString(); message += " validating passed:"+validatingPassed.ToString(); message += " description:"+_test.InnerText; res.Failure (message, _errorString); } }
protected internal override void ProcessNoException(TestCaseResult testResult) { testResult.Success(); }
public override void Run (TestCaseResult res) { try { Harness.RunSingleTest(_baseUrl, _testInfo); } catch (Exception e) { res.Failure(e.Message, null); return; } res.Success(); }