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

dotnet test does not respect LogFileName -- adds date #1951

Closed
livarcocc opened this issue Mar 11, 2019 · 25 comments
Closed

dotnet test does not respect LogFileName -- adds date #1951

livarcocc opened this issue Mar 11, 2019 · 25 comments

Comments

@livarcocc
Copy link

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

@ShreyasRmsft
Copy link
Member

@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.

@hpbieker
Copy link

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.

@ShreyasRmsft
Copy link
Member

You are right on the behavior changing from 15.9.0 to 16.0.0. Let me double check the exact reason we made this change and get back to you.

@ShreyasRmsft
Copy link
Member

@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?

@brittonbeckham
Copy link

BTW: this happens even when running tests against a single .csproj file. We have the same problem where it broke our CI pipes.

@ShreyasRmsft
Copy link
Member

@brittonbeckham can you please create a new issue and provide the entire set of logs and screenshots (where applicable) for this?

gfoidl added a commit to gfoidl-Tests/Continuous-Integration-Test that referenced this issue Apr 3, 2019
Cf. microsoft/vstest#1951
A timestamp is appended to the filename, so build broke.

Also fixed the _testCore, to allow promotion of exit codes
@tremblaysimon
Copy link

tremblaysimon commented Apr 3, 2019

@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.

@jonjomckay
Copy link

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 running dotnet vstest /logger:"trx;LogFileName=report.unit.xml", so it looks like this was a breaking change made in a non-major version update...?

@Kemyke
Copy link

Kemyke commented Apr 5, 2019

Same here, broke our build pipelines too.

@Marusyk
Copy link

Marusyk commented Apr 8, 2019

@ShreyasRmsft This change broke our pipelines too. What's going on?

@brittonbeckham
Copy link

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!

@cltshivash
Copy link
Contributor

@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.

@cltshivash cltshivash reopened this Apr 9, 2019
@mayankbansal018
Copy link
Contributor

Adding reference to #1978 , we plan to publish an RFC on how trx file name would be generated, will update once that is out.

@andyturner
Copy link

+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?

@subprime
Copy link

+1, broke our build chain too.

@crhairr
Copy link

crhairr commented Apr 16, 2019

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.

@SeppPenner
Copy link

+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?

Broke our scripts as well. I totally agree with @andyturner and @crhairr. It should be backwards compatible and simply provide the possibility to add prefixes/postfixes if needed.

gfoidl added a commit to gfoidl/trx2junit that referenced this issue Apr 19, 2019
gfoidl added a commit to gfoidl/trx2junit that referenced this issue Apr 19, 2019
* 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. microsoft/vstest#1951

* TFM for samples set to netcoreapp3.0
@vany0114
Copy link

+1 broke my build too

@mikravn
Copy link

mikravn commented Apr 26, 2019

+1 It broke our builds too, it would be better with possibility for prefixes/postfixes.

Also the description in dotnet test -h is now misleading:
Log in trx format using the specified file name: --logger "trx;LogFileName=<TestResults.trx>"

@ecoffman
Copy link

ecoffman commented Apr 30, 2019

+1 Our scripts are broken now, too.

I fixed it like so:

sh 'dotnet test src/hub-backend.sln --verbosity m --logger "trx;LogFileName=TestResult.xml"'
script {
    TRX_FILE = sh (script: "ls -t src/<hidden>/TestResults/TestResult*.xml | head -1", returnStdout: true).trim()
}
step([$class: 'MSTestPublisher', testResultsFile:"$TRX_FILE", failOnError: true, keepLongStdio: true])

@Brunni
Copy link

Brunni commented May 7, 2019

+1
It broke our builds, too!
Our command: dotnet test --logger "trx;LogFileName=TestResults.trx"

JPWatson added a commit to AdaptiveConsulting/Aeron.NET that referenced this issue May 8, 2019
…92)

* Switch bounds checking to environment variable (and enable by default)
* Fix Appveyor microsoft/vstest#1951
jaaufauvre added a commit to Mastercard/oauth1-signer-csharp that referenced this issue May 8, 2019
jaaufauvre added a commit to Mastercard/oauth1-signer-csharp that referenced this issue May 8, 2019
jaaufauvre added a commit to Mastercard/oauth1-signer-csharp that referenced this issue May 9, 2019
jaaufauvre added a commit to Mastercard/client-encryption-csharp that referenced this issue May 9, 2019
@alirezava
Copy link

+1 broke our build too.

Microsofts cowboy builder at it again...

Any updates on this?

@mayankbansal018
Copy link
Contributor

It was fixed via #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

@hrai
Copy link

hrai commented May 15, 2019

@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?

Using the trx regex like TestResult_*.trx in my build script fixed it temporarily until we get the sdk up to date.

janjanech added a commit to frikst/POCOMapper that referenced this issue Jun 13, 2019
skwasjer added a commit to skwasjer/IbanNet that referenced this issue Jul 25, 2019
skwasjer added a commit to skwasjer/IbanNet that referenced this issue Jul 25, 2019
skwasjer added a commit to skwasjer/IbanNet that referenced this issue Oct 25, 2019
Squashed commit of the following:

commit 9332f66
Merge: e327d13 9664ec0
Author: skwas <skwas@skwas.net>
Date:   Fri Oct 25 19:41:55 2019 +0200

    Merge branch 'master' into develop

commit e327d13
Author: skwas <skwas@skwas.net>
Date:   Fri Oct 25 19:34:45 2019 +0200

    Build with VS2019 image

commit ded1ddc
Author: skwas <skwas@skwas.net>
Date:   Fri Oct 25 19:29:58 2019 +0200

    Insert final newline

commit 99714e3
Author: skwas <skwas@skwas.net>
Date:   Fri Oct 25 19:14:50 2019 +0200

    Move localizable text to RESX

commit 4daec94
Author: skwas <skwas@skwas.net>
Date:   Fri Oct 25 18:57:10 2019 +0200

    Reorder target frameworks and rerun custom tool. This workaround ensures GetTypeInfo() is emitted.

    dotnet/project-system#1519

commit 5ee8134
Author: skwas <skwas@skwas.net>
Date:   Fri Oct 25 18:52:23 2019 +0200

    Move localizable text to RESX

commit 050ece6
Author: skwas <skwas@skwas.net>
Date:   Fri Oct 25 18:44:09 2019 +0200

    Update Changelog

commit 6cd686b
Author: skwas <skwas@skwas.net>
Date:   Wed Oct 16 05:58:49 2019 +0200

    Use .snupkg and SourceLink

commit 2bae078
Author: skwas <skwas@skwas.net>
Date:   Wed Oct 16 05:57:30 2019 +0200

    Add settings for props and targets files

commit 9664ec0
Merge: e6bee51 aa01d3f
Author: skwasjer <skwas@skwas.net>
Date:   Wed Oct 16 03:30:58 2019 +0200

    Merge pull request #10 from skwasjer/develop

    Add test coverage

commit aa01d3f
Author: skwas <skwas@skwas.net>
Date:   Wed Oct 16 01:36:20 2019 +0200

    Fix upload script not finding test reports

commit 204017d
Author: skwas <skwas@skwas.net>
Date:   Wed Oct 16 01:18:16 2019 +0200

    Fix: upload test report per target framework

    microsoft/vstest#1603

commit 1b25c1a
Author: skwas <skwas@skwas.net>
Date:   Sat Aug 10 00:56:30 2019 +0200

    Fix whitespace

commit 3c2bc0d
Author: skwas <skwas@skwas.net>
Date:   Sat Aug 10 00:56:13 2019 +0200

    Add test case that asserts correct verification of case (in)sensitive IBAN's

commit 9f71aca
Author: skwas <skwas@skwas.net>
Date:   Wed Oct 16 00:46:34 2019 +0200

    fix: internal IBAN value can never be null. Add some extra coverage for equality checks.

commit 884119e
Author: skwas <skwas@skwas.net>
Date:   Wed Oct 16 00:20:28 2019 +0200

    Add coverage

commit 51e99ba
Author: skwas <skwas@skwas.net>
Date:   Wed Oct 16 00:10:30 2019 +0200

    Partial revert, the custom upload of test reports was needed because NUnit reports are not supported by AppVeyor.

    This partially reverts commit 099472f.

commit 3d6ab4b
Author: skwas <skwas@skwas.net>
Date:   Wed Oct 16 00:03:29 2019 +0200

    Add coverage for extensions

commit 3243a77
Author: skwas <skwas@skwas.net>
Date:   Tue Oct 15 23:32:00 2019 +0200

    Moved extension specific to get country code to validator since it's poluting string class with this extension method.

commit e6bee51
Merge: 046132a a3bf4fb
Author: skwasjer <skwas@skwas.net>
Date:   Tue Oct 15 23:21:44 2019 +0200

    Merge pull request #9 from skwasjer/develop

    CI/Coverage improvements

commit a3bf4fb
Merge: 92a4e88 046132a
Author: skwasjer <skwas@skwas.net>
Date:   Tue Oct 15 23:18:16 2019 +0200

    Merge branch 'master' into develop

commit 92a4e88
Author: skwas <skwas@skwas.net>
Date:   Tue Oct 15 23:00:10 2019 +0200

    fix: fail build when test fails during coverage
    fix: exclude generated/excluded code

commit 099472f
Author: skwas <skwas@skwas.net>
Date:   Tue Oct 15 22:49:17 2019 +0200

    Move DebugType=full to cmdline arg, so we can compile Release with portable PDB (to support SourceLink)

commit 8189ae1
Author: skwas <skwas@skwas.net>
Date:   Tue Oct 15 20:48:24 2019 +0200

    Bump test dependencies

commit 046132a
Merge: 6e07f35 9ba8014
Author: skwasjer <skwas@skwas.net>
Date:   Thu Jul 25 03:38:07 2019 +0200

    Merge pull request #5 from skwasjer/develop

    v3.1.1 - Maintenance release

commit 9ba8014
Author: skwas <skwas@skwas.net>
Date:   Thu Jul 25 01:21:15 2019 +0200

    Fix unit test reports not found
    microsoft/vstest#1951

commit 20ed577
Author: skwas <skwas@skwas.net>
Date:   Thu Jul 25 01:13:15 2019 +0200

    fix: use correct build hook

commit b9914c4
Author: skwas <skwas@skwas.net>
Date:   Thu Jul 25 01:04:16 2019 +0200

    fix: test-results.xml files not found due to invalid arg

commit dc89c1f
Author: skwas <skwas@skwas.net>
Date:   Thu Jul 25 00:53:45 2019 +0200

    fix build failure

commit 323af41
Author: skwas <skwas@skwas.net>
Date:   Thu Jul 25 00:49:20 2019 +0200

    fix: custom codecov script does not generate and upload unit test results to AppVeyor

commit 5dec462
Author: skwas <skwas@skwas.net>
Date:   Wed Jul 24 23:57:40 2019 +0200

    Update Changelog.md

commit 8593bae
Author: skwas <skwas@skwas.net>
Date:   Wed Jul 24 23:51:36 2019 +0200

    Revert breaking change, expose dictionary via internal interface. Breaking change will be postponed until v4.

commit 5364406
Author: skwas <skwas@skwas.net>
Date:   Wed Jul 24 23:34:07 2019 +0200

    Ensure supported countries cannot be modified directly.

commit b5b5147
Author: skwas <skwas@skwas.net>
Date:   Wed Jul 24 23:23:54 2019 +0200

    Made internal (so it won't get used yet) until decided what to do with it.

commit e6ea2b9
Author: skwas <skwas@skwas.net>
Date:   Wed Jul 24 23:15:15 2019 +0200

    Enable cache for choco packages, and add full debug symbols for coverage

commit f33dd15
Author: skwas <skwas@skwas.net>
Date:   Wed Jul 24 23:05:04 2019 +0200

    Enable codecov

commit f619f6e
Merge: 970850e 6e07f35
Author: skwas <skwas@skwas.net>
Date:   Wed Jul 24 22:47:54 2019 +0200

    Merge branch 'master' into develop

commit 970850e
Author: skwas <skwas@skwas.net>
Date:   Thu May 23 22:36:02 2019 +0200

    Field is not supported.

commit ddc095e
Author: skwas <skwas@skwas.net>
Date:   Thu May 23 20:33:54 2019 +0200

    Move getting country code from string to internal extension.

commit 4d52172
Author: skwas <skwas@skwas.net>
Date:   Thu May 23 20:17:21 2019 +0200

    Update Changelog.md

commit 397a50f
Author: skwas <skwas@skwas.net>
Date:   Thu May 23 20:16:12 2019 +0200

    (breaking) Expose supported countries through new interface.
    (breaking) Change type of SupportedCountries to dictionary

commit 7f532af
Author: skwas <skwas@skwas.net>
Date:   Sun May 12 03:40:47 2019 +0200

    Allow access to some properties via debugger

commit 4f8e24b
Author: skwas <skwas@skwas.net>
Date:   Sat May 11 02:33:34 2019 +0200

    [skip ci] Build/test shields only report for master branch

commit ae03d21
Author: skwas <skwas@skwas.net>
Date:   Sat May 11 02:24:55 2019 +0200

    Always use latest version of IbanNet for example app

# Conflicts - resolved using changes to be integrated:
#	Changelog.md
#	appveyor.yml
#	ci/upload-testresults.ps1
#	codecov.yml
#	src/IbanNet.DataAnnotations/IbanNet.DataAnnotations.csproj
#	src/IbanNet.FluentValidation/IbanNet.FluentValidation.csproj
#	src/IbanNet/IbanNet.csproj
#	src/IbanNet/IbanValidator.cs
#	test/IbanNet.Tests/IbanValidatorTests.cs
@hunyhabib
Copy link

hunyhabib commented Nov 25, 2019

Now My tests also are breaking with Microsoft.Net.Test.SDK V16.3.0 for same reason

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

No branches or pull requests