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

Ad-hoc Test Runner: Debug.WriteLine in .NET 5/Core doesn't write to Output window #156

Open
duncansmart opened this issue Mar 11, 2021 · 0 comments

Comments

@duncansmart
Copy link

Using the ad-hoc test runner in .NET 4.x and earlier, doing a Debug.WriteLine outputs the messages to the Output window. In .NET 5 (and Core) this isn't the case. A workaround is to add Trace.Listeners.Add(new ConsoleTraceListener()) to my code somewhere every time I write an ad-hoc test, but this is a bit of a faff.

🙏 Could a console TraceListener be added to Trace.Listeners in TestDriven.NetCore.AdHoc.dll instead of me having to do it manually each time?

I've decompiled TestDriven.NetCore.AdHoc.dll and added the following code to Program.Main and replaced it:

public static int Main(string[] args)
{
    Trace.Listeners.Add(new ConsoleTraceListener());
    ...
}

class ConsoleTraceListener : TraceListener
{
    public override void Write(string message) => Console.Write(message);
    public override void WriteLine(string message) => Console.WriteLine(message);
}

And it now works as it does under .NET 4.x

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

No branches or pull requests

1 participant