Class VisualTrialReporter

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

class VisualTrialReporter
  : ILifecycleListener
  , ITestCaseLifecycleListener;

Constructors

NameDescription
this ()

Methods

NameDescription
begin (suite, result)
end (__param_0)
update ()

Example

it should print "The Plan" at the beginning

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

writer.buffer.should.equal("\n\n");

Example

it should print the test location

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

auto test = new TestResult("other test");
test.fileName = "someFile.d";
test.line = 100;
test.labels = [ Label("name", "value"), Label("name1", "value1") ];
test.status = TestResult.Status.success;

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

writer.buffer.should.equal("BEGIN TEST;\n" ~
  "suite:some suite\n" ~
  "test:other test\n" ~
  "file:someFile.d\n" ~
  "line:100\n" ~
  `labels:[{ "name": "name", "value": "value" }, { "name": "name1", "value": "value1" }]` ~ "\n");

Example

it should print a sucess test

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

auto test = new TestResult("other test");
test.fileName = "someFile.d";
test.line = 100;
test.status = TestResult.Status.success;

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

writer.buffer.should.equal("status:success\nEND TEST;\n");

Example

it should print a failing test with a basic throwable

auto writer = new BufferedWriter;
auto reporter = new VisualTrialReporter(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("status:failure\n" ~
       "errorFile:file.d\n" ~
       "errorLine:42\n" ~
       "message:Test's failure\n" ~
       "error:object.Exception@file.d(42): Test's failure\n" ~
       "END TEST;\n");

Example

it should not print the YAML if the throwable is missing

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

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

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

writer.buffer.should.equal("status:failure\nEND TEST;\n");