visual-studio - 从代理或客户端运行数据表的 Specflow 测试在 Azure 管道 VS 测试任务上失败
问题描述
BLUF : 没有 Specflow 数据表测试从 Azure Pipeline 运行良好使用 Specflow 数据表测试从 Azure Pipeline 失败
设置
- SpecFlow 3.1 或 3.3
- MSTest 作为测试运行者
- 包.config
- .feature.cs 文件是使用 SpecFlow.Tools.MsBuild.Generation NuGet 包生成的
- VS 2019
- Visual Studio 扩展设置中的 SpecFlowSingleFileGenerator 自定义工具选项已禁用
- .NET Framework 4.5.1(自托管计算机上的框架 .NET 4.7)
- TFS/VSTS/Azure DevOps – 任务 – Visual Studio 测试任务 2.*
配置
- Visual Studio C# Selenium 测试项目
- 使用范围报告
- DotNetSeleniumExtras 页面对象
- MSTestTestAdapter 和框架
- Selenium 和 Chrome 驱动程序
- 特征文件中的数据表
- 构建或发布管道上的 Azure Visual Studio 任务
- 测试程序集使用 .exe 而不是 .dll 运行
- Azure VSTest 任务使用 testhost.x86.exe
行动:
- 在 Visual Studio 中使用数据表创建 Selenium Specflow 测试
- 推送到回购
- 使用 Visual Studio 测试任务设置构建或发布管道(测试的行为方式相同)
- 运行管道
结果:
- 通过 Visual Studio 测试资源管理器从客户端机器上运行带有或不带有数据表的测试而不会出现错误
- 通过 Visual Studio 测试资源管理器或使用 vstest.console.exe 从命令行运行时,使用或不使用数据表的测试在自定义本地代理计算机上运行时不会出现错误
- 没有数据表的测试通过 Visual Studio 测试资源管理器从自定义本地代理计算机运行,或者在命令行使用 vstest.console.exe 运行时没有错误
使用数据表的测试失败,并出现来自 Azure Pipeline Visual Studio 任务的以下错误
dmp 文件错误:进程名称:testhost.x86.exe:C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\Extensions\TestPlatform\testhost.x86.exe 进程架构:x86 异常代码: 0xC0000005 异常信息:线程试图读取或写入它没有适当访问权限的虚拟地址。堆信息:不存在
系统信息
- 操作系统版本:10.0.14393
- CLR 版本:4.7.3620.0
Azure PipelineError 输出:
Test method HappyTest.Features.CPUF.YPUCC_1 threw exception:
System.NullReferenceException: Object reference not set to an instance of an object.
AventStack.ExtentReports.Model.ExceptionInfo..ctor(Exception ex)
AventStack.ExtentReports.ExtentTest.Log(Status status, Exception ex, MediaEntityModelProvider provider)
AventStack.ExtentReports.ExtentTest.Fail(Exception ex, MediaEntityModelProvider provider)
UtilityLibrary.Utilities.Hooks.Hooks.InsertReportingSteps(ScenarioContext InjectedText) in D:\DevOpsAgent\_work\8\s\UtilityLibrary\Utilities\Hooks\Hooks.cs: line 188 lambda_method(Closure , IContextManager , ScenarioContext )
TechTalk.SpecFlow.Bindings.BindingInvoker.InvokeBinding(IBinding binding, IContextManager contextManager, Object[] arguments, ITestTracer testTracer, TimeSpan& duration) in D:\a\1\s\TechTalk.SpecFlow\Bindings\BindingInvoker.cs: line 69
TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.InvokeHook(IBindingInvoker invoker, IHookBinding hookBinding, HookType hookType) in D:\a\1\s\TechTalk.SpecFlow\Infrastructure\TestExecutionEngine.cs: line 351
TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.FireEvents(HookType hookType) in D:\a\1\s\TechTalk.SpecFlow\Infrastructure\TestExecutionEngine.cs: line 340
TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.FireScenarioEvents(HookType bindingEvent) in D:\a\1\s\TechTalk.SpecFlow\Infrastructure\TestExecutionEngine.cs: line 321
TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.OnStepEnd() in D:\a\1\s\TechTalk.SpecFlow\Infrastructure\TestExecutionEngine.cs: line 304
TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.ExecuteStep(IContextManager contextManager, StepInstance stepInstance) in D:\a\1\s\TechTalk.SpecFlow\Infrastructure\TestExecutionEngine.cs: line 470
TechTalk.SpecFlow.Infrastructure.TestExecutionEngine.Step(StepDefinitionKeyword stepDefinitionKeyword, String keyword, String text,
String multilineTextArg, Table tableArg) in D:\a\1\s\TechTalk.SpecFlow\Infrastructure\TestExecutionEngine.cs: line 581
TechTalk.SpecFlow.TestRunner.Given(String text, String multilineTextArg, Table tableArg, String keyword) in D:\a\1\s\TechTalk.SpecFlow\TestRunner.cs: line 79
HappyTest.Features.CPUF.YPUCC(Anonymized Data Fields Here) in D:\DevOpsAgent\_work\8\s\HappyTest\Features\CreatePersonalUser.feature: line 12
HappyTest.Features.CPUF.YPUCC_1() in D:\DevOpsAgent\_work\8\s\HappyTest\Features\CreatePersonalUser.feature: line 11
-> Loading plugin D:\DevOpsAgent\_work\8\s\HappyTest\bin\Release\TechTalk.SpecFlow.MSTest.SpecFlowPlugin.dll
-> Using app.config
Given The user navigates to Sbn Test
:: The page type is HappyTest.Pages.BasePage
:: Sbn Test Page Displayed
-> done: BaseScenarioSteps.GivenUserNavigatesToSbnTest() (2.0s)
Given The user selects Personal Subscribe Yearly
:: The page type is HappyTest.Pages.SbnHome
-> error: Timed out after 10 seconds
:: WebDriver Stopped
YAML
pool:
name: qa-automation
demands:
- msbuild
- visualstudio
variables:
BuildPlatform: ''
BuildConfiguration: 'Debug'
steps:
- task: NuGetToolInstaller@1
displayName: 'Use NuGet 5.3.1'
inputs:
versionSpec: 5.3.1
- task: NuGetCommand@2
displayName: 'NuGet restore'
inputs:
restoreSolution: SeleniumTest.sln
- task: VSBuild@1
displayName: 'Build solution SeleniumTest.sln'
inputs:
solution: SeleniumTest.sln
platform: '$(BuildPlatform)'
configuration: '$(BuildConfiguration)'
- task: PublishSymbols@2
displayName: 'Publish symbols path'
inputs:
PublishSymbols: false
- task: CopyFiles@2
displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
inputs:
SourceFolder: '$(system.defaultworkingdirectory)'
Contents: '**\bin\$(BuildConfiguration)\**'
TargetFolder: '$(build.artifactstagingdirectory)'
CleanTargetFolder: true
OverWrite: true
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
- task: VisualStudioTestPlatformInstaller@1
displayName: 'Visual Studio Test Platform Installer'
inputs:
versionSelector: latestStable
- task: VSTest@2
displayName: 'VsTest - testAssemblies'
inputs:
testAssemblyVer2: |
!**\*TestAdapter.dll
**\HappyTest.exe
!**\obj\**
runTestsInIsolation: true
otherConsoleOptions: '/Tests:Happy_1'
testRunTitle: 'Validate Specflow Data Table Tests'
diagnosticsEnabled: true
collectDumpOn: always
VS 操作尝试失败
- 将 SpecFlow 更新到 Beta 3.3
- 更新了 Selenium 和大多数其他软件包
- 更新了 app.config 中的依赖项
- 将 .NET Framework 更新到 4.6.2,然后恢复
- 在浏览器渲染之前和之后添加了额外的等待
- 尝试在构建平台上的 x86 与 x64 与任何 cpu 架构之间切换
- 使用完整的 app.config
- 添加了 60 秒 WebDriverWait
Azure 操作尝试失败:
- 更改了构建和发布任务的多个参数
- 将所有变量从发布更改为调试
- 在 Azure 和本地代理上尝试测试
- 将 Visual Studio 版本从 2017 更改为 2019 和最新的 VS 构建任务
- 隔离检查运行测试
- 推送包文件夹以释放 Drop
解决方案
推荐阅读
- sql - 如何在 Croud Repository 中查找特定列不同的最后 10 个实体?
- android - 如果我设置的触发时间已经过去,如何让 AlarmManager 不执行我的通知?
- c - Eclipse-Photon 三元算子编译错误
- java - 从迭代器中删除数组中元素的最佳方法是什么?
- c# - 实体框架两次添加相同的实体
- c - HackerRank 上的对角线差
- sql - 引用表中没有主键或候选键
- python-3.x - 如何在 pytorch 中将模型中的每个参数的 require_grad 更改为 false?
- jackson - 以 CBOR 格式解码 VALUE_EMBEDDED_OBJECT 令牌类型
- python - 获取 numpy genfromtxt 的常量“(得到 12 列而不是 11 列)”错误。我已经尝试过其他帖子的解决方案,但没有一个有效