我当前在使用MStest插件时遇到奇怪的效果。仅当测试成功时才生成我的测试报告,但是当测试失败时,则不会生成任何测试报告。多亏了这个答案,Jenkins integration for dotnet test我的管道看起来像这样
node {
stage('Checkout') {
cleanWs()
checkout scm
return
skipRemainingStages = true
}
stage('Restore') {
sh "dotnet restore $project1"
}
stage('Build') {
sh "dotnet publish $project1 --output $outputFolder --configuration Release -p:Version=$buildVersion -p:FileVersion=$buildVersion"
}
stage ('Unit test') {
sh "dotnet restore $UnitTest"
sh returnStdout: true, script: "dotnet test $UnitTest --logger \'trx;LogFileName=unit_tests.xml\' "
step ([$class: 'MSTestPublisher', testResultsFile:"**/*.xml", failOnError: true, keepLongStdio: true])
}
}
日志:
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Results File: /var/jenkins_home/workspace/myproject/Build_master/myproject/TestResults/unit_tests.xml
Total tests: 16. Passed: 8. Failed: 8. Skipped: 0.
Test Run Failed.
Test execution time: 15.9443 Seconds
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 1
Finished: FAILURE
我不知道为什么测试失败时不生成测试报告。 谢谢 enter image description here
答案 0 :(得分:0)
您的测试无法通过构建,因此您实际上从未发布过测试结果。
您可以通过两种方法解决此问题-将测试配置为在失败的测试中不返回非零状态。
或者忽略它
var MeSeContext = document.getElementById("MeSeStatusCanvas").getContext("2d");
var MeSeData = {
labels: [
"AMER",
"APAC",
"EMEA"
],
datasets: [{
label: ['SFO'],
data: [23.2, 0, 0],
backgroundColor: 'red'
},
{
label: ['CHI'],
data: [6.3, 0],
backgroundColor: 'brown'
},
{
label: ['INDIA'],
data: [0, 3, 0],
backgroundColor: 'green'
},
{
label: ['ANZ'],
data: [0, 7, 0],
backgroundColor: 'lightgreen'
}
]
};
var MeSeChart = new Chart(MeSeContext, {
type: 'horizontalBar',
data: MeSeData,
options: {
responsive: true,
scales: {
xAxes: [{
stacked: true,
}],
yAxes: [{
stacked: true,
}]
}
}
});