question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

All messages from EventListenerTextWriter goes to console output independent on stream name

See original GitHub issue

I want to put some hidden message from test to ITestEventListener extensions.

public void Test()
{
  (new NUnit.Framework.Internal.Execution.EventListenerTextWriter("DiagnosticStream", System.IO.TextWriter.Null)).WriteLine("This is message from custom stream");
}

But this message also goes to console output. Is there some way to accomplish my needs?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:33 (21 by maintainers)

github_iconTop GitHub Comments

1reaction
CharliePoolecommented, Sep 8, 2018

If I were doing this, I would model it after TextOutput, but I would not use TextOutput.

[Reasons for not using TextOutput:

  1. TextOutput is for outputting text. Adding some special arg to text output to indicate it is not really text output confuses the API for the majority of users, merely to make this easy to implement.
  2. Duplicating the logic in TextOutput in another class is a very small duplication and it may not remain a duplication as the feature evolves because the purpose of a feature is what drives (or should drive) change.]

Anyway, I would create the following pieces:

  1. Define a new xml element to represent the message. I would have this reviewed by the team before implementing since it’s the most important piece.

  2. A way to create this message: probably a new constructor or a property of EventListenerTextWriter that specifies a different XML element to use.

  3. A mechanism to send a message to a particular extension or other engine component. For example TestContext.SendMessage(string destination, string message);

Provided we are not handling the messages in the engine itself, but only in extensions, no more is needed. All NUnit components will ignore the new XML element.

Again… the first piece is the critical one and it will go easier if it’s reviewed first as a design element. The rest can be handled through code review.

0reactions
jnm2commented, Feb 20, 2019

Closed by https://github.com/nunit/nunit/pull/3018. Thanks, Nikolay!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Console and Engine Release Notes
Cecil to latest; 433 All messages from EventListenerTextWriter goes to console output independent on stream name; 454 Misc improvements to ...
Read more >
c# - How to get the text sent to console output in an event ...
SetOut(new StreamWriter(progressStream)); Then use the events of the progress stream to see when it is written to.
Read more >
Creating Trace Listeners in .Net - Bryan Soliman Blog
The purpose of a listener is to collect, store, and route tracing messages. Listeners direct the tracing output to an appropriate target, such ......
Read more >
Create and Initialize Trace Listeners - .NET Framework
Learn how to create and initialize trace listeners by using classes such as System.Diagnostics.DefaultTraceListener in .NET.
Read more >
Chocolatey Software | NUnit 3 Console Runner 3.10.0
Chocolatey is software management automation for Windows that wraps installers, executables, zips, and scripts into compiled packages.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found