CleanCut / green

Green is a clean, colorful, fast python test runner.
MIT License
786 stars 74 forks source link

Support option to print test results after errors #178

Closed Ogaday closed 6 years ago

Ogaday commented 6 years ago

Sometimes when I have many failing tests I have to scroll a long way past errors to see the summary of passing and failing tests - it would be nice to choose to suppress stdout or stderr, or perhaps print the listing of passes and failures after stdout and stderr?

Ogaday commented 6 years ago

If I was pointed in the right direction, this is something I'd be happy to have a go at :+1:

CleanCut commented 6 years ago

The actual stdout/stderr emitted during a test can be captured and discarded with -q, --quiet-stdout. If you mean the traceback output from errors/failures, then they occur after the summary of results because each result summary line is output before the test runs colored white (partly so that if a crash in green itself occurs then you can see which test you were on, and partly so that if the test takes a long time to run then you know which test is running while you wait). Then after the test completes it is rewritten in the appropriate status color and letter code.

Tracebacks and stdout and stderr and skip information is collected as we go. Once all the tests are run, we then present the traceback, stdout, stderr, and skip information -- which is easy to rearrange or toggle in the code.

You could certainly start storing the summary information as we go along, and then output it again (or only) at the end. If you only output it at the end, you run the risk of a very large delay with no feedback about what is happening (a lot of people don't like that) and if anything goes wrong and green itself crashes, then you won't know where it was. I'm not sure that would be useful to many people. If you repeat the summary output at the end, I suppose some people may find it useful. But in many cases where there are hundreds or thousands of tests...you will still only see a fraction of your summary on your terminal at a time. Again, I am not certain that would be a generally useful feature.

Perhaps a more useful feature would be an option to disable outputting the tracebacks? You can already disable stderr/stdout. You can already disable skip output. If you could also disable error/failure tracebacks, then you would be left with the line-per-test output and the final count.

The per-test lines are initially output here and then re-written with the correct status code and color here

The error/failure tracebacks are output here.

If you wanted to add a new flag, you would do that here and here and here.

Also, it is worth mentioning that some people simply use the -f, --failfast option so that after any test fails the remainder of the run is aborted, and the one traceback is output. That way the bottom of the screen ends with the summary item that failed, one traceback, and the count line (assuming there were no skips/stdout/stderr or their output was suppressed).

Ogaday commented 6 years ago

Thank you very much, that's a very thorough response!

Perhaps a more useful feature would be an option to disable outputting the tracebacks?

I think you're right, this is the best way to go about it. I'll look into this over the next week or so, and if I have any questions, I'll post them here.

Thanks again!

CleanCut commented 6 years ago

I am going to close this issue, as it seems to be resolved. If you feel the issue needs to be reopened and discussed further, please go ahead!