Skip to content

New API for global errors and attachments#650

Merged
delatrie merged 2 commits into
mainfrom
feat/runtime-api-globals
Apr 24, 2026
Merged

New API for global errors and attachments#650
delatrie merged 2 commits into
mainfrom
feat/runtime-api-globals

Conversation

@delatrie

Copy link
Copy Markdown
Contributor

Context

Allure Report 3.2.0 has introduced global attachments and errors: report-wide information that is not tied to a particular test.

This PR extends the Allure API to allow producing global errors and attachments at runtime.

API changes

1. New AddGlobalAttachment function (3 overloads):

  • AddGlobalAttachment(string name, string type, string path)
  • AddGlobalAttachment(string name, string type, byte[] content, string fileExtension = "")
  • AddGlobalAttachment(string path, string? name = null)

Examples:

AllureApi.AddGlobalAttachment("machine-log", "text/plain", logBytes, ".log");
AllureApi.AddGlobalAttachment("machine-log", "text/plain", logFilePath);

2. New AddGlobalError function (3 overloads):

  • AddGlobalError(Exception error)
  • AddGlobalError(string message)
  • AddGlobalError(StatusDetails statusDetails)

Examples:

try
{
    // ...
}
catch (Exception e)
{
    AllureApi.AddGlobalError(e);
}
AllureApi.AddGlobalError("A critical error has occured. The test process will be terminated");
AllureApi.AddGlobalError(new StatusDetails
{
    message = "Global teardown failed",
    trace = "System.InvalidOperationException: teardown failure\n   at Demo.Teardown()",
});

3. New Global property for [AllureAttachment] and [AllureAttachmentFile]

  • bool Global { get; init; }

If set to true, emits a global attachment instead of a test/step/fixture-scoped one. Global attachments don't require a test or fixture to run.

Examples:

[AllureAttachment(Global = true)]
public static string DumpState() => "state";
[AllureAttachmentFile(Global = true)]
public static FileInfo ExportArtifact() => new FileInfo("artifact.zip");

Checklist

@delatrie delatrie changed the title feat(commons): add global errors and attachments Extend the Allure API to support global errors and attachments Apr 23, 2026
@delatrie delatrie changed the title Extend the Allure API to support global errors and attachments New API for global errors and attachments Apr 23, 2026
@delatrie delatrie merged commit 14e8990 into main Apr 24, 2026
7 checks passed
@delatrie delatrie deleted the feat/runtime-api-globals branch April 24, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants