簡體   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