Package io.cucumber.messages.types
Class Attachment
- java.lang.Object
-
- io.cucumber.messages.types.Attachment
-
public class Attachment extends Object
//// Attachments (parse errors, execution errors, screenshots, links...) * An attachment represents any kind of data associated with a line in a [Source](#io.cucumber.messages.Source) file. It can be used for: * Syntax errors during parse time * Screenshots captured and attached during execution * Logs captured and attached during execution It is not to be used for runtime errors raised/thrown during execution. This is captured in `TestResult`.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAttachment.ContentEncoding* Whether to interpret `body` "as-is" (IDENTITY) or if it needs to be Base64-decoded (BASE64).
-
Constructor Summary
Constructors Constructor Description Attachment()No args constructor for use in serializationAttachment(String body, Attachment.ContentEncoding contentEncoding, String fileName, String mediaType, Source source, String testCaseStartedId, String testStepId, String url)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object other)StringgetBody()* The body of the attachment.Attachment.ContentEncodinggetContentEncoding()* Whether to interpret `body` "as-is" (IDENTITY) or if it needs to be Base64-decoded (BASE64).StringgetFileName()* Suggested file name of the attachment.StringgetMediaType()* The media type of the data.SourcegetSource()//// Source * A source file, typically a Gherkin document or Java/Ruby/JavaScript source codeStringgetTestCaseStartedId()StringgetTestStepId()StringgetUrl()* A URL where the attachment can be retrieved.inthashCode()voidsetBody(String body)* The body of the attachment.voidsetContentEncoding(Attachment.ContentEncoding contentEncoding)* Whether to interpret `body` "as-is" (IDENTITY) or if it needs to be Base64-decoded (BASE64).voidsetFileName(String fileName)* Suggested file name of the attachment.voidsetMediaType(String mediaType)* The media type of the data.voidsetSource(Source source)//// Source * A source file, typically a Gherkin document or Java/Ruby/JavaScript source codevoidsetTestCaseStartedId(String testCaseStartedId)voidsetTestStepId(String testStepId)voidsetUrl(String url)* A URL where the attachment can be retrieved.StringtoString()
-
-
-
Constructor Detail
-
Attachment
public Attachment()
No args constructor for use in serialization
-
Attachment
public Attachment(String body, Attachment.ContentEncoding contentEncoding, String fileName, String mediaType, Source source, String testCaseStartedId, String testStepId, String url)
- Parameters:
fileName-contentEncoding-mediaType-source-body-testStepId-testCaseStartedId-url-
-
-
Method Detail
-
getBody
public String getBody()
* The body of the attachment. If `contentEncoding` is `IDENTITY`, the attachment is simply the string. If it's `BASE64`, the string should be Base64 decoded to obtain the attachment. (Required)
-
setBody
public void setBody(String body)
* The body of the attachment. If `contentEncoding` is `IDENTITY`, the attachment is simply the string. If it's `BASE64`, the string should be Base64 decoded to obtain the attachment. (Required)
-
getContentEncoding
public Attachment.ContentEncoding getContentEncoding()
* Whether to interpret `body` "as-is" (IDENTITY) or if it needs to be Base64-decoded (BASE64). Content encoding is *not* determined by the media type, but rather by the type of the object being attached: - string => IDENTITY - byte array => BASE64 - stream => BASE64 (Required)
-
setContentEncoding
public void setContentEncoding(Attachment.ContentEncoding contentEncoding)
* Whether to interpret `body` "as-is" (IDENTITY) or if it needs to be Base64-decoded (BASE64). Content encoding is *not* determined by the media type, but rather by the type of the object being attached: - string => IDENTITY - byte array => BASE64 - stream => BASE64 (Required)
-
getFileName
public String getFileName()
* Suggested file name of the attachment. (Provided by the user as an argument to `attach`)
-
setFileName
public void setFileName(String fileName)
* Suggested file name of the attachment. (Provided by the user as an argument to `attach`)
-
getMediaType
public String getMediaType()
* The media type of the data. This can be any valid [IANA Media Type](https://www.iana.org/assignments/media-types/media-types.xhtml) as well as Cucumber-specific media types such as `text/x.cucumber.gherkin+plain` and `text/x.cucumber.stacktrace+plain` (Required)
-
setMediaType
public void setMediaType(String mediaType)
* The media type of the data. This can be any valid [IANA Media Type](https://www.iana.org/assignments/media-types/media-types.xhtml) as well as Cucumber-specific media types such as `text/x.cucumber.gherkin+plain` and `text/x.cucumber.stacktrace+plain` (Required)
-
getSource
public Source getSource()
//// Source * A source file, typically a Gherkin document or Java/Ruby/JavaScript source code
-
setSource
public void setSource(Source source)
//// Source * A source file, typically a Gherkin document or Java/Ruby/JavaScript source code
-
getTestCaseStartedId
public String getTestCaseStartedId()
-
setTestCaseStartedId
public void setTestCaseStartedId(String testCaseStartedId)
-
getTestStepId
public String getTestStepId()
-
setTestStepId
public void setTestStepId(String testStepId)
-
getUrl
public String getUrl()
* A URL where the attachment can be retrieved. This field should not be set by Cucumber. It should be set by a program that reads a message stream and does the following for each Attachment message: - Writes the body (after base64 decoding if necessary) to a new file. - Sets `body` and `contentEncoding` to `null` - Writes out the new attachment message This will result in a smaller message stream, which can improve performance and reduce bandwidth of message consumers. It also makes it easier to process and download attachments separately from reports.
-
setUrl
public void setUrl(String url)
* A URL where the attachment can be retrieved. This field should not be set by Cucumber. It should be set by a program that reads a message stream and does the following for each Attachment message: - Writes the body (after base64 decoding if necessary) to a new file. - Sets `body` and `contentEncoding` to `null` - Writes out the new attachment message This will result in a smaller message stream, which can improve performance and reduce bandwidth of message consumers. It also makes it easier to process and download attachments separately from reports.
-
-