Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for attachments / embeddings as per Cucumber and Behave #617

Open
Johnlon opened this issue Apr 29, 2024 · 10 comments
Open

Support for attachments / embeddings as per Cucumber and Behave #617

Johnlon opened this issue Apr 29, 2024 · 10 comments
Labels
⚡ enhancement Request for new functionality

Comments

@Johnlon
Copy link
Member

Johnlon commented Apr 29, 2024

🤔 What's the problem you're trying to solve?

In cucumber the Scenario class provides a means to attach(bytes, mediatype, name) but we can't see the same capability in godog.
How do we add typed attachments to the output report file?

✨ What's your proposed solution?

Add the necessary API and docs

⛏ Have you considered any alternatives or workarounds?

None known

📚 Any additional context?

No response

@Johnlon Johnlon added the ⚡ enhancement Request for new functionality label Apr 29, 2024
@Johnlon Johnlon changed the title Support for attachments / embeddings as per Cucumber JVM and Behave Support for attachments / embeddings as per Cucumber and Behave Apr 29, 2024
@vearutop
Copy link
Member

vearutop commented May 2, 2024

@Johnlon I'd be happy to spend some time on that, perhaps you can help by providing some more expectations.

It would be very helpful to see an example report (in cucumber JSON "messages" format?) that does what you need (has attachments where they can be defined) in standard-compliant format.

@Johnlon
Copy link
Member Author

Johnlon commented May 2, 2024

Hi take a look at cucumber JVM JSON report output.....
It has this at the step level ...

"embeddings" [
{
"data" : "string of base 64 data",
"mine_type" : "string",
"name": "string"
}
];

In the JVM api see the api like .. Scenario.attach(name, mimetype, data)

The newer "messages" format in Cucumber JVM has the EmbedEvent which also represents this data.

Additionally the new Cucumber HTML formatter (Cucumber React) consumes these embedding messages and displays them correctly.


Re the attach API ..

The same kind of thing is in the main branch of Behave but because Behave looks like it's dying (ie it doesn't make prod releases anymore, 7 years) then I guess folk build their own dist of Behave containing that feature.

@Johnlon
Copy link
Member Author

Johnlon commented May 2, 2024

The cuke json schema isnt maintained ... cucumber/cucumber-json-schema#6 but the cuke JVM tools and the Behave patches populate the JSON report with the embeddings I mentioned.

In the messages format the ndjson file format has an object "attachment".
cucumber/messages java defines Attachement.java pregenerated and checked in.
messages go has messages.go containing "Attachment"

@vearutop
Copy link
Member

vearutop commented May 2, 2024

I think this https://github.com/cucumber/messages (json schema) is the current main reporting format (and it is used in godog internally).

What I'm interested in is a full example file that exhibits variable attachments in different places (also if possible the case of multiple attachments per step result), because I'm not super fluent in these semantics and where attachments should be applicable and how the relation is built.

@vearutop
Copy link
Member

vearutop commented May 2, 2024

From the implementation perspective I think we can introduce something like ctx := godog.AddAttachment(ctx, attachment) and then catch that information between the steps.

@Johnlon
Copy link
Member Author

Johnlon commented May 2, 2024

From the implementation perspective I think we can introduce something like ctx := godog.AddAttachment(ctx, attachment) and then catch that information between the steps.

Steps may add multiple attachments.
I can't recall if hooks can also do it but I'm pretty sure they can.

There is a cucumber compatibility kit that would help I suspect make the Json report compatible.

--

I already started looking myself.

I'm looking at godog and various tickets in he backlog and wondering if a much more severe treatment of godog is needed to move it forward, a treatment that would probably allow for attachments along the way. But it might mean forking it (at least for a bit) to make my life easier.

Why don't you also kick the wheels on a fix and we can compare notes when either of us have anything to show for it.

@Johnlon
Copy link
Member Author

Johnlon commented May 2, 2024

I think this https://github.com/cucumber/messages (json schema) is the current main reporting format (and it is used in godog internally).

I don't think that's right. On some other ticket I wrote up this problem. The ticket where aslak is saying we should use the "message" format.

Some events in godog aren't in that module and the ones that have similar names have different properties.
I could be wrong but take a look. My recollection is that it is miles off.

@Johnlon
Copy link
Member Author

Johnlon commented May 2, 2024

Re my previous comment. This is why I think that godog possibly needs more radical work

Likely support for messages #341 would require a solution for attachments as attachments are part of the model.

@Johnlon
Copy link
Member Author

Johnlon commented May 9, 2024

I've had a go at it myself here : #623

Something strange about the coverage - stuff I've not touched being reported and lines I know are tested aren't being counted?

@Johnlon
Copy link
Member Author

Johnlon commented Oct 11, 2024

will close when released

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚡ enhancement Request for new functionality
Projects
None yet
Development

No branches or pull requests

2 participants