Class TapReporter

This reporter will print the results using thr Test anything protocol version 13

class TapReporter
  : ILifecycleListener
  , ITestCaseLifecycleListener ;

Constructors

NameDescription
this ()

Methods

NameDescription
begin (_param_0, _param_1)
end (_param_0)
update ()

Example

it should print "The Plan" at the beginning

auto writer = new BufferedWriter;
auto reporter = new TapReporter(writer);
reporter.begin(10);

writer.buffer.should.equal("TAP version 13\n1..10\n");

Example

it should print a sucess test

auto writer = new BufferedWriter;
auto reporter = new TapReporter(writer);

auto test = new TestResult("other test");
test.status = TestResult.Status.success;

reporter.end("some suite", test);

writer.buffer.should.equal("ok - some suite.other test\n");

Example

it should print a failing test with a basic throwable

auto writer = new BufferedWriter;
auto reporter = new TapReporter(writer);

auto test = new TestResult("other's test");
test.status = TestResult.Status.failure;
test.throwable = new Exception("Test's failure", "file.d", 42);

reporter.end("some suite", test);

writer.buffer.should.equal("not ok - some suite.other's test\n" ~
"  ---\n" ~
"  message: 'Test\'s failure'\n" ~
"  severity: failure\n" ~
"  location:\n" ~
"    fileName: 'file.d'\n" ~
"    line: 42\n\n");

Example

it should not print the YAML if the throwable is missing

auto writer = new BufferedWriter;
auto reporter = new TapReporter(writer);

auto test = new TestResult("other's test");
test.status = TestResult.Status.failure;

reporter.end("some suite", test);

writer.buffer.should.equal("not ok - some suite.other's test\n");

Example

it should print the results of a TestException

IResult[] results = [
  cast(IResult) new MessageResult("message"),
  cast(IResult) new ExtraMissingResult("a", "b") ];

auto exception = new TestException(results, "unknown", 0);

auto writer = new BufferedWriter;
auto reporter = new TapReporter(writer);

auto test = new TestResult("other's test");
test.status = TestResult.Status.failure;
test.throwable = exception;

reporter.end("some suite", test);

writer.buffer.should.equal("not ok - some suite.other's test\n" ~
"# message\n" ~
"# \n" ~
"#     Extra:a\n" ~
"#   Missing:b\n" ~
"# \n" ~
"  ---\n" ~
"  message: 'message'\n" ~
"  severity: failure\n" ~
"  location:\n" ~
"    fileName: 'unknown'\n" ~
"    line: 0\n\n");