简体   繁体   English

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

[英]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.

相关问题 vstest.console可以按所有匹配的特征过滤测试吗? - Can vstest.console filter tests by all matched traits? 使用vstest.console使用基于名称空间的测试 - Running tests based on a namespace using vstest.console using 如何从csproj项目文件中正确删除NUnit3TestAdapter - How to correctly remove NUnit3TestAdapter from csproj project file 带有第三方 dll 的 VisualStudio NUnit3TestAdapter 测试项目 - VisualStudio NUnit3TestAdapter testing project with third party dlls 在Nunit控制台上运行Specflow 3.0报告 - Running Specflow 3.0 reports on Nunit console 在 vstest.console.exe 中运行多个单元测试时格式化控制台输出 - Formatting console output when running multiple Unit Tests in vstest.console.exe 从控制台应用程序运行nunit测试时处理异常 - Handling exceptions when running nunit tests from console application 运行某些特定测试时vstest崩溃 - vstest crashed when running some particular tests 通过nunit3-console.exe运行时,获取要在[SetUpFixture]中执行的测试 - Get tests to be executed in [SetUpFixture] while running via nunit3-console.exe 即使选择单个测试,Nunit 也会在 TestFixture 上运行所有测试 - Nunit running all tests on TestFixture even when selecting single test
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM