allure-framework / allure-js-commons

Deprecated, use https://github.com/allure-framework/allure-js instead
Other
27 stars 40 forks source link

Feature request: addAttachement should prefix filename with attachmentName #47

Closed thernstig closed 1 year ago

thernstig commented 3 years ago

I try to add an attachment like this:

addAttachment('screenshotASD', screenshot, 'image/png');

But the attachment name does not get the name screenshotASD anywhere in it. Rather it ends up being called 5c426ded-e834-4cf5-a43e-053a3cfc68d5-attachment.png.

just-boris commented 3 years ago

The attachment name is displayed in the Report UI. However filenames are always UUID to prevent collisions where you run multiple tests in parallel.

thernstig commented 3 years ago

@just-boris I can understand the UUID, but I would like to add a name so I can tie it to a test case name, for the cases where uses quickly open the file from disk. So it would be nice to be able to prepend the name with something.

just-boris commented 3 years ago

I would take this as a feature request, not a bug report.

There is also a related open PR: https://github.com/allure-framework/allure-js-commons/pull/46, but I am currently not in the position to promise when it is going to be merged, if ever.

P.S. you could help by providing a more detailed description of your use-case and why it is important for you. "would be nice to..." is not a strong enough justification for doing this

baev commented 3 years ago

In order to make it work: 1) remove all "bad" characters from specified name 2) add unique suffix 3) trim the file name up to 255 characters 4) you'll still will have troubles finding corresponding attachments as your test prefix would be the same for parameterised test cases/test cases with name longer than 200 chars (as we'll reserve 55 for UUID + 'attachment.{ext}' suffix).

From my point of view I rather not provide such a feature to our users because it's only usable for small local runs. And from the other side it'll increase overall complexity. In addition, we have requirement to reduce the number of files generated by allure, and at some point we can consider make allure-results binary (gzip/protobuf)

thernstig commented 3 years ago

I am not sure that "only usable for small local runs" is entirely true. I'd say the majority of times I want to check a screenshot I run it locally. In addition, even if it exists in CI, downloading the attached screenshot for a suite or test case is not uncommon to send along in emails and or/add to bug reports. The name in the filename is then quite helpful.

I updated the topic to reflect this is a feature request.