单元测试因CodeCoverage失败而出现多个错误,但通过了否则 [英] Unit Test Fails with multiple Errors with CodeCoverage but passes otherwise

查看:144
本文介绍了单元测试因CodeCoverage失败而出现多个错误,但通过了否则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 我从单元测试项目中删除了所有引用,并替换了它们.我希望这样做会有所帮助,但是没有帮助.
  • 似乎是在抱怨###.BusinessLayer.ServiceClient DLL,因此尽管测试运行了(即使没有该引用),但我还是明确地将其添加到了项目中.
  • 我正在使用默认的TestSettings文件,并且测试以32位模式运行
  • 测试是将数据绑定到csv文件
  • 我在64位操作系统上使用VS 2013 Ultimate
  • 这是我尝试过的另一件事.我创建了一个.runsettings文件,并从Test/TestSettings中激活了该文件.该文件中的几乎所有内容都已被注释掉,除了"SymbolSearchPath"之外.部分.在这里,我提到通向 具有所有测试的单元测试项目的Bin目录.

    有趣的是,现在我可以克服之前的错误(请参阅第一个图像),但是现在我得到了另一个错误.

    猜猜,令人困惑的是-如果我按原样运行它或对其进行调试(没有代码覆盖),则该测试有效.但是,当我使用Test Explorer中的Code Coverage进行相同操作时,它将失败.想知道我在这里可能会错过什么.

    谢谢!

    解决方案

    AmbhrinHalo,

    >>  ###.BusinessLayer.ServiceClient DLL

    您从这个dll文件中得到了什么?它是自定义类库吗?如果是这样,如何将源代码添加到与当前测试项目相同的解决方案中?然后再次收集代码覆盖率.

    不使用.runsettings文件,只需添加测试设置文件,然后在启用旧的代码覆盖工具后将所有dll文件添加到testsettings文件中.结果如何?

    如果仍然存在此问题,我怀疑真正的问题与测试项目或VS IDE无关,我们将检查您在当前测试项目中如何真正引用此dll文件.

    最好的问候,

    Jack


    When I run the Unit Test by itself, it runs just fine and does what it is expected to do.. However, I also need Code Coverage metrics from the run so I run the same test with Code Coverage and it does not even start but fails at the very onset.. 

    A couple of things that I tried at my end - 

    • I removed all references from my Unit Test Project and replaced them fresh ones. I was hoping that would help but did not..
    • It seems to complain about the ###.BusinessLayer.ServiceClient DLL so I explicitely added that to the project although my test ran (even w/o that reference). That did not help either
    • I am using the default TestSettings file and the tests are running in 32bit mode
    • The test is data bound to a csv file
    • I am using VS 2013 Ultimate on a 64 bit OS

    This is one other thing that I tried. I created a .runsettings file and from Test/TestSettings, made that as active.. Almost everything in that file has been commented out except for the "SymbolSearchPath" section.. Here I mention the path to the Bin Directory of the Unit Test Project which has all the tests.. 

    Interestingly, now I was able to get past my earlier error (refer the first image) but now I get a different one.. 

    Guess, what is perplexing is - The test just works if I just ran it as is or just debugged it (w/o code coverage). But it fails when I run the same with Code Coverage from Test Explorer. Wonder what I could be missing here.

    Would really appreciate some help!

    Thanks!

    解决方案

    Hi AmbhrinHalo,

    >> ###.BusinessLayer.ServiceClient DLL

    What did you get this dll file? Is it the custom class library? If so, how about add the source code to the same solution as your current test project? And then collect the code coverage again.

    Not use the .runsettings file, just add the test settings file, and then add all dlls file in the testsettings file after you enable the old code coverage tool. How about the result?

    If it still has this issue, I doubt that the real issue is not related to the test project or the VS IDE, we would check that how you really refer to this dll file in your current test project.

    Best Regards,

    Jack


    这篇关于单元测试因CodeCoverage失败而出现多个错误,但通过了否则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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