一口气运行多个python测试脚本时,Cmd.exe在Azure DevOps上以代码``5''退出

问题描述

我正在尝试在Azure DevOps管道中执行多个python脚本,但是“ ## [error] Cmd.exe退出,代码为'5'。”返回,显然没有任何测试用例的标识。

在管道的“执行脚本”步骤中,已写入以下命令:

 "C:\Program Files\Python\Python38\python.exe"  -m pytest $(System.DefaultWorkingDirectory)\autotest_main.py -v --junitxml=test-results.xml --html=report.html --self-contained-html

,这很好用,直到脚本“ autotest_main.py”仅包含带有测试用例的套件。但是我需要组织很多测试用例,因此起点是如下所示的autotest_main.py脚本:

import os

os.system('test_Preconditions.py')
os.system('test_Suite1.py')
os.system('test_Suite2.py')
os.system('test_Suite3.py')
os.system('test_Suite4.py')

我还使用了test_表示法来使测试用例易于识别。 每个test_Suite1.py文件都包含与硒Webdriver结合使用的单元测试,以测试Web应用程序的前端。 当我在本地计算机上运行脚本时,一切正常,但是当我使用azure devops运行脚本时,“ ## [error] Cmd.exe退出,代码为'5'。”返回。 这里的日志:

##[section]Starting: execute script
==============================================================================
Task         : Command line
Description  : Run a command line script using Bash on Linux and macOS and cmd.exe on Windows
Version      : 2.176.1
Author       : Microsoft Corporation
Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/command-line
==============================================================================
Generating script.
Script contents:
"C:\Program Files\Python\Python38\python.exe"  -m pytest C:\agent\_work\12\s\autotest_main.py -v --junitxml=test-results.xml --html=report.html --self-contained-html
========================== Starting Command Output ===========================
##[command]"C:\Windows\system32\cmd.exe" /D /E:ON /V:OFF /S /C "CALL "C:\agent\_work\_temp\b653526f-53a0-4ac7-8a22-50698ed4ba58.cmd""
============================= test session starts =============================
platform win32 -- Python 3.8.3,pytest-6.1.0,py-1.9.0,pluggy-0.13.1 -- C:\Program Files\Python\Python38\python.exe
cachedir: .pytest_cache
metadata: {'Python': '3.8.3','Platform': 'Windows-10-10.0.14393-SP0','Packages': {'pytest': '6.1.0','py': '1.9.0','pluggy': '0.13.1'},'Plugins': {'html': '2.1.1','metadata': '1.10.0','nunit': '0.6.0'}}
rootdir: C:\agent\_work\12\s
plugins: html-2.1.1,metadata-1.10.0,nunit-0.6.0
collecting ... collected 0 items
 
---------- generated xml file: C:\agent\_work\12\s\test-results.xml -----------
--------- generated html file: file://C:\agent\_work\12\s\report.html ---------
============================ no tests ran in 0.32s ============================
##[error]Cmd.exe exited with code '5'.
##[section]Finishing: execute script

是否有解决此问题的建议?我想尽可能避免在Azure管道中编写很多执行脚本步骤。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)