在Jenkins下运行时,VSTest.console.exe会生成空的.coverage文件 [英] VSTest.console.exe when run under Jenkins generate empty .coverage file

查看:132
本文介绍了在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.

  1. 按获胜+ R
  2. 输入"services.msc",然后按Enter
  3. 找到詹金斯"服务并双击它
  4. 转到登录"标签
  5. 选中此帐户"半径按钮
  6. 输入您的本地帐户和密码
  7. 应用设置
  8. 重新启动Jenkins服务

然后,问题解决了!

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

Hope this solution is helpful to you^^

这篇关于在Jenkins下运行时,VSTest.console.exe会生成空的.coverage文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆