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

TrxLogger throws on certain platforms #4736

Closed
dotMorten opened this issue Nov 5, 2023 · 0 comments · Fixed by #4737
Closed

TrxLogger throws on certain platforms #4736

dotMorten opened this issue Nov 5, 2023 · 0 comments · Fixed by #4737

Comments

@dotMorten
Copy link
Contributor

Description

I'm using the TrxLogger to generate TRX reports on the devices I run the unit tests on (Android, iOS etc), but the TRX logger throws an exception when logging the final testrun complete message.
This is because it for some reason writes to the console, but also tries to set the text color of the console:

Console.ForegroundColor = previousForegroundColor;

Setting the foreground color isn't supported on several platforms, as indicated here:
https://learn.microsoft.com/en-us/dotnet/api/system.console.foregroundcolor?view=net-7.0

The call should be guarded with a platform check. It would also be nice to be able to set the output level to None so nothing is writting to the console at all, since it doesn't make sense on some platforms.

Steps to reproduce

Use the TRX logger on iOS or Android. Call OnTestRunComplete on the TrxWriter.

Expected behavior

No PlatformNotSupported exception is thrown

Actual behavior

PlatformNotSupported exception, when TRX Logger hits this:

ConsoleOutput.Instance.Information(false, resultsFileMessage);

Screenshot from trx failling with callstack:
image

Environment

iOS and Android

dotMorten added a commit to dotMorten/vstest that referenced this issue Nov 5, 2023
@dotMorten dotMorten mentioned this issue Nov 5, 2023
1 task
dotMorten added a commit to dotMorten/MSTestX that referenced this issue Nov 5, 2023
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

Successfully merging a pull request may close this issue.

1 participant