vstest icon indicating copy to clipboard operation
vstest copied to clipboard

Several problems are being caused by the new log file name timestamp

Open jnm2 opened this issue 5 years ago • 9 comments

https://github.com/Microsoft/vstest/pull/1877 is causing problems.

  • VSTest inventing directories that don't exist because the string.Replace is hitting all containing directory names, not just the file name.
  • The filename is unsightly and there's no way to turn this off.
  • Our CI scripts have to guess at the resulting filename based on the directory listing or else direct VSTest to a temp folder and copy TRX files back out with proper filenames.

jnm2 avatar Apr 04 '19 18:04 jnm2

@jnm2 we are looking at this issue, & re-designing on how we should handle the results at dotnet sln(multiple test project / multi target test project) level.

We are not reverting the fix done earlier immediately, as it might cause confusion for those whose trx are getting published.

We will publish an RFC once we have a design in place, before implementing it.

mayankbansal018 avatar Apr 05 '19 10:04 mayankbansal018

Good to know. I'd love if there was a way for the TRX format to be enhanced so that a single file can contain all the results for each target framework. Projects that use TRX would be able to follow the <multi-project run name>.trx pattern that is possible with NUnit XML.

Second-best would be <multi-project run name>.netstandard2.0.trx etc, but that puts a burden on our CI scripts to play catch-up with our projects' changing TFMs over time. It's not very maintainable from that perspective.

jnm2 avatar Apr 05 '19 12:04 jnm2

well maybe you could use the existing feature? --logger "rx;LogFileName=Framework.trx" for framework

--logger "rx;LogFileName=Core2_1.trx" for Core 2.1

--logger "rx;LogFileName=Core2_2.trx" for Core 2.2

this change broke all of my multi-targeted builds!

jcoburn avatar Apr 11 '19 13:04 jcoburn

well maybe you could use the existing feature?

How would my build script know which TFMs to use? They change pretty often. This is additional pain.

jnm2 avatar Apr 12 '19 12:04 jnm2

@vagisha-nidhi Can you please link the RFC for this fix and also release when it is available.

singhsarab avatar Sep 16 '19 08:09 singhsarab

Tagging @AbhitejJohn

drognanar avatar Jan 23 '20 17:01 drognanar

#1877 was reverted in #1996 so that fixes the log file name timestamp part of the issue.

Being able to run tests on multiple frameworks and collect the results is unfortunately not yet solved, though.

See also #1876 which is related to this issue. If the [targetFramework] template is implemented as proposed, it could solve the problem of running tests on multiple frameworks by producing one test results file per target framework.

0xced avatar Sep 13 '21 19:09 0xced

Note to self: test if problem still exists

Evangelink avatar Aug 02 '22 12:08 Evangelink

Cross-posting my comment from #1876 which can workaround this issue by defining the test logger parameters as MSBuild properties, where you have access to the target framework and the project name.

I recently learnt that you can control the loggers through MSBuild properties instead of dotnet test arguments. Thus it becomes easy to craft the log file name of your choice. Here's what I have added to the Directory.Build.props file in my tests directory:

<ItemGroup>
  <VSTestLogger Include="trx%3BLogFileName=TestResults-$(TargetFramework)-$(MSBuildProjectName).trx" />
  <VSTestLogger Include="html%3BLogFileName=TestResults-$(TargetFramework)-$(MSBuildProjectName).html" />
</ItemGroup>

<PropertyGroup Condition="$(ContinuousIntegrationBuild) == 'true'">
  <VSTestResultsDirectory>$(MSBuildThisFileDirectory)\..</VSTestResultsDirectory>
  <VSTestLogger>@(VSTestLogger)</VSTestLogger>
</PropertyGroup>

0xced avatar Apr 29 '23 18:04 0xced