JetBrains / TeamCity.VSTest.TestAdapter

Apache License 2.0
30 stars 14 forks source link

Could not add additional logger in tests #39

Open gunmaden opened 4 years ago

gunmaden commented 4 years ago

I want to add additional trx logging in tests but with this condition is impossible to get teamcity output https://github.com/JetBrains/TeamCity.VSTest.TestAdapter/blob/2f59b50ef2f26b035f0039d7c5ad6434321892a3/TeamCity.VSTest.TestLogger/TeamCity.VSTest.TestAdapter.props#L28

Possible fix is appending logger://teamcity if VSTestLogger don't contains it already.

<VSTestLogger Condition=" !$(VSTestLogger.Contains('logger://teamcity')) ">$(VSTestLogger);logger://teamcity</VSTestLogger>
NikolayPianikov commented 4 years ago

@gunmaden hi, thank you, will add and check

NikolayPianikov commented 4 years ago

@gunmaden looks like this approach does not work for me. But you could specify multiple loggers, for instance:

dotnet test --logger "trx;LogFileName=my.trx" --logger logger://teamcity

Please see this ticket for details

gunmaden commented 4 years ago

@NikolayPianikov sure, but I think that expected behavior after add package is adding TC logger if IsUnderTeamCity == true in all cases, not only in case if there's no other loggers

Now we should some workaround (it works 🤔 but it's not elegant) but as I wrote before I think this logic could be implemented out of the box

<Target Name="SetupVSTestLogger" BeforeTargets="VSTest"
          Condition="'$(TEAMCITY_VERSION)' != ''">
    <PropertyGroup>
      <ContainsTeamCityTestAdapter>@(PackageReference->AnyHaveMetadataValue("Identity", "TeamCity.VSTest.TestAdapter"))</ContainsTeamCityTestAdapter>
      <VSTestLogger Condition=" $(ContainsTeamCityTestAdapter) AND !$(VSTestLogger.Contains('logger://teamcity')) ">$(VSTestLogger);logger://teamcity</VSTestLogger>
    </PropertyGroup>
  </Target>