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 log-on-failure mode #22

Closed
wants to merge 4 commits into from
Closed

Conversation

binkley
Copy link
Contributor

@binkley binkley commented Nov 22, 2014

Add a new mode, log-on-failure. It should:

  • Continue appending to the saved log
  • Print to the original streams for failed tests
  • This is designed to improve developer convenience, keeping passing tests quiet and making failing tests noisy.

Rebased as suggested. I also squashed some commits to make it clearer what you are getting:

  • Commit binkley/system-rules@fb4c976 could be cherry-picked separately; it has PrintStreamLog extends TestWatcher rather than ExternalResource
  • Commit binkley/system-rules@cc86caf add log-on-failure mode, requiring previous commit to get at TestWatcher#failed(Throwable, Description).

Cheers,
--binkley

@binkley binkley mentioned this pull request Nov 22, 2014
/**
* Capture the writes to the stream. On test failure write to the original stream.
*/
LOG_ONLY_ON_FAILURE
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about LOG_AND_WRITE_TO_STREAM_ON_FAILURE_ONLY?

@stefanbirkner
Copy link
Owner

Looks fine. Just a few coding style issues.

@binkley
Copy link
Contributor Author

binkley commented Nov 26, 2014

Let's see how well the comment suggestions were applied with commit 7ba13ea,

@stefanbirkner
Copy link
Owner

@binkley Are you using the rule for verifying the log or do you simply mute System.out and System.err?

@binkley
Copy link
Contributor Author

binkley commented Mar 5, 2015

Sorry for long delay, job change & returning to US after working overseas.

I do verify log. Muting is nice to quiet Spring, but my real intent is to
check my own logging that it meets an Ops standard.

Cheers,
Brian

On Tue, Feb 17, 2015 at 5:18 PM, Stefan Birkner notifications@github.com
wrote:

@binkley https://github.com/binkley Are you using the rule for
verifying the log or do you simply mute System.out and System.err?


Reply to this email directly or view it on GitHub
#22 (comment)
.

@stefanbirkner stefanbirkner modified the milestones: 1.10.0, 1.9.0 Mar 5, 2015
@stefanbirkner
Copy link
Owner

If you verify the log, why do you need to print it to System.out or System.err in case of a failure?

@binkley
Copy link
Contributor Author

binkley commented Mar 6, 2015

Good question. For some cases I do want the output as well as the test
failure, perhaps it reflects a failure to structure the tests well.

For those tests where I just want to silence the output, not test it (I'm
looking at you Spring logging), I do want to see the output when the tests
fails. This is the case my request relates to. Apologies for not
recalling the full context when composing my previous reply.

Cheers,
Brian

On Thu, Mar 5, 2015 at 5:05 PM, Stefan Birkner notifications@github.com
wrote:

If you verify the log, why do you need to print it to System.out or
System.err in case of a failure?


Reply to this email directly or view it on GitHub
#22 (comment)
.

@stefanbirkner
Copy link
Owner

Would a few new rules muteSystemOut, muteSystemOutExceptOnFailure, muteSystemErr and muteSystemErrExceptOnFailure achieve your goal?

@binkley
Copy link
Contributor Author

binkley commented Mar 6, 2015

Yes, sir.

Cheers,
Brian

On Fri, Mar 6, 2015 at 12:34 PM, Stefan Birkner notifications@github.com
wrote:

Would a few new rules muteSystemOut, muteSystemOutExceptOnFailure,
muteSystemErr and muteSystemErrExceptOnFailure achieve your goal?


Reply to this email directly or view it on GitHub
#22 (comment)
.

@stefanbirkner
Copy link
Owner

Great :-)

stefanbirkner added a commit that referenced this pull request May 18, 2015
In case of a failed test it is sometimes helpful to see the output to
{@code System.err} and {@code System.out}. Therefore
{@code SystemErrRule} and {@code SystemOutRule} have a new method
{@code muteForSuccessfulTests().

    @rule
    public final SystemErrRule systemErrRule
            = new SystemErrRule().muteForSuccessfulTests();
    @rule
    public final SystemOutRule systemOutRule
            = new SystemOutRule().muteForSuccessfulTests();
stefanbirkner added a commit that referenced this pull request May 18, 2015
In case of a failed test it is sometimes helpful to see the output to
`System.errr` and `System.out`. Therefore `SystemErrRule` and
`SystemOutRule` have a new method `muteForSuccessfulTests()`.

    @rule
    public final SystemErrRule systemErrRule
            = new SystemErrRule().muteForSuccessfulTests();
    @rule
    public final SystemOutRule systemOutRule
            = new SystemOutRule().muteForSuccessfulTests();
stefanbirkner added a commit that referenced this pull request May 18, 2015
In case of a failed test it is sometimes helpful to see the output to
`System.errr` and `System.out`. Therefore `SystemErrRule` and
`SystemOutRule` have a new method `muteForSuccessfulTests()`.

    @rule
    public final SystemErrRule systemErrRule
            = new SystemErrRule().muteForSuccessfulTests();
    @rule
    public final SystemOutRule systemOutRule
            = new SystemOutRule().muteForSuccessfulTests();
stefanbirkner added a commit that referenced this pull request May 18, 2015
In case of a failed test it is sometimes helpful to see the output to
`System.errr` and `System.out`. Therefore `SystemErrRule` and
`SystemOutRule` have a new method `muteForSuccessfulTests()`.

    @rule
    public final SystemErrRule systemErrRule
            = new SystemErrRule().muteForSuccessfulTests();
    @rule
    public final SystemOutRule systemOutRule
            = new SystemOutRule().muteForSuccessfulTests();
stefanbirkner added a commit that referenced this pull request May 18, 2015
In case of a failed test it is sometimes helpful to see the output to
`System.errr` and `System.out`. Therefore `SystemErrRule` and
`SystemOutRule` have a new method `muteForSuccessfulTests()`.

    @rule
    public final SystemErrRule systemErrRule
            = new SystemErrRule().muteForSuccessfulTests();
    @rule
    public final SystemOutRule systemOutRule
            = new SystemOutRule().muteForSuccessfulTests();
stefanbirkner added a commit that referenced this pull request May 18, 2015
In case of a failed test it is sometimes helpful to see the output to
`System.errr` and `System.out`. Therefore `SystemErrRule` and
`SystemOutRule` have a new method `muteForSuccessfulTests()`.

    @rule
    public final SystemErrRule systemErrRule
            = new SystemErrRule().muteForSuccessfulTests();
    @rule
    public final SystemOutRule systemOutRule
            = new SystemOutRule().muteForSuccessfulTests();
stefanbirkner added a commit that referenced this pull request May 18, 2015
In case of a failed test it is sometimes helpful to see the output to
`System.errr` and `System.out`. Therefore `SystemErrRule` and
`SystemOutRule` have a new method `muteForSuccessfulTests()`.

    @rule
    public final SystemErrRule systemErrRule
            = new SystemErrRule().muteForSuccessfulTests();
    @rule
    public final SystemOutRule systemOutRule
            = new SystemOutRule().muteForSuccessfulTests();
stefanbirkner added a commit that referenced this pull request May 19, 2015
In case of a failed test it is sometimes helpful to see the output to
`System.errr` and `System.out`. Therefore `SystemErrRule` and
`SystemOutRule` have a new method `muteForSuccessfulTests()`.

    @rule
    public final SystemErrRule systemErrRule
            = new SystemErrRule().muteForSuccessfulTests();
    @rule
    public final SystemOutRule systemOutRule
            = new SystemOutRule().muteForSuccessfulTests();
stefanbirkner added a commit that referenced this pull request May 19, 2015
In case of a failed test it is sometimes helpful to see the output to
`System.errr` and `System.out`. Therefore `SystemErrRule` and
`SystemOutRule` have a new method `muteForSuccessfulTests()`.

    @rule
    public final SystemErrRule systemErrRule
            = new SystemErrRule().muteForSuccessfulTests();
    @rule
    public final SystemOutRule systemOutRule
            = new SystemOutRule().muteForSuccessfulTests();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants