如何在GitHub Actions中运行Selenium测试

山姆

我正在尝试找到等效的命令来在GitHub action中运行Selenium测试在Azure DevOps中,我将使用此YAML运行“ Visual Studio测试”:

- task: VSTest@2
  displayName: 'Run functional smoke tests on website and web service'
  inputs:
    searchFolder: '$(build.artifactstagingdirectory)'
    testAssemblyVer2: |
      **\FeatureFlags.FunctionalTests\FeatureFlags.FunctionalTests.dll
    uiTests: true
    runSettingsFile: '$(build.artifactstagingdirectory)/drop/FunctionalTests/FeatureFlags.FunctionalTests/test.runsettings'
    overrideTestrunParameters: |
     -ServiceUrl "https://$(WebServiceName)-staging.azurewebsites.net/" 
     -WebsiteUrl "https://$(WebsiteName)-staging.azurewebsites.net/"  

在GitHub动作中,等效任务是什么?它看起来不像GitHub运行器/代理中存在VsTest.Console.exe,因此答案可能涉及安装Visual Studio测试平台安装程序-但显然我想避免这种情况,因为这会严重降低每个构建的速度。

山姆

感谢@Eldar,他帮助我指出了正确的方向。基本答案是(在Windows运行程序中运行):

- name: Functional Tests
  run: |
    $vsTestConsoleExe = "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\Common7\\IDE\\Extensions\\TestPlatform\\vstest.console.exe"
    $targetTestDll = "functionaltests\FeatureFlags.FunctionalTests.dll"
    $testRunSettings = "/Settings:`"functionaltests\test.runsettings`" "
    #Note that the `" is an escape character to quote strings, and the `& is needed to start the command
    $command = "`& `"$vsTestConsoleExe`" `"$targetTestDll`" $testRunSettings " 
    Write-Host "$command"
    Invoke-Expression $command
  shell: powershell

使用Invoke-Expression似乎可以解决我收到的一些初始错误。带有上下文的完整yaml在GitHub上可见

注意要找到vstest.console.exe文件,我使用了这个yaml搜索GitHub Actions运行程序。有些文件夹已锁定,因此如果您在根C:文件夹中进行搜索,则会引发错误。通过上面提供链接,我能够建立Visual Studio的根文件夹,并在其中搜索vstest.console.exe:

- name: search for visual studio test runner
  run: |
    $var1 = Get-Childitem -Path "C:\Program Files (x86)\Microsoft Visual Studio" -Filter "vstest.console.exe" -Recurse | select -ExpandProperty FullName
    Write-Host "VS test runner: $var1"
  shell: powershell

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在GitHub Actions中运行Postgres以测试我的Go API

GitHub Actions运行Espresso测试

如何在Github Actions中设置秘密?

如何在Github Actions中丢掉工作?

如何在Chrome中运行Selenium WebDriver测试用例?

如何在 selenium webdriver 框架中运行 jmeter 性能测试

github-actions如何在(生产)构建结果而不是开发模式上运行测试

如何在本地测试和模拟 GitHub Actions 开发的场景

如何在Github Desktop中运行隐藏?

如何在Github Actions中运行Pandoc“转换Dir中的所有文件”命令

如何在GitHub Actions中的运行之间缓存已安装的工具?

在 Github Actions 中设置 Capybara / Selenium 测试时遇到问题

如何在Github Actions中使用机密?

如何配置Capybara在dockerized的Selenium Grid中运行测试?

如何在GitHub Actions CI / CD中构建Flutter

如何在 GitHub Actions 中实现 ./cloud_sql_proxy?

如何在Github Actions步骤中强制退出

如何在Github Actions中设置Docker用户

如何在GitHub Actions中缓存yarn包

如何在 Github Actions 中設置 Rubocop

如何在GitHub Actions中设置和访问Workflow变量?

如何在推送事件中跳过GitHub Actions工作?

如何在Github Actions CI / CD中访问服务?

如何在 GitHub Actions 中设置 Dockerfile 标签?

如何在自托管运行器上为GitHub Actions修复'GitHub.Services.OAuth.VssOAuthTokenRequestException'

如何让Jenkins运行我的Maven / Selenium GitHub测试

如何在本地测试github CI?

如何从GitHub Actions运行Tox

如何在Github中显示我的测试通过/失败?