Class AttachmentReporter
java.lang.Object
com.shaft.tools.io.internal.AttachmentReporter
Internal utility class responsible for attaching test artifacts (screenshots, recordings,
GIFs, data files, page snapshots, etc.) to the Allure report and optionally to ReportPortal.
Attachment routing is driven by the attachmentType / attachmentName strings
using a LinkedHashMap of named handlers registered in the static initialiser.
New content types can be supported by adding entries to attachmentHandlers.
This class is not intended for direct use in test code; it is invoked by
ReportManagerHelper.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidattachBasedOnFileType(String attachmentType, String attachmentName, ByteArrayOutputStream attachmentContent, String attachmentDescription) Attaches the given content to the Allure report (and ReportPortal if enabled), automatically selecting the correct MIME type and file extension based on the attachment type and name strings.
-
Method Details
-
attachBasedOnFileType
public static void attachBasedOnFileType(String attachmentType, String attachmentName, ByteArrayOutputStream attachmentContent, String attachmentDescription) Attaches the given content to the Allure report (and ReportPortal if enabled), automatically selecting the correct MIME type and file extension based on the attachment type and name strings.The
attachmentTypestring is matched (case-insensitively) against known keywords such as"screenshot","gif","json","xml", etc. For unrecognised types the"default"handler is used, which attaches the raw bytes without a declared MIME type.Example:
AttachmentReporter.attachBasedOnFileType( "screenshot", "Home page screenshot", screenshotOutputStream, "Screenshot after login" );- Parameters:
attachmentType- a string describing the content category (e.g."screenshot","json","page snapshot")attachmentName- the file or data name, also inspected for type inference (e.g."response.xml")attachmentContent- the raw content to attach as aByteArrayOutputStreamattachmentDescription- the human-readable label shown in the Allure report attachment panel
-