设定:
我们在C#中有一个测试套件可以进行设置:它在TestRail中检查测试计划中存在哪些测试,并写入一个测试列表的文件。 Jenkins的构建有两个构建步骤(在pull& build之后):
/runlist
NUnit参数拉入该列表。当有要运行的测试时,这非常有效。
但是,由于[完全独立的实现],有时该文件为空。因此,“运行与列表”构建步骤的NUnit结果:
Tests run: 0, Errors: 0, Failures: 0, Inconclusive: 0, Time: 0.010100375885762 seconds
Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0
这告诉Jenkins这一步失败了:
C:\Program Files (x86)\Jenkins\jobs\[job_name]\workspace>exit 0
Archiving artifacts
Recording NUnit tests results
No test report files were found. Configuration error?
Build step 'Publish NUnit test result report' changed build result to FAILURE
Email was triggered for: Failure
Sending email for trigger: Failure
我想要的是两件事之一:
如何配置Jenkins / this build以实现这一目标?
答案 0 :(得分:1)
我相信我找到了自己问题的答案。
步骤:
我的批处理文件代码:
@echo off
REM Retrieve the build name.
set arg1=%1
REM Set the file name.
set file="C:\Path\To\TestsToRunFile\%arg1%.txt"
REM Get the file size.
FOR /F "usebackq" %%A IN ('%file%') DO set size=%%~zA
REM Exit codes based on the file size.
IF %size% EQU 0 (
exit /b 0
) ELSE (
exit /b 1
)