繁体   English   中英

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

[英]Visual Studio 2015 update 3 code coverage issues

我目前正在使用Visual Studio Enterprise 2015版本14.0.25431.01 Update 3,并使用MS c#示例程序来测试内置的单元测试和代码覆盖功能。 单元测试工作正常,但是每次尝试在测试结束后尝试覆盖代码时,都会收到一条错误消息:

“生成的结果为空:未检测到二进制文件。确保运行了测试,加载了所需的二进制文件,具有匹配的符号文件,并且未通过自定义设置排除。有关更多信息,请参见: http : //go.microsoft.com/fwlink /?LinkID = 253731。 ”。

当然,我检查了链接以进行故障排除,并在那里解决了所有列出的问题,但是没有成功。 我还尝试了一些应该在较早版本中可用的解决方案(使用命令提示符来检测二进制文件或运行代码覆盖率,删除测试结果文件夹和VS解决方案用户选项.suo文件等),但仍然没有找到任何解决方案对我的案子有用。

是否有人面临相同的问题或知道可能的解决方案?

提前非常感谢您!

最好,

史蒂夫

PS:我使用的是标准设置,但是所有优化都已关闭。 我的测试项目与我要测试的源项目位于同一解决方案中。 这是示例程序的代码:

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;
        }
    }
}
}

测试类的定义如下:

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.");
        }
    }
}

我一直在寻找解决方案。 并发现这实际上是PDB文件问题。 您所需要做的就是转到此链接器选项卡->调试。 并将选项“生成完整的程序数据库文件”设置为“是”。 这是由于VS2015为/ Debug:FASTLINK引入了更改。 将其设置为“是”将会覆盖它。

暂无
暂无

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

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