nunit-console icon indicating copy to clipboard operation
nunit-console copied to clipboard

Remove some sections from console output

Open sixeyes opened this issue 4 years ago • 8 comments

Is there any way to turn off various parts reported when running the nunit3-console.exe (v3.12)?

I already have --noheader but that doesn't reduce it by much.

Currently I'm seeing:

Runtime Environment
   OS Version: Microsoft Windows 10.0.19042
  Runtime: .NET Core 3.1.14

Test Files
   relative path to assembly containing tests.dll


Run Settings
    DisposeRunners: True
    WorkDirectory: Absolute path for current directory
    NumberOfTestWorkers: 6

Test Run Summary
  Overall result: Passed
  Test Count: 8, Passed: 8, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 0
  Start time: 2021-04-20 15:52:40Z
    End time: 2021-04-20 15:52:41Z
    Duration: 0.389 seconds

Ideally I like to see Test Run Summary section but remove the others. I'd also want the error messages when tests are failing.

This seems to have been discussed 5 years ago here in an archived repo: https://github.com/nunit/dotnet-test-nunit/issues/78

sixeyes avatar Apr 20 '21 16:04 sixeyes

There are basically two questions we need to ask our selves here:

  1. What should be the default output?
  2. What tailoring should be made available?

I would argue that the current output is the best default because it gives info that helps debug problems when they occur. I am often able to answer a user question simply by looking at the output they include in it. OTOH, if certain output only appeared when requested, many of those users who most need help would be unlikely to discover the options.

As for tailoring, I'm for it. :smile: I would favor some kind of overall numeric or enum level as opposed to individual booleans for each section of the output. We would define the levels and then decide what output belongs in each.

CharliePoole avatar Apr 20 '21 18:04 CharliePoole

Good point here I think. What I'm thinking - do we need a detailed level of configuration here, or just to make the short version shorter?

How about making --noheader just show the below? It perhaps changes the meaning slightly, but I think the intent is the same.

Test Files
   relative path to assembly containing tests.dll

Test Run Summary
  Overall result: Passed
  Test Count: 8, Passed: 8, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 0
  Start time: 2021-04-20 15:52:40Z
    End time: 2021-04-20 15:52:41Z
    Duration: 0.389 seconds

@sixeyes - if we can agree on a format, is this something you'd be interested in contributing?

ChrisMaddock avatar Apr 25 '21 17:04 ChrisMaddock

Sorry for the delay in replying.

If there's an option for a "REALLY" slimmed down option I'd be interested. Never worked on an open source project before so would need guidance too.

I'm really just after the Test Count line

sixeyes avatar May 11 '21 10:05 sixeyes

We can definitely help with the guidance. 🙂

Can you clarify exactly what you're trying to do here - why do you want this feature? I'm wondering if there might be a better solution here with the engine extensibility, e.g. a simple TestEventListener extension.

ChrisMaddock avatar May 16 '21 20:05 ChrisMaddock

I'm using nunit-console to run my tests. I'm after all the error text (if any test fails), or a 1 line message if the tests all pass. I couldn't think of an easy way to do this with findstr, so I was hoping to restrict the large amount of text that is generated when NUnit passes all the tests.

I appreciate that the text has value for debugging user issues but I'd like to minimise the output (unless I have broken tests). Assuming the tests don't fail I'd like to see when I've run my tests, how many there were etc, without having to scroll back through the console prompt.

sixeyes avatar May 17 '21 17:05 sixeyes

Here's a suggested mitigation of the problem. If there are errors, they list before the Run Settings, which means you have to scroll back farther to see your errors. We did it that way because some of the settings are not finalized until after your test runs. However, that doesn't mean we have to print things in that order. Perhaps Run Settings should be before the test output?

@sixeyes This doesn't solve your problem entirely, of course. If you're interested in working on a PR, can you suggest what sort of option(s) you would want to provide? The idea is to avoid your spending time coding before knowing what sort of approach would be acceptable.

My own preference is for a single setting with no more than two or three levels. Numeric settings probably won't work, since people are used to the default being 0, i.e. the least output. Maybe an enum with options Minimal, Normal and Verbose?

CharliePoole avatar May 17 '21 18:05 CharliePoole

Given the example from Chris earlier, for 0 (Minimal) I'd like

Test Count: 8, Passed: 8, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 0. Duration: 0.389 seconds

I assume 2 (Verbose) would produce the current output. As for any other options, I'm open to suggestions

sixeyes avatar May 21 '21 12:05 sixeyes

@sixeyes Because you indicated you are willing to do a PR, I think we were waiting for you to suggest something... My last post was intended as a suggestion to you in coming up with what you'd like to do.

If you are going to do a PR, it will have include two main code changes... (1) accepting a new option with specific allowed values and (2) acting on the supplied option when presenting the report. The second bit could include all three levels of reporting, but doesn't have to. You could just implement Minimal and leave the rest to somebody else to finish.

Short answer, just let us know what you'd like to do and how we can help you do a PR. Lots of suggestions will undoubtedly come up during the review of the PR. :smiling_imp:

CharliePoole avatar May 21 '21 14:05 CharliePoole