【发布时间】:2016-10-12 10:15:14
【问题描述】:
我目前正在使用 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.");
}
}
}
【问题讨论】:
-
感谢您的回复。我将检查页面,分析输出文件为空。因此,在我的测试运行期间,二进制文件似乎没有加载到内存中。任何想法如何解决这个问题?我的设置有问题吗?我的测试运行没有任何错误,所以我也检查了。
标签: c# visual-studio-2015 code-coverage