Converts a test result to allure status
Return the string representation of the test
AllureTestXml should transform a test with steps
auto epoch = SysTime.fromUnixTime(0); TestResult result = new TestResult("Test"); result.begin = Clock.currTime; result.end = Clock.currTime; result.status = TestResult.Status.success; StepResult step = new StepResult(); step.name = "some step"; step.begin = result.begin; step.end = result.end; result.steps = [step, step]; auto allure = AllureTestXml("allure", result, ""); allure.toString.should.equal( ` <test-case start="` ~ (result.begin - epoch).total!"msecs".to!string ~ `" stop="` ~ (result.end - epoch).total!"msecs".to!string ~ `" status="passed"> <name>Test</name> <steps> <step start="` ~ (result.begin - epoch).total!"msecs".to!string ~ `" stop="` ~ (result.end - epoch).total!"msecs".to!string ~ `" status="passed"> <name>some step</name> </step> <step start="` ~ (result.begin - epoch).total!"msecs".to!string ~ `" stop="` ~ (result.end - epoch).total!"msecs".to!string ~ `" status="passed"> <name>some step</name> </step> </steps> </test-case>`);
AllureTestXml should transform a test with labels
auto epoch = SysTime.fromUnixTime(0); TestResult result = new TestResult("Test"); result.begin = Clock.currTime; result.end = Clock.currTime; result.status = TestResult.Status.success; result.labels ~= Label("status_details", "flaky"); auto allure = AllureTestXml("allure", result, ""); allure.toString.should.equal( ` <test-case start="` ~ (result.begin - epoch).total!"msecs".to!string ~ `" stop="` ~ (result.end - epoch).total!"msecs".to!string ~ `" status="passed"> <name>Test</name> <labels> <label name="status_details" value="flaky"/> </labels> </test-case>`);
AllureTestXml should add the attachments
string resource = buildPath(getcwd(), "some_text.txt"); std.file.write(resource, ""); auto uuid = randomUUID.toString; scope(exit) { if(exists(resource)) { remove(resource); } remove("allure/" ~ uuid ~ "/title.0.some_text.txt"); } auto epoch = SysTime.fromUnixTime(0); TestResult result = new TestResult("Test"); result.begin = Clock.currTime; result.end = Clock.currTime; result.status = TestResult.Status.success; result.attachments = [ Attachment("title", resource, "plain/text") ]; auto allure = AllureTestXml("allure", result, uuid); allure.toString.should.equal( ` <test-case start="` ~ (result.begin - epoch).total!"msecs".to!string ~ `" stop="` ~ (result.end - epoch).total!"msecs".to!string ~ `" status="passed"> <name>Test</name> <attachments> <attachment title="title" source="` ~ uuid ~ `/title.0.some_text.txt" type="plain/text" /> </attachments> </test-case>`);