public void RecordExceptionWithSiteCanHandleRecursivelyThrowingException() { var result = new TestCaseResult(new TestMethod(new MethodWrapper(typeof(UnexpectedExceptionTests), nameof(DummyMethod)))); var ex = RecordPossiblyDangerousException(() => result.RecordException(new RecursivelyThrowingException(), FailureSite.Test)); Assert.That(ex is null); // Careful not to pass ex to Assert.That and crash the test run rather than failing Assert.That(result, Has.Property("Message").StartWith( "NUnit.TestData.UnexpectedExceptionFixture.RecursivelyThrowingException : RecursivelyThrowingException was thrown by the Exception.Message property." + Environment.NewLine + "RecursivelyThrowingException was thrown by the Exception.Data property.")); Assert.That(result, Has.Property("StackTrace").EqualTo( "RecursivelyThrowingException was thrown by the Exception.StackTrace property.")); }
public void SetUp() { test = new TestMethod(typeof(DummySuite).GetMethod("DummyMethod")); test.Properties.Set(PropertyNames.Description, "Test description"); test.Properties.Add(PropertyNames.Category, "Dubious"); test.Properties.Set("Priority", "low"); testResult = (TestCaseResult)test.MakeTestResult(); TestSuite suite = new TestSuite(typeof(DummySuite)); suite.Properties.Set(PropertyNames.Description, "Suite description"); suite.Properties.Add(PropertyNames.Category, "Fast"); suite.Properties.Add("Value", 3); suiteResult = (TestSuiteResult)suite.MakeTestResult(); SimulateTestRun(); }
public void SetUp() { test = new TestMethod(typeof(DummySuite).GetMethod("DummyMethod")); test.Properties.Set(PropertyNames.Description, "Test description"); test.Properties.Add(PropertyNames.Category, "Dubious"); test.Properties.Set("Priority", "low"); testResult = (TestCaseResult)test.MakeTestResult(); TestSuite suite = new TestSuite(typeof(DummySuite)); suite.Properties.Set(PropertyNames.Description, "Suite description"); suite.Properties.Add(PropertyNames.Category, "Fast"); suite.Properties.Add("Value", 3); suiteResult = (TestSuiteResult)suite.MakeTestResult(); SimulateTestRun(); }
public void TestFinished_WithOutput() { var result = new TestCaseResult(Fakes.GetTestMethod(this, "MyFakeMethod")); result.OutWriter.WriteLine("First line of output"); result.OutWriter.WriteLine("Another line of output"); _textUI.TestFinished(result); Assert.That(GetReportLines(), Is.EqualTo(new string[] { "=> NUnitLite.Tests.TextUITests.MyFakeMethod", "First line of output", "Another line of output" })); }
public void TestFinished_NoOutput() { var result = new TestCaseResult(Fakes.GetTestMethod(this, "MyFakeMethod")); _textUI.TestFinished(result); Assert.That(Report, Is.EqualTo("")); }