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

RunTests.cs « nunit « mcs - github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e5369546900a73b0f835a2736cdc698955f42df9 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using System;
using System.IO;
using System.Threading;
using System.Globalization;

using NUnit.Framework;

namespace MonoTests {

public class MyTestRunner {

	static TextWriter fWriter = Console.Out;

	protected static TextWriter Writer {
		get { return fWriter; }
	}

	public static void Print(TestResult result) {
		PrintErrors(result);
		PrintFailures(result);
		PrintHeader(result);
	}

	/// <summary>Prints the errors to the standard output.</summary>
	public static void PrintErrors(TestResult result) {
		if (result.ErrorCount != 0) {
			if (result.ErrorCount == 1)
				Writer.WriteLine("There was "+result.ErrorCount+" error:");
			else
				Writer.WriteLine("There were "+result.ErrorCount+" errors:");
			
			int i= 1;
			foreach (TestFailure failure in result.Errors) {
				Writer.WriteLine(i++ + ") "+failure+"("+failure.ThrownException.GetType().ToString()+")");
				Writer.Write(failure.ThrownException);
			}
		}
	}

	/// <summary>Prints failures to the standard output.</summary>
	public static void PrintFailures(TestResult result) {
		if (result.FailureCount != 0) {
			if (result.FailureCount == 1)
				Writer.WriteLine("There was " + result.FailureCount + " failure:");
			else
				Writer.WriteLine("There were " + result.FailureCount + " failures:");
			int i = 1;
			foreach (TestFailure failure in result.Failures) {
				Writer.Write(i++ + ") " + failure.FailedTest);
				Exception t= failure.ThrownException;
				if (t.Message != "")
					Writer.WriteLine(" \"" + t.Message + "\"");
				else {
					Writer.WriteLine();
					Writer.Write(failure.ThrownException);
				}
			}
		}
	}

	/// <summary>Prints the header of the report.</summary>
	public static void PrintHeader(TestResult result) {
		if (result.WasSuccessful) {
			Writer.WriteLine();
			Writer.Write("OK");
			Writer.WriteLine (" (" + result.RunCount + " tests)");
			
		} else {
			Writer.WriteLine();
			Writer.WriteLine("FAILURES!!!");
			Writer.WriteLine("Tests Run: "+result.RunCount+ 
					 ", Failures: "+result.FailureCount+
					 ", Errors: "+result.ErrorCount);
		}
	}

}

}