namespace NUnit.Framework { using System; using System.Diagnostics; using System.IO; using System.Text; /// /// A TestFailure collects a failed test together with /// the caught exception. /// /// public class TestFailure : MarshalByRefObject { private readonly ITest fFailedTest; private readonly Exception fThrownException; /// /// Constructs a TestFailure with the given test and exception. /// public TestFailure(ITest theFailedTest, Exception theThrownException) { if(theFailedTest==null) throw new ArgumentNullException("theFailedTest"); if(theThrownException==null) throw new ArgumentNullException("theThrownException"); this.fFailedTest = theFailedTest; this.fThrownException = theThrownException; } /// Gets the failed test. public ITest FailedTest { get { return this.fFailedTest; } } /// True if it's a failure, false if error. public bool IsFailure { get { return this.fThrownException is AssertionFailedError; } } /// Gets the thrown exception. public Exception ThrownException { get { return this.fThrownException; } } /// Returns a short description of the failure. public override string ToString() { return this.fFailedTest + ": " + this.fThrownException.Message; } } }