我目前正在使用Visual Studio Enterprise 2015版本14.0.25431.01 Update 3,並使用MS c#示例程序來測試內置單元測試和代碼覆蓋功能。單元測試工作完全正常,但每次我嘗試測試完成後,啓動代碼覆蓋率,我得到一個錯誤消息說:產生Visual Studio 2015更新3代碼覆蓋問題
「空的結果:沒有二進制文件儀表確保測試跑,所需的二進制文件已加載,具有匹配的符號文件,並且未通過自定義設置排除。有關詳細信息,請參閱:http://go.microsoft.com/fwlink/?LinkID=253731。「。
當然,我檢查了鏈接進行故障排除,並通過所有列出的問題,但沒有任何成功。我還嘗試了幾個應該在早期版本中工作的解決方案(使用命令promp來測試二進制代碼或運行代碼覆蓋率,刪除測試結果文件夾和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.");
}
}
}
你有看看https://blogs.msdn.microsoft.com/allendm/2012/06/05/troubleshooting-missing-data-in-code-coverage-results/ – allen
感謝您的迴應。我將檢查頁面,分析輸出文件爲空。所以看起來在我的測試運行期間,二進制文件不會被加載到內存中。任何想法如何解決這個問題?我的設置有問題嗎?我的測試運行沒有任何錯誤,所以我也檢查了這一點。 – Steve