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 Aug 25, 2014 · 13 revisions

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

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

@Attachment(name = "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 corresponding test case passed. This is done allure.report.remove.attachments system property. Simply set this property somewhere in tests code to PCRE regular expression and Allure will remove any attachment which name 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 system property allure.report.remove.attachments=.*\.png. To apply this setting globally you can put file named allure.properties in your classpath. See AllureConfig for existing properties list.