首页 > 解决方案 > Bamboo:如何运行 xunit 测试(脚本任务),然后将其提供给“xunit 解析器”

问题描述

我在项目的 Bamboo 计划下配置了 xunit 解析器任务,我运行了我的计划:启动类型为 'com.wwwlicious.xunit.xunit:xunitParser' 的任务 'Xunit' 失败的任务,因为预期有测试用例,但没有找到。

我的xunit解析器只解析从上一步以某种方式产生的测试结果?

我尝试添加一个脚本任务来手动运行 xunit 测试:https ://xunit.github.io/docs/getting-started/netcore/cmdline

C:\SomeApplication>dotnet test -l:trx;LogFileName=SomeApplTests.xml
Build completed.
Test run for C:\SomeApplication\bin\Debug\netcoreapp2.0\YI.LS.Test.dll(.NETCoreApp,Version=v2.0)
Microsoft (R) Test Execution Command Line Tool Version 15.9.0
Copyright (c) Microsoft Corporation.  All rights reserved.
Starting test execution, please wait...
Total tests: 20. Passed: 20. Failed: 0. Skipped: 0.
Test Run Successful.
Test execution time: 4.3114 Seconds

所以,好吧 - 我可以配置一个 Bamboo脚本任务来运行“dotnet test”,它会在“ TestResult ”文件夹下生成 SomeApplTests.xml 。现在的挑战是:如何将它提供给xunit 解析器?另外 trx logger 也不好,prolly 需要 xunit logger https://github.com/spekt/xunit.testlogger

谢谢

参考:
https ://marketplace.atlassian.com/apps/1216522/xunit-net-parser?hosting=server&tab=support
https://github.com/wwwlicious/wwwlicious.bamboo.xunit/issues/6
如何发布结果使用 dotnet 测试命令

https://github.com/spekt/xunit.testlogger

标签: bambooxunit.net

解决方案


找到答案:

您需要安装在测试项目“XunitXmlTestLogger”(https://github.com/spekt/xunit.testlogger)然后配置脚本任务: dotnet test -l:"xunit;LogFileName=Test.xml" 您需要将工作目录设置为指向您的测试项目,例如:MySoln\MyTestProj

然后在 Bamboo 中配置您的 xUnit.net Parser 任务,将 xUnit 测试结果文件/目录指向:MySoln\MyTestProj*.xml(默认为:artifacts/**/*.xml)

https://github.com/wwwlicious/wwwlicious.bamboo.xunit/issues/6


推荐阅读