运行 使用 NUnit3TestAdapter 在 vstest.console 上进行测试时,并非所有 Specflow Hooks 都被执行

Not all Specflow Hooks are executed when running tests on vstest.console with NUnit3TestAdapter

我们使用 visualstudio.com 发布管理器告诉本地构建代理在构建代理机器上构建和执行一组 SpecFlow 测试,从 GIT 分支中提取。

我们将测试程序集任务与自定义测试适配器 (NUnit3TestAdapter 3.7.0) 一起使用,并将其指向包含 SpecFlow 测试的程序集。同一 bin 文件夹中的其他程序集包含执行设置和拆卸挂钩的 SpecFlow-Hooks。

我们面临的问题是似乎并不是所有这些 Hook 都被调用了。 .trx 日志中的第一条和最后一条消息都来自 [BeforeScenario][AfterScenario] 挂钩。但是,在相同的程序集中有 [BeforeTestRun][AfterTestRun][BeforeFeature] 挂钩。

我在下面粘贴了来自 VSTS 的(删节)日志:

Executing vstest.console.exe "DLL CONTAINING TESTS" /TestCaseFilter:"TestCategory=MP2" /Settings:"C:\agent_work\r17\a\TestResults_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. All rights reserved.

Starting test execution, please wait...

Information: NUnit Adapter 3.7.0.0: Test execution started

Information: Running all tests in C:\agent_work\r17\a\drop\b\DLL CONTAINING TESTS

Information: NUnit3TestExecutor converted 472 of 472 NUnit test cases

然后是测试本身的日志记录,从 BeforeScenario.

的消息开始

我不知道为什么其他挂钩从未被调用过。 NUnit3TestAdapter 甚至会跟踪 TestRun 上下文吗?是因为 Before/AfterTestRun 和 Before/AfterFeature-hooks 绑定到静态方法吗?或者它们是否可能已被执行,但消息从未传递到 .trx 日志?

结果[BeforeTestRun] 被称为非常好,但没有出现在日志中。问题出在 [AfterTestRun],结果是 SpecFlow 中从未真正修复过的 old bug (?)