我正在尝试找到等效的命令来在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] 删除。
我来说两句