Skip to content
This repository has been archived by the owner on Jan 14, 2019. It is now read-only.

Attachments

Ivan Krutov edited this page Sep 23, 2014 · 13 revisions

An attachment in Java code is simply a method annotated with @Attachment that returns either a String or byte array, which should be added to the report:

@Attachment
public String performedActions(ActionSequence actionSequence) {
    return actionSequence.toString();
}

@Attachment(value = "Page screenshot", type = "image/png")
public byte[] saveScreenshot(byte[] screenShot) {
    return screenShot;
}

Removing attachments for passed test cases

In order to economize free disk space, you can remove attachments if the corresponding test case passed. To do this, use the allure.report.remove.attachments system property. Simply set this property somewhere in the test code to a PCRE regular expression, and Allure will remove any attachment with a name that matches this regular expression. For example, if your test saves a lot of PNG screenshots and you don't want to store them for passed cases, set the system property allure.report.remove.attachments=.*\.png. To apply this setting globally, you can put a file named allure.properties in your classpath. See AllureConfig for a list of existing properties.

Placeholders

Attachment name supports the same placeholders as steps do.