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

puts in an After hook does not output anything #298

Closed
wants to merge 1 commit into from

Conversation

mattwynne
Copy link
Member

Per this stackoverflow answer

After do
  puts "hello"
end

does not actually write out anything. If there's another scenario in the file, the 1st scenario's After-hook output will appear in the 2nd scenario's flow.

I'm trying to write an After hook that will allow me to check why a scenario failed, and if it was a particular exception, output some useful text to tell the person how to get past it (which is unfortunately a manual step, but I'd like to be more friendly than a stack-trace).

@mattwynne
Copy link
Member

You need to use $stderr.puts

It's a long story :)

@petemounce
Copy link
Author

@mattwynne That outputs to the terminal, but not into the HTML report which is what I'd ideally like (but I guess can live without, given that TeamCity will pick up the terminal output).

I might change my approach, actually, and see if I can embed some files into the report. The specifics are that I'm writing some integration tests against AWS, and so the tests and the system-under-test both need correctly provisioned users to be able to run, and credentials. The provisioning can be automated, but not if the user running the tests doesn't at least themselves have an environment set up to have their own user. So I've captured the permissions policies into some JSON files and intend to output those if the tests fail for AWS::EC2::Errors::UnauthorizedOperation.

/cc @trevorrowe.

@mattwynne
Copy link
Member

OK. See cucumber/common#259 if you want some background on this.

I guess the fault is that we're sending the after_scenario message to the formatter too early (before the After hooks have been run). If someone wants to look into it, that's the place to start.

@pahari
Copy link

pahari commented Aug 14, 2013

Puts in After hook doesnt print in HTML report, $stderr.puts outputs to the terminal, but not into the HTML report , Is there a way where i can output a message into HTML file

@mattwynne
Copy link
Member

This will not be fixed until 2.0 is released.

@chrismdp chrismdp modified the milestone: 2.0 Mar 6, 2014
@mattwynne
Copy link
Member

Can you try this again with version 2.0.0.beta.2 ?

@mattwynne
Copy link
Member

Scratch that, it doesn't work yet - see the attached tests.

@brasmusson
Copy link
Contributor

This issue is now fixed (after v2.0.0.beta.3). For the HTML formatter #746 fixed the last problems.

@lock
Copy link

lock bot commented Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
@luke-hill luke-hill deleted the 298-printing-from-hooks-to-html-report branch March 20, 2019 09:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants