问题
This worked before SP1 was installed.
namespace Test
{
public class Adder
{
public int Add(int n1, int n2)
{
return n1 + n2;
}
}
}
namespace AdderTest
{
[TestFixture]
public class Class1
{
[Test]
public void AddTest1()
{
var add = new Adder();
var res = add.Add(2, 3);
Assert.AreEqual(5, res);
}
}
}
This command still works after SP1 installed
vstest.console.exe /usevsixextensions:true /framework:framework45 /platform:x86 AdderTest.dll
This one doesn't and it fails on every PC in our team where SP1 is installed.
vstest.console.exe /enablecodecoverage /usevsixextensions:true /framework:framework45 /platform:x86 AdderTest.dll
Error: The active Test Run was aborted because the execution process exited unexpectedly. Check the execution process logs for more information. If the logs are not enabled, then enable the logs and try again.
The logs show the following error:
V, 10664, 11, 2016/02/02, 15:00:09.114, 2115392201142, vstest.console.exe, TestRunRequest:SendTestRunMessage: Starting.
I, 10664, 11, 2016/02/02, 15:00:09.116, 2115392205435, vstest.console.exe, TestRunRequest:SendTestRunMessage: Completed.
E, 10664, 10, 2016/02/02, 15:00:23.722, 2115441528953, vstest.console.exe, TAEF Engine Execution: [HRESULT: 0x800706BA] Failed to create the test host process for out of process test execution. (The test host process failed to run with exit code 0xc0000005. Failed to set up communication with the test host process. (The connection attempt timed out.))
It appears SP1 installed all new vstest exe's and DLL's, also seemed to install the TAEF stuff, although I am using windows 7
Using NUnit 2.6 & the VS Nunit Test runner extension (also tried NUint 3.0 with it's test runner - still broke)
We are using VSTEST because our code is a combination of C++/C# and 64 bit components. We need unite and coverage tests.
Update:
Used VS 2105 to write an intellitest - that fails the same way running coverage.
回答1:
This is a regression in VS 2015 Update 1. Wex.Communication.dll was calling GetModuleFileNameExW while its global variables were being initialized. On Windows 7 while collecting code coverage, this API caused Wex.Communication.dll to be unloaded. When GetModuleFileNameExW returned, the process crashed because the DLL was unloaded. I've fixed this to wait until after the DLL has fully loaded to call GetModuleFileNameExW, which prevents the crash. (I'm a Software Engineer who works on TAEF at Microsoft.) The fix will ship in a future VS 2015 update.
To work around this, disable TAEF by setting the registry value named "Value" to 0 in the HKEY_CURRENT_USER\SOFTWARE\Microsoft\VisualStudio\14.0_Config\FeatureFlags\TestingTools\UnitTesting\Taef key. (VSTest has two implementations in VS 2015. When TAEF is disabled, the old implementation from VS 2013 is used. The TAEF-based implementation is new in VS 2015.)
回答2:
See this link https://github.com/mmanela/chutzpah/issues/387
The entry by mmanela on Sep 1, 2015
Setting the registry key mentioned in this link resolved the issue. Microsoft told me this was a workaround and not a fix.
来源:https://stackoverflow.com/questions/35163843/vstestcode-coverage-broken-after-sp1-for-visual-studio-2015-installed