vstest: dotnet test does not respect LogFileName -- adds date
From @hpbieker on March 11, 2019 9:59
Steps to reproduce
- Install .NET Core 3.0 preview3
- Create a test project
- Run
dotnet test --logger 'trx;LogFileName=somename.trx'
Expected behavior
A file named somename.trx
should be created. In .NET Core 2.2 / Test Execution Command Line Tool Version 15.9.0 I get this behaviour.
Actual behavior
A file named somename_2019-03-11_10-38-36-764.trx
was created.
$ dotnet test --logger 'trx;LogFileName=somename.trx'
Test run for C:\Users\nohabie\AppData\Local\Temp\test\bin\Debug\netcoreapp3.0\test.dll(.NETCoreApp,Version=v3.0)
Microsoft (R) Test Execution Command Line Tool Version 16.0.0-preview-20190124-02
Copyright (c) Microsoft Corporation. All rights reserved.
Starting test execution, please wait...
Results File: C:\Users\XXX\AppData\Local\Temp\test\TestResults\somename_2019-03-11_10-38-36-764.trx
Total tests: 1. Passed: 1. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 1,1557 Seconds
Environment data
$ dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 3.0.100-preview3-010431
Commit: d72abce213
Runtime Environment:
OS Name: Windows
OS Version: 6.1.7601
OS Platform: Windows
RID: win7-x64
Base Path: C:\Program Files\dotnet\sdk\3.0.100-preview3-010431\
Host (useful for support):
Version: 3.0.0-preview3-27503-5
Commit: 3844df9537
.NET Core SDKs installed:
2.1.600 [C:\Program Files\dotnet\sdk]
2.2.200 [C:\Program Files\dotnet\sdk]
3.0.100-preview3-010431 [C:\Program Files\dotnet\sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.0.0-preview3-19153-02 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.0.0-preview3-27503-5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.0.0-preview3-27504-2 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
Copied from original issue: dotnet/cli#10962
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 13
- Comments: 25 (7 by maintainers)
Commits related to this issue
- build.sh test updated because of trx-logger Cf. https://github.com/Microsoft/vstest/issues/1951 A timestamp is appended to the filename, so build broke. Also fixed the _testCore, to allow promotion ... — committed to gfoidl-Tests/Continuous-Integration-Test by gfoidl 5 years ago
- Fixed CI due to trx-logger filename Cf. https://github.com/Microsoft/vstest/issues/1951 — committed to gfoidl/trx2junit by gfoidl 5 years ago
- Multi-targeting for .NET Core 3.0 (#49) * Multi-targeting for .NET Core 3.0 * Updated build-image * Use glogging feature of trx2junit in CI * Fixed CI due to trx-logger filename Cf. https... — committed to gfoidl/trx2junit by gfoidl 5 years ago
- fixes unit tests report to appveyor since MS did a broken change to dotnet test api https://github.com/Microsoft/vstest/issues/1951 — committed to vany0114/EF.DbContextFactory by vany0114 5 years ago
- Switch bounds checking to environment variable and enable by default (#92) * Switch bounds checking to environment variable (and enable by default) * Fix Appveyor https://github.com/Microsoft/vstest... — committed to AdaptiveConsulting/Aeron.NET by JPWatson 5 years ago
- Fixed unit test report generation (https://github.com/Microsoft/vstest/issues/1951) — committed to Mastercard/oauth1-signer-csharp by jaaufauvre 5 years ago
- Fixed unit test report generation (https://github.com/Microsoft/vstest/issues/1951) (Part 2) — committed to Mastercard/oauth1-signer-csharp by jaaufauvre 5 years ago
- Fixed unit test report generation (microsoft/vstest#1951) — committed to Mastercard/oauth1-signer-csharp by jaaufauvre 5 years ago
- Fixed unit test report generation (microsoft/vstest#1951) — committed to Mastercard/client-encryption-csharp by jaaufauvre 5 years ago
- yet another fix for appveyor microsoft/vstest#1951 — committed to frikst/POCOMapper by janjanech 5 years ago
- Fix unit test reports not found https://github.com/microsoft/vstest/issues/1951 — committed to skwasjer/IbanNet by skwasjer 5 years ago
- Fix unit test reports not found https://github.com/microsoft/vstest/issues/1951 — committed to skwasjer/IbanNet by skwasjer 5 years ago
- Release v3.1.2 Squashed commit of the following: commit 9332f66f2c61fcb194acaa96508e8f57b9c575eb Merge: e327d13 9664ec0 Author: skwas <skwas@skwas.net> Date: Fri Oct 25 19:41:55 2019 +0200 Me... — committed to skwasjer/IbanNet by skwasjer 5 years ago
@hpbieker this was done when dotnet test support at solution level was added i believe. The scenario was that when you ran it at a solution level multiple csprojs are present and multiple trx files are generated. To ensure these don’t override each other this change was made.
I’m sorry this broke your build scripts. But I don’t see a way to go back to honoring the exact file name without adding a post fix since it will break the multi csproj scenario.
You can look for trx files with a regex that checks for the name you have as the prefix. (This is what we do in the AzureDevops pipelines, to publish the trx-es). I hope the explanation was satisfactory?
But it did not behave this way in In .NET Core 2.2 / Test Execution Command Line Tool Version 15.9.0 I get this behaviour? This change broke my build scripts because the trx file was not found anymore.
BTW: this happens even when running tests against a single .csproj file. We have the same problem where it broke our CI pipes.
This also broke all of our build pipelines too. Nothing exotic is happening in this section of our pipelines - it’s merely pulling the
microsoft/dotnet:2.2-sdk
Docker image and runningdotnet vstest /logger:"trx;LogFileName=report.unit.xml"
, so it looks like this was a breaking change made in a non-major version update…?+1, broke our build chain too. I’m surprised such a change was implemented without any backwards compatibility. Was it not more sensible to implement a “UniqueLogFileName” parameter for those people with the multi-target issue to use, and to leave the behaviour of “LogFileName” untouched/unbroken?
@ShreyasRmsft This change broke our pipelines too.
Is it normal that a patch version (.NET Core SDK 2.1.602) brings a breaking change like that?
Workaround: change your build script or use SDK version 2.1.505.
Note that we used the microsoft/dotnet:2.1-sdk docker image available on Docker Hub. Since that image point to 2.1.602 instead of 2.1.505 it broke our pipelines.
This broke our build scripts that execute inside of Jenkins. The test result collector at the end of our build pipeline stages can no longer find the files. We have many, many dozens of these build scripts, all run inside Docker images. Fixing this is a huge issue for us, and a reason not to adopt the newer .NET Core versions.
We also have many multi-test solutions in place. Our pattern is to run each test project separately and collect the result files at the end of the stage. Your “multi test” solution is for a problem that many developers have already worked around.
The better solution would have been to allow developers the options to change the suffix if we had needed to, rather than forcing it on us and breaking our builds without warning.
Your solution to a problem that didn’t exist is bad.
I think MS wants us to open another issue for this, but seems like it shouldn’t have been closed. A patch like this to a container image shouldn’t have been a breaking change without, at minimum, a minor version number change. We found a work around for the meantime, but this is definitely frustrating.
On the flip side, I am happy and excited about where all this .NET Core stuff is going and have been using it heavily. Having used .NET since v1, i can say I have never been more excited to code in .NET Core. Cheers to the entire team!
@brittonbeckham @Marusyk @Kemyke Apologies for the break here and do acknowledge that we should have called this out broadly and with an equivalent version update. The cause of the change was to address the scenario of multi targeted test project where the log file provided was being overwritten and ending up with data loss. We will revisit the change and see if we could retain the earlier behavior and at the same time address the issue with multi target test projects.
It was fixed via https://github.com/microsoft/vstest/pull/1996 Release: https://github.com/microsoft/vstest/releases/tag/v16.0.2-preview-20190502-01 Notes: https://github.com/Microsoft/vstest-docs/blob/master/docs/releases.md#1602-preview-20190502-01
@livarcocc as of today this is by design.
We do this to create unique files. Consider the option as more of a logFilePrefix rather than logFileName.
And changing the param name is contract breaking change so we won’t be able to rename it.