我想使用自定义记录器在 TFS 中运行我的自动化测试。通常,您可以通过将类似 /Logger:MyCustomLogger 的内容添加到 Visual Studio 测试任务的 Other Console Options 部分来执行此操作。
您可以选择按装配、测试运行 ID 或测试计划来选择测试。如果选择测试运行或测试计划,则无法设置其他控制台选项值。根据文档:
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.
我认为那是因为它使用 TCM.exe 而不是 VSTest.Console.Exe,并且 TCM 不采用相同的控制台选项,但不完全确定。
根据上面的引述,“可以使用设置文件来指定选项”。我的问题是:什么设置文件允许您提供记录器? RunSettings 不支持它(虽然可以解决 here )。
那么有解决办法吗?有没有办法在运行测试计划时提供记录器?
最佳答案
请查看this documentation :
Runsettings via
Logger
node in theLoggerRunSettings
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
andKey2=Value2
are passed as dictionary parameters to the logger while initialization. i.e.
SampleLoggerWithParameters.Initialize(TestLoggerEvents events,<br/> Dictionary<string, string> parameters)
is invoked withparameters = {{"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,<br/> Sample.Sample.Logger, Version=0.0.0.0, Culture=neutral,<br/> PublicKeyToken=xxxxxxxxxxxxxxxx"
. Uri and friendlyName are ignored in this case as assemblyQualifiedName takes more precedence.
关于tfs - 在 TFS 中,如何使用自定义记录器执行测试运行?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51212536/