Skip to content

TrxLogger throws on certain platforms #4736

@dotMorten

Description

@dotMorten

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions