简体   繁体   English

Visual Studio 2015更新3代码覆盖问题

[英]Visual Studio 2015 update 3 code coverage issues

I am currently working with Visual Studio Enterprise 2015 Version 14.0.25431.01 Update 3 and have used an MS c# example program to test the built-in unit test and code coverage function. 我目前正在使用Visual Studio Enterprise 2015版本14.0.25431.01 Update 3,并使用MS c#示例程序来测试内置的单元测试和代码覆盖功能。 The unit test is working perfectly fine, but everytime I try to start code coverage after the test finished, I get an error message saying: 单元测试工作正常,但是每次尝试在测试结束后尝试覆盖代码时,都会收到一条错误消息:

"Empty results generated: No binaries were instrumented. Make sure the tests ran, required binaries were loaded, had matching symbol files, and were not excluded through custom settings. For more information see: http://go.microsoft.com/fwlink/?LinkID=253731 .". “生成的结果为空:未检测到二进制文件。确保运行了测试,加载了所需的二进制文件,具有匹配的符号文件,并且未通过自定义设置排除。有关更多信息,请参见: http : //go.microsoft.com/fwlink /?LinkID = 253731。 ”。

Of course, I checked the link for troubleshooting and worked through all listed issues there, but without any success. 当然,我检查了链接以进行故障排除,并在那里解决了所有列出的问题,但是没有成功。 I also tried several solutions which should have worked in earlier versions (use command promp to instrument binary or to run code coverage, deleting test results Folder and the VS Solution User Option .suo file, etc.), but still haven't found anything useful working for my case. 我还尝试了一些应该在较早版本中可用的解决方案(使用命令提示符来检测二进制文件或运行代码覆盖率,删除测试结果文件夹和VS解决方案用户选项.suo文件等),但仍然没有找到任何解决方案对我的案子有用。

Does anybody face the same problem or knows a possible solution for it? 是否有人面临相同的问题或知道可能的解决方案?

Thank you very much in advance! 提前非常感谢您!

Best, 最好,

Steve 史蒂夫

PS: I am using the standard settings, but with all optimizations turned off. PS:我使用的是标准设置,但是所有优化都已关闭。 My test project is located in the same solution as my source project I want to test. 我的测试项目与我要测试的源项目位于同一解决方案中。 Here is the code for the example program: 这是示例程序的代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace codecoverage

{
public class Program
{

    static void Main(string[] args)
    {
        Program prog = new Program();
        prog.TestFunction(0);
    }

    public int TestFunction(int input)
    {
        if (input > 0)
        {
            return 1;
        }

        else
        {
            return 0;
        }
    }
}
}

The Test Class is defined as followed: 测试类的定义如下:

using Microsoft.VisualStudio.TestTools.UnitTesting;
using codecoverage;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace codecoverage.Tests
{
    [TestClass()]
    public class ProgramTests
    {
        [TestMethod()]
        public void TestFunctionTest2()
        {
            Program target = new Program();
            int input = 1;
            int expected = 1;
            int actual;
            actual = target.TestFunction(input);
            Assert.AreEqual(expected, actual, "CodeCoverage.Program.TestFunction did not return the expected value.");
        }
    }
}

i have been looking for the solution. 我一直在寻找解决方案。 and found that it's actually a PDB file problem. 并发现这实际上是PDB文件问题。 all you need to do is to go to this linker tab->debugging. 您所需要做的就是转到此链接器选项卡->调试。 and set option "Generate full program database file" to Yes. 并将选项“生成完整的程序数据库文件”设置为“是”。 this is due to the change VS2015 introduced for /Debug:FASTLINK. 这是由于VS2015为/ Debug:FASTLINK引入了更改。 setting it to 'yes' would override it. 将其设置为“是”将会覆盖它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM