在Jenkins下运行时,VSTest.console.exe会生成空的.coverage文件

编程入门 行业动态 更新时间:2024-10-28 06:29:57
本文介绍了在Jenkins下运行时,VSTest.console.exe会生成空的.coverage文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我使用Jenkins对.Net Framework项目进行了简单的构建配置.该项目使用单元测试.

I have a simple build configuration with Jenkins for a .Net Framework project. The project uses Unit Tests.

当我在Jenkins下使用VSTestRunner插件运行测试时,它将生成测试报告.trx以及.coverage文件.找到所有测试并正常运行,但是生成的.coverage文件始终为空(大小为10B,没有覆盖数据).我曾尝试在詹金斯(Jenkins)中将该命令作为Shell Execution命令执行.但是它仍然给出相同的结果,即空的.coverage文件.命令是:

When I run the tests using VSTestRunner plugin under Jenkins, it generates test report .trx as well as .coverage file. All the tests are found and run properly but .coverage file generated is always empty (10B in size and no coverage data). I have tried to give the command as a Shell Execution command in Jenkins. But it still gives same result, i.e. empty .coverage file. Command is:

"C:\ Program Files(x86)\ Microsoft Visual Studio \ 2017 \ Enterprise \ Common7 \ IDE \ CommonExtensions \ Microsoft \ TestWindow \ vstest.console.exe""CompletePathToLibraries.UnitTest.dll"/Enablecodecoverage/InIsolation/Framework:Framework45/Logger:trx

"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" "CompletePathToLibraries.UnitTest.dll" /Enablecodecoverage /InIsolation /Framework:Framework45 /Logger:trx

但是,如果我从Jenkins外部运行相同的命令,即通过手动启动命令提示符运行命令,它会生成包含所需数据的完美.coverage文件.

But if I run the same command from outside Jenkins, i.e. a by manually launmching command prompt, it generates perfect .coverage file with expected data in it.

系统配置:Windows 10专业版詹金斯2.121.2Visual Studio企业版2017Jenkins作为服务安装,并在NT AUTHORITY \ SYSTEM帐户下运行.

System config: Windows 10 Pro Jenkins 2.121.2 Visual Studio Enterprise 2017 Jenkins is installed as service and is running under NT AUTHORITY\SYSTEM account.

推荐答案

我遇到了同样的问题,我只是用这种方式解决:我发现Jenkins服务器将使用与您的内置计算机用户不同的用户来执行cmd.因此,我决定更改uesr帐户,使其与我的内置计算机用户帐户相同.

I've got the same problem, and I just solve in this way: I found that Jenkins Server will execute the cmd with an user which differ to your built machine user. Therefore, I decide to change the uesr account to make it same as my built machine user account.

  • 按获胜+ R
  • 输入"services.msc",然后按Enter
  • 找到詹金斯"服务并双击它
  • 转到登录"标签
  • 选中此帐户"半径按钮
  • 输入您的本地帐户和密码
  • 应用设置
  • 重新启动Jenkins服务
  • 然后,问题解决了!

    希望此解决方案对您有帮助^^

    Hope this solution is helpful to you^^

    更多推荐

    在Jenkins下运行时,VSTest.console.exe会生成空的.coverage文件

    本文发布于:2023-11-16 14:58:45,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1605326.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:文件   VSTest   Jenkins   console   coverage

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!