feat(attachments): attach logs, HAR files, videos, traces and HTML to tests - #36
Merged
Merged
Conversation
… tests
Adds reporter methods that upload a file against the current build and add
it to the current test or to its last step:
- attachFile(File), attachFile(File, fileName) and attachData(byte[],
fileName) for the whole test (video, trace, HAR, console log)
- attachFileToLastStep / attachDataToLastStep for the most recent step
(e.g. driver.getPageSource() as page.html right after a fail())
Uploads are synchronous and only need the build id, so they work in batch
mode too. A failed upload throws an Error, the same as storeScreenshot.
AnglesReporterEmpty implements them as no-ops.
Also adds AttachmentRequests (POST /build/{buildId}/attachment), a
TestAttachment model, and `attachments` on CreateExecution, Execution and
Step. Needs an Angles server with test attachment support (AnglesHQ/angles,
same branch name).
Fixes BaseRequests.getDefaultErrorMessage, which threw a
NullPointerException for an error body without a "message" field (upload
rejections answer {"error": ...}) and tried to read the response body twice.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KgQXSUjuLVXmLWxobnMfSf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds reporter methods that upload a file against the current build and attach it to the current test, or to its last step:
Interface:
AnglesReporterInterfacegains six methods:attachFile(File)andattachFile(File, fileName)attachData(byte[], fileName)attachFileToLastStep(File)andattachFileToLastStep(File, fileName)attachDataToLastStep(byte[], fileName)AnglesReporterEmptyimplements them as no-ops.Behaviour: uploads are synchronous and only need the build id, so they work in batch mode. A failed upload throws an
Error, the same asstoreScreenshot.New classes:
AttachmentRequests(POST /build/{buildId}/attachment, from a file or a byte array) and theTestAttachmentmodel.Model fields:
attachmentsonCreateExecution,ExecutionandStep.Step.attachmentsis null until used, so Gson leaves it out of requests for steps without attachments.README: new Attachments section.
Fix
BaseRequests.getDefaultErrorMessagethrew aNullPointerExceptionfor any error body without a"message"field. Upload rejections answer{"error": ...}, as the existing manual-attachment upload already does. It also tried to read the response body a second time in its fallback. It now reads the body once and usesmessage, thenerror, then the raw text.Depends on
AnglesHQ/angles#133 (the API).
Testing
mvn -DskipTests -Dgpg.skip=true installbuilds every module..exeis rejected with the server's message (this is what found thegetDefaultErrorMessageNPE)🤖 Generated with Claude Code
https://claude.ai/code/session_01KgQXSUjuLVXmLWxobnMfSf
Generated by Claude Code