Contents

init(_:named:as:sourceLocation:)

Initialize an instance of this type that encloses the given image.

Declaration

init<T>(_ image: T, named preferredName: String? = nil, as imageFormat: AttachableImageFormat? = nil, sourceLocation: SourceLocation = #_sourceLocation) where AttachableValue : _AttachableImageWrapper<T>, AttachableValue : AttachableWrapper, T : AttachableAsImage

Parameters

  • image:

    The value that will be attached to the output of the test run.

  • preferredName:

    The preferred name of the attachment when writing it to a test report or to disk. If nil, the testing library attempts to derive a reasonable filename for the attached value.

  • imageFormat:

    The image format with which to encode image.

  • sourceLocation:

    The source location of the call to this initializer. This value is used when recording issues associated with the attachment.

Discussion

The testing library uses the image format specified by imageFormat. Pass nil to let the testing library decide which image format to use. If you pass nil, then the image format that the testing library uses depends on the path extension you specify in preferredName, if any. If you do not specify a path extension, or if the path extension you specify doesn’t correspond to an image format the operating system knows how to write, the testing library selects an appropriate image format for you.

See Also

Attaching images to tests