Skip to content

TrxReport doesn't correctly handle DebugOrTraceTrxMessage #5507

Closed

Description

We have a base TrxMessage with 3 concrete implementations:

  • StandardErrorTrxMessage (should go to StdErr, and correctly does)
  • StandardOutputTrxMessage (should go to StdOut, and correctly does)
  • DebugOrTraceTrxMessage (should go to DebugTrace, but incorrectly goes to StdOut today)

Then if we face an instance that's not any of the 3 concrete implementations (e.g, another implementation provided by user, of an instance of the base TrxMessage directly), we add it to StdOut. It feels like in v2 we should consider doing a break here if Trx is really designed to deal with StdError, StdOut, and DebugTrace only. We don't need a base type here.

Implementation on MTP:

TrxMessagesProperty? trxMessages = testNode.Properties.SingleOrDefault<TrxMessagesProperty>();
IEnumerable<string?>? nonErrorMessages = trxMessages?.Messages.Where(x => x is not StandardErrorTrxMessage).Select(x => x.Message);
if (nonErrorMessages?.Any() == true)
{
output.Add(new XElement("StdOut", RemoveInvalidXmlChar(string.Join(Environment.NewLine, nonErrorMessages))));
}
IEnumerable<string?>? errorMessages = trxMessages?.Messages.Where(x => x is StandardErrorTrxMessage).Select(x => x.Message);
if (errorMessages?.Any() == true)
{
output.Add(new XElement("StdErr", RemoveInvalidXmlChar(string.Join(Environment.NewLine, errorMessages))));
}

Relevant part on VSTest:

https://github.com/microsoft/vstest/blob/377623d4d0b6e00d8e6a0be47268866ac14f8c49/src/Microsoft.TestPlatform.Extensions.TrxLogger/ObjectModel/TestResult.cs#L517-L519

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area/mtp-extensionsarea/trx

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions