Visual Studio 2015更新3个代码覆盖问题
Visual Studio 2015 update 3 code coverage issues
我目前正在使用 Visual Studio Enterprise 2015 Version 14.0.25431.01 Update 3 并使用 MS c# 示例程序来测试内置的单元测试和代码覆盖功能。单元测试运行良好,但每次我在测试完成后尝试开始代码覆盖时,都会收到一条错误消息:
"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.".
当然,我检查了 link 以进行故障排除并解决了那里列出的所有问题,但没有任何成功。我还尝试了几个应该在早期版本中工作的解决方案(使用命令提示符来检测二进制文件或 运行 代码覆盖率,删除测试结果文件夹和 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;
}
}
}
}
测试Class定义如下:
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文件的问题。您需要做的就是转到此链接器选项卡-> 调试。并将选项 "Generate full program database file" 设置为是。这是由于 VS2015 为 /Debug:FASTLINK 引入的更改。将其设置为 'yes' 会覆盖它。
我目前正在使用 Visual Studio Enterprise 2015 Version 14.0.25431.01 Update 3 并使用 MS c# 示例程序来测试内置的单元测试和代码覆盖功能。单元测试运行良好,但每次我在测试完成后尝试开始代码覆盖时,都会收到一条错误消息:
"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.".
当然,我检查了 link 以进行故障排除并解决了那里列出的所有问题,但没有任何成功。我还尝试了几个应该在早期版本中工作的解决方案(使用命令提示符来检测二进制文件或 运行 代码覆盖率,删除测试结果文件夹和 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;
}
}
}
}
测试Class定义如下:
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文件的问题。您需要做的就是转到此链接器选项卡-> 调试。并将选项 "Generate full program database file" 设置为是。这是由于 VS2015 为 /Debug:FASTLINK 引入的更改。将其设置为 'yes' 会覆盖它。