Cmd.exe已退出,代码为';5';在Azure DevOps上,一次运行多个python测试脚本

Cmd.exe已退出,代码为';5';在Azure DevOps上,一次运行多个python测试脚本,python,azure,testing,cmd,azure-devops-pipelines,Python,Azure,Testing,Cmd,Azure Devops Pipelines,我试图在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.xm

我试图在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_u表示法,使测试用例易于识别。 每个test_Suite1.py文件中包含的单元测试都与selenium 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管道中编写大量执行脚本步骤。

我建议您从
cmd.exe
/C
参数中删除
CALL
cmd.exe
也不需要
/S
选项!也共享您的autotest_main.py脚本。有一个打字错误,没有autotest_main.py文件,只有autotest_main.py,所以我再次编辑了这个问题。@Donatodipiero,您为什么在两小时内登录并发布了对一条评论的回复,却忽略了十小时前的评论?你也比那晚了三个小时再次登录,所以我不确定为什么你没有响应@很抱歉,我不是DevOps管理员,所以我必须请他试试你的建议,我会让你知道它是否有效,这就是原因。