-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Console Output in Unit Tests #27561
Comments
From within a corefx unit test you should definitely be able to use Console.WriteLine. If you mean using it within the product code in System.Net.Sockets, you could do something like: #pragma warning disable BCL0015
[DllImport("msvcrt")]
private static extern int printf(string format, string arg);
private static void WriteLine(string s) => printf("%s\r\n", s); on Windows, or: #pragma warning disable BCL0015
[DllImport("libc")]
private static extern int printf(string format, string arg);
private static void WriteLine(string s) => printf("%s\n", s); on Unix. Or you could locally/temporarily modify https://github.com/dotnet/corefx/blob/d6646295b889daf9cf46caae1f9097b719873439/src/System.Net.Sockets/src/System.Net.Sockets.csproj#L382-L402 to include System.Console and then just use Console.WriteLine. |
What's the test btw? Is it some existing test that's failing for you without any changes to System.Net.Sockets? |
Thanks I'll try that, it's this test: https://mc.dot.net/#/user/nbaztec/pr~2Fjenkins~2Fdotnet~2Fcorefx~2Fmaster~2F/test~2Ffunctional~2Fcli~2F/da29f1b45f466d29d0049f0c02535bb1a668fbde/workItem/System.Net.Sockets.Tests basically I need to see the output of DNS resolution since all the other assertions are passing. |
Sadly I still couldn't get the console output after adding |
I see output like:
in those logs... what's not working? |
I see, interestingly all the log outputs are missing from |
That's .NET Framework. If your project doesn't have a netfx configuration it will just run the official assembly from the GAC. Therefore your changes and outputs are not run. |
Interesting, I guessed so but wasn't sure. I don't think I will be able to patch this bug it the original GAC, as such what might be the potential solutions - we can take this discussion to dotnet/corefx#32504 since the originnal answer is sufficient, just my code is never executed. This bug is single handedly bothering me since a week now and I'm unable to come to a solution. |
I'm facing a issue where a particular test fails for exactly a single target, however there's no way that I can debug the actual code to fix it. I've tried with
Console.WriteLine
but of course the assembly isn't included withinSystem.Net.Sockets
.System.Diagnostics.Debug
doesn't show up on the test log either.Any ideas?
The text was updated successfully, but these errors were encountered: