Skip to content
GitHub

Attachment

Attachment builder for adding files, screenshots, and logs to test reports.

Attaches the built attachment to the current test or step.

void attach()

Creates an attachment from a binary data buffer.

Attachment fromBinary(std::string_view name, std::string_view mimeType, const void* data, size_t size)

Parameters:

NameTypeDescription
namestd::string_viewThe name of the attachment.
mimeTypestd::string_viewThe MIME type of the attachment (e.g., “image/png”).
dataconst void*A pointer to the binary data.
sizesize_tThe size of the data in bytes.

Returns:

An Attachment object.

Creates an attachment from a file.

Attachment fromFile(std::string_view name, std::string_view filePath)

Parameters:

NameTypeDescription
namestd::string_viewThe name of the attachment.
filePathstd::string_viewThe path to the file. The MIME type will be detected automatically.

Returns:

An Attachment object.

Creates a plain text attachment.

Attachment fromText(std::string_view name, std::string_view content)

Parameters:

NameTypeDescription
namestd::string_viewThe name of the attachment.
contentstd::string_viewThe text content.

Returns:

An Attachment object.