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

Add option to silence the output to console while test run #556

Closed
pinpox opened this issue Jun 23, 2015 · 3 comments
Closed

Add option to silence the output to console while test run #556

pinpox opened this issue Jun 23, 2015 · 3 comments
Assignees

Comments

@pinpox
Copy link

pinpox commented Jun 23, 2015

Im using this quite a lot:

  def silence_output
    # Store the original stderr and stdout in order to restore them later
    @original_stderr = $stderr
    @original_stdout = $stdout

    # Redirect stderr and stdout
    $stderr = File.new("out.txt", 'w')
    $stdout = File.new("out.txt", 'w')
  end

  # Replace stderr and stdout so anything else is output correctly
  def enable_output
    $stderr = @original_stderr
    $stdout = @original_stdout
    @original_stderr = nil
    @original_stdout = nil
  end

  def teardown
    enable_output
  end

  def setup
    silence_output
  end

It would be nice to have an option that does the same thing without having to add those methods.

@zenspider
Copy link
Collaborator

This doesn't need to be a part of minitest. Instead, it can be packaged as a plugin gem. I'm happy to help you get this packaged up into gem form.

Also, it should use the before/after_setup/teardown hooks.

@zenspider zenspider self-assigned this Jun 25, 2015
@zenspider
Copy link
Collaborator

Please close this if you think it has been resolved.

@zenspider
Copy link
Collaborator

No response. Closing.

@minitest minitest locked and limited conversation to collaborators May 17, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants