/
TestDrivenListener.cs
60 lines (52 loc) · 1.49 KB
/
TestDrivenListener.cs
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
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using TestDriven.Framework;
namespace Fixie.TestDriven
{
public class TestDrivenListener : Listener
{
readonly ITestListener tdnet;
public TestDrivenListener(ITestListener tdnet)
{
this.tdnet = tdnet;
}
public void AssemblyStarted(Assembly assembly)
{
}
public void CasePassed(PassResult result)
{
var @case = result.Case;
tdnet.TestFinished(new TestResult
{
Name = @case.Name,
State = TestState.Passed
});
}
public void CaseFailed(FailResult result)
{
var @case = result.Case;
var exceptions = result.Exceptions;
tdnet.TestFinished(new TestResult
{
Name = @case.Name,
State = TestState.Failed,
Message = exceptions.First().GetType().FullName,
StackTrace = CompoundStackTrace(exceptions),
});
}
static string CompoundStackTrace(IEnumerable<Exception> exceptions)
{
using (var writer = new StringWriter())
{
writer.WriteCompoundStackTrace(exceptions);
return writer.ToString();
}
}
public void AssemblyCompleted(Assembly assembly, AssemblyResult result)
{
}
}
}