3
votes

I want to run my automated tests in TFS using a Custom Logger. Normally you would do this by adding something like /Logger:MyCustomLogger to the Other Console Options section of the Visual Studio Test Task.

You have the option to select tests by Assembly, Test Run ID, or Test Plan. If you select either Test Run or Test Plan, you are not able to set the Other Console Options value. Per the documentation:

Other console options that can be passed to vstest.console.exe, as documented here.

These options are not supported and will be ignored when running tests using the ‘Multi agent’ parallel setting of an agent phase or when running tests using ‘Test plan’ option. The options can be specified using a settings file instead.These options are not supported and will be ignored when running tests using the ‘Multi agent’ parallel setting of an agent phase or when running tests using ‘Test plan’ option. The options can be specified using a settings file instead.

I think thats because it uses TCM.exe instead of VSTest.Console.Exe, and TCM doesnt take the same console options, but not entirely sure.

According to the quote above, "The options can be specified using a settings file instead". My question is: What settings file allows you to provide a Logger? RunSettings doesnt support it (Though that may be addressed here).

So is there a workaround for this? Is there a way to provide a Logger while running a Test Plan?

1

1 Answers

2
votes

Please check this documentation:

Runsettings via Logger node in the LoggerRunSettings section. Here is a sample on how this can be specified:

<RunSettings>
    <LoggerRunSettings>
        <Loggers>
            <Logger friendlyName="sampleLoggerwithParameters">
                <Configuration>
                    <Key1>Value1</Key1>
                    <Key2>Value2</Key2>
                </Configuration>
            </Logger>
            <Logger uri="logger://sample/sampleLoggerWithoutParameters1"
                    friendlyName="sampleLoggerWithoutParameters1" />
            <Logger uri="logger://sample/sampleLoggerWithoutParameters2"
                    assemblyQualifiedName="Sample.Sample.Sample.SampleLogger,

Sample.Sample.Logger, Version=0.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx" friendlyName="sampleLoggerWithoutParameters2" />

This loads and initializes:

  • Logger with friendlyName="sampleLoggerwithParameters". Key1=Value1 and Key2=Value2 are passed as dictionary parameters to the logger while initialization. i.e.
    SampleLoggerWithParameters.Initialize(TestLoggerEvents events,
    Dictionary<string, string> parameters)
    is invoked with parameters = {{"Key1", "Value1"}, {"Key2", "Value2"}}
  • Logger with uri="logger://sample/sampleLoggerWithoutParameters1". FriendlyName is ignored in this case as uri takes more precedence.
  • Logger with assemblyQualifiedName="Sample.Sample.Sample.SampleLogger,
    Sample.Sample.Logger, Version=0.0.0.0, Culture=neutral,
    PublicKeyToken=xxxxxxxxxxxxxxxx"
    . Uri and friendlyName are ignored in this case as assemblyQualifiedName takes more precedence.