-
-
Notifications
You must be signed in to change notification settings - Fork 691
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
Handle output in json-formatter #894
Handle output in json-formatter #894
Conversation
@@ -8,6 +8,10 @@ Given('a passed {word} with text attachment {string}', function(word: string, at | |||
this.attach(attachmentText, 'text/plain') | |||
}) | |||
|
|||
Given('a step outputs:', function(txt: string) { | |||
this.attach(txt, 'text/output') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
text/output
is not a valid media type. It should be text/plain
. Alternatively, it should be an extension - I suggest text/x.cucumber.output+plain
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds fine, I was definitely not convinced by text/output
anyway, sounded too hacky :D
Note, I'm also wondering about a good way to implement this in various languages. From what I've seen, in Ruby, we define What I think should be pretty useful, would be to have, for each languages, two ways to add output:
For example, this could be: # cucumber-ruby message formatter
class MessageFormatter
def output(text)
# It's called embed in cucumber-ruby but let's forget it for now
attach(text, 'text/x.cucumber.output+plain')
end
def puts(text)
output(text)
end
end // cucumber-js message formatter
class MessageFormatter implements Formatter {
public output(text: string): void {
this.attach(text, 'text/x.cucumber.output+plain')
}
// .log as in console.log
public log(text: string): void {
this.output(text)
}
} // cucumber-jvm message formatter
class MessageFormatter {
public void output(String text) {
this.attach(text, "text/x.cucumber.output+plain")
}
// .println as in System.out.println
public void println(String text) {
this.output(text);
}
} |
The user isn't invoking the Let's discuss this on a call. |
See #897 |
…f "text/x.cucumber.output+plain")
Summary
JSON formatter currently does not handle
output
field in the generated json files. This field is populated in the steps by callingputs
(in Ruby, there must be equivalents elsewhere).The idea here is to use a specific attachment type (
text/output
) which won't end up in the attachments.Of course we should not ask the users to handle the output type themselves, but we should add this in the various cucumber flavours.
For example, in cucumber-ruby, we could have this the messages formatter:
I'm not 100% sure of the way to use attachments for output, so any better idea is more than welcome :)
Details
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: