[英]Not all Specflow Hooks are executed when running tests on vstest.console with NUnit3TestAdapter
We use the visualstudio.com Release Manager to tell a local Build Agent to build and execute a set of SpecFlow tests on the Build Agent-machine, pulling from a GIT-branch. 我们使用visualstudio.com发布管理器来告诉本地Build Agent从GIT分支中提取并在Build Agent机器上构建并执行一组SpecFlow测试。
We're using the Test Assemblies-task with a Custom Test Adapter (NUnit3TestAdapter 3.7.0) and point it toward the assembly containing the SpecFlow tests. 我们正在使用带有自定义测试适配器(NUnit3TestAdapter 3.7.0)的Test Assemblies-task,并将其指向包含SpecFlow测试的程序集。 Other assemblies inside the same bin folder contain SpecFlow-Hooks that execute setup and teardown-hooks.
同一bin文件夹中的其他程序集包含执行安装和拆卸挂钩的SpecFlow挂钩。
The problem we're facing is that not all of these Hooks seem to called. 我们面临的问题是似乎并非所有这些Hook都被调用。 The first and last messages in the .trx logs are all from
[BeforeScenario]
and [AfterScenario]
hooks. .trx日志中的第一条消息和最后一条消息均来自
[BeforeScenario]
和[AfterScenario]
挂钩。 There are -however- [BeforeTestRun]
, [AfterTestRun]
and [BeforeFeature]
hooks in the same assemblies. [BeforeTestRun]
,在同一程序集中有[BeforeTestRun]
, [AfterTestRun]
和[BeforeFeature]
挂钩。
I've pasted the (abridged) logs from VSTS below: 我从下面粘贴了来自VSTS的(摘要)日志:
Executing vstest.console.exe " DLL CONTAINING TESTS " /TestCaseFilter:"TestCategory=MP2" /Settings:"C:\\agent_work\\r17\\a\\TestResults\\1_2017-05-31_09-31-50-AM.runsettings" /logger:trx /TestAdapterPath:"C:\\agent_work\\r17\\a\\drop\\b\\packages\\NUnit3TestAdapter.3.7.0\\tools"
执行vstest.console.exe“包含测试的DLL ” / TestCaseFilter:“ TestCategory = MP2” /Settings:"C:\\agent_work\\r17\\a\\TestResults\\1_2017-05-31_09-31-50-AM.runsettings“ / logger :trx /TestAdapterPath:"C:\\agent_work\\r17\\a\\drop\\b\\packages\\NUnit3TestAdapter.3.7.0\\tools“
Microsoft (R) Test Execution Command Line Tool Version 14.0.25420.1 2017-05-31T07:31:51.1862622Z Copyright (c) Microsoft Corporation.
Microsoft(R)测试执行命令行工具版本14.0.25420.1 2017-05-31T07:31:51.1862622Z版权所有(c)Microsoft Corporation。 All rights reserved.
版权所有。
Starting test execution, please wait...
开始执行测试,请稍候...
Information: NUnit Adapter 3.7.0.0: Test execution started
信息:NUnit适配器3.7.0.0:测试执行开始
Information: Running all tests in C:\\agent_work\\r17\\a\\drop\\b\\ DLL CONTAINING TESTS
信息:在C:\\ agent_work \\ r17 \\ a \\ drop \\ b \\ DLL包含测试中运行所有测试
Information: NUnit3TestExecutor converted 472 of 472 NUnit test cases
信息:NUnit3TestExecutor转换了472个NUnit测试用例中的472个
Then the logging from the tests itself, starting with messages from BeforeScenario
. 然后从测试本身进行日志记录,从
BeforeScenario
消息开始。
I'm at a loss as to why the other hooks are never called. 我不知道为什么从来没有调用其他钩子。 Does NUnit3TestAdapter even keep track of a TestRun context?
NUnit3TestAdapter甚至可以跟踪TestRun上下文吗? Is it because the Before/AfterTestRun and Before/AfterFeature-hooks are bound to static methods?
是因为Before / AfterTestRun和Before / AfterFeature-hook绑定到静态方法吗? Or is it possible they ARE executed, but the messages are never passed through to the .trx logs?
还是有可能它们被执行了,但是消息从未传递到.trx日志?
It turns out [BeforeTestRun]
was being called perfectly fine, but just didn't show up in the logs. 事实证明,
[BeforeTestRun]
被很好地调用了,但是没有出现在日志中。 The problem was with [AfterTestRun]
, which turns out to be an old bug in SpecFlow that was never really fixed (?) 问题出在
[AfterTestRun]
,它原来是SpecFlow中的一个旧错误 ,从未真正修复过(?)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.