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

Fix - dotnet test on a multi-target projects logs only the last target #1877

Merged
merged 2 commits into from
Dec 28, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ private static string FormatDateTimeForRunName(DateTime timeStamp)
{
// We use custom format string to make sure that runs are sorted in the same way on all intl machines.
// This is both for directory names and for Data Warehouse.
return timeStamp.ToString("yyyy-MM-dd HH:mm:ss", DateTimeFormatInfo.InvariantInfo);
return timeStamp.ToString("yyyy-MM-dd HH:mm:ss:fff", DateTimeFormatInfo.InvariantInfo);
}

private void Initialize()
Expand Down
16 changes: 6 additions & 10 deletions src/Microsoft.TestPlatform.Extensions.TrxLogger/TrxLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -441,17 +441,13 @@ private void HandleSkippedTest(ObjectModel.TestResult rsTestResult)

private void DeriveTrxFilePath()
{
abhishkk marked this conversation as resolved.
Show resolved Hide resolved
if (this.parametersDictionary != null)
if (this.parametersDictionary != null &&
this.parametersDictionary.TryGetValue(TrxLoggerConstants.LogFileNameKey, out string logFileNameValue) &&
!string.IsNullOrWhiteSpace(logFileNameValue))
{
var isLogFileNameParameterExists = this.parametersDictionary.TryGetValue(TrxLoggerConstants.LogFileNameKey, out string logFileNameValue);
if (isLogFileNameParameterExists && !string.IsNullOrWhiteSpace(logFileNameValue))
{
this.trxFilePath = Path.Combine(this.testResultsDirPath, logFileNameValue);
}
else
{
this.SetDefaultTrxFilePath();
}
string logFileNameWithoutExt = Path.GetFileNameWithoutExtension(logFileNameValue);
logFileNameValue = logFileNameValue.Replace(logFileNameWithoutExt, logFileNameWithoutExt + DateTime.Now.ToString("_yyyy-MM-dd_HH-mm-ss-fff", DateTimeFormatInfo.InvariantInfo));
this.trxFilePath = Path.Combine(this.testResultsDirPath, logFileNameValue);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,12 @@ public void CustomTrxFileNameShouldConstructFromLogFileParameter()
{
this.MakeTestRunComplete();

Assert.AreEqual(Path.Combine(TrxLoggerTests.DefaultTestRunDirectory, TrxLoggerTests.DefaultLogFileNameParameterValue), this.testableTrxLogger.trxFile, "Wrong Trx file name");
string expectedFileNameWithoutTimestamp = Path.Combine(TrxLoggerTests.DefaultTestRunDirectory, TrxLoggerTests.DefaultLogFileNameParameterValue);
string fileName = Path.GetFileNameWithoutExtension(this.testableTrxLogger.trxFile);
string actualFileNameWithoutTimestamp = this.testableTrxLogger.trxFile.Replace(fileName, fileName.Split('_')[0]);

Assert.AreNotEqual(expectedFileNameWithoutTimestamp, this.testableTrxLogger.trxFile, "Expected time stamp to appear in file name");
Assert.AreEqual(expectedFileNameWithoutTimestamp, actualFileNameWithoutTimestamp, "Trx file name should construct from log file parameter");
}

/// <summary>
Expand Down