Welcome to mirror list, hosted at ThFree Co, Russian Federation.

TestFailure.cs « NUnitCore « src « nunit « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 4dad5bd02bd049919eae79a6673fe4b4da69b130 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
namespace NUnit.Framework 
{
	using System;
	using System.Diagnostics;
	using System.IO;
	using System.Text;
  
	/// <summary>
	/// A <c>TestFailure</c> collects a failed test together with
	/// the caught exception.
	/// </summary>
	/// <seealso cref="TestResult"/>
	public class TestFailure : MarshalByRefObject
	{
		private readonly ITest fFailedTest;
		private readonly Exception fThrownException;

		/// <summary>
		/// Constructs a TestFailure with the given test and exception.
		/// </summary>
		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;
		}

		/// <value>Gets the failed test.</value>
		public ITest FailedTest
		{ 
			get { return this.fFailedTest; }
		}

		/// <value>True if it's a failure, false if error.</value>
		public bool IsFailure 
		{
			get { return this.fThrownException is AssertionFailedError; }
		}

		/// <value>Gets the thrown exception.</value>
		public Exception ThrownException 
		{
			get { return this.fThrownException; }
		}

		/// <summary>Returns a short description of the failure.</summary>
		public override string ToString() 
		{
			return this.fFailedTest + ": " + this.fThrownException.Message;
		}
	}
}