【发布时间】:2014-05-13 06:29:09
【问题描述】:
在Bamboo上,我有MSBuild 的工作来构建和运行测试。
它工作正常 - 但我想使用 test quarantine 选项,所以当我将一些测试转移到隔离区时(并且这个移动的测试只是失败的原因)作业将被标记为成功
我将一项失败的测试转移到隔离区,但作业被标记为失败
配置:
在Job -> Tasks 我有Command 命名为Test runner:
可执行文件 = VSTest.Console
参数 = "WebServiceTestClient.dll" /Logger:trx
在运行测试失败的作业后,我得到了日志
01-Apr-2014 10:59:44 Total tests: 62. Passed: 61. Failed: 1. Skipped: 0.
01-Apr-2014 10:59:44 Test Run Failed.
01-Apr-2014 10:59:44 Test execution time: 10.1296 Minutes
01-Apr-2014 10:59:44 Failing task since return code of [C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\VSTest.Console.exe "WebServiceTestClient.dll" /Logger:trx] was 1 while expected 0
01-Apr-2014 10:59:44 Finished task 'Test runner'
01-Apr-2014 10:59:44 Starting task 'Parse test logs' of type 'com.atlassian.bamboo.plugin.dotnet:mstest'
01-Apr-2014 10:59:44 Parsing test results...
01-Apr-2014 10:59:45 Failing task since 1 failing test cases were found.
作业被标记为失败,但随后:
01-Apr-2014 10:59:45 Changing Task Result to SUCCESS as all failed tests were quarantined.
01-Apr-2014 10:59:45 Finished task 'Parse test logs'
01-Apr-2014 10:59:45 Running post build plugin 'NCover Results Collector'
01-Apr-2014 10:59:45 Running post build plugin 'Clover Results Collector'
01-Apr-2014 10:59:45 Running post build plugin 'Artifact Copier'
01-Apr-2014 10:59:45 Finalising the build...
不幸的是,输出是:
【问题讨论】:
-
Bambo 将除 0 以外的所有返回视为失败,而通常程序在出现警告(或类似情况)时返回 1。所以我的解决方法是使用内联脚本任务(而不是命令任务),在任务中首先运行 vstest.console 然后捕获返回值(
%ERRORLEVEL%)如果它是 1 然后执行EXIT /B 0 -
谢谢 tmlai... 您的评论实际上就是答案。我创建了一个执行测试的 powershell 脚本并添加了一个新任务来解析 mstest trx。