简体   繁体   中英

Visual Studio 2015 update 3 code coverage issues

I am currently working with Visual Studio Enterprise 2015 Version 14.0.25431.01 Update 3 and have used an MS c# example program to test the built-in unit test and code coverage function. The unit test is working perfectly fine, but everytime I try to start code coverage after the test finished, I get an error message saying:

"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 .".

Of course, I checked the link for troubleshooting and worked through all listed issues there, but without any success. I also tried several solutions which should have worked in earlier versions (use command promp to instrument binary or to run code coverage, deleting test results Folder and the VS Solution User Option .suo file, etc.), but still haven't found anything useful working for my case.

Does anybody face the same problem or knows a possible solution for it?

Thank you very much in advance!

Best,

Steve

PS: I am using the standard settings, but with all optimizations turned off. My test project is located in the same solution as my source project I want to test. Here is the code for the example program:

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

The Test Class is defined as followed:

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

i have been looking for the solution. and found that it's actually a PDB file problem. all you need to do is to go to this linker tab->debugging. and set option "Generate full program database file" to Yes. this is due to the change VS2015 introduced for /Debug:FASTLINK. setting it to 'yes' would override it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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