Attachment

A struct representing an attachment for test steps

Members

Functions

toString
string toString()

Static functions

fromFile
Attachment fromFile(string name, string path, string mime)

Add a file to the current test or step

fromString
Attachment fromString(string content)

Create an attachment from a string

Static variables

destination
string destination;

The attachement destination. All the attached files will be copied in this folder if it is not allready inside

Variables

file
string file;

The absolute path to the attachment

mime
string mime;

The file mime path

name
string name;

The attachment name

Examples

Create an attachement from string

auto a = Attachment.fromString("content");
a.name.should.equal("unknown");
a.mime.should.equal("text/plain");

readText(a.file).should.equal("content");

Convert an attachement to Json string

Attachment("dub", "dub.json", "text/json").toString.should.equal(
  `{"name":"dub","file":"dub.json","mime":"text/json"}`
);

Meta