8

This is what I'm getting when I build my Test project:

VS 11 Unit Testing Unexpected Error

With this I'm unable to run my tests since they're not being discovered by VS.

See the message "Unexpected error detected. Check the Tests Output Pane for details." at the window bottom. Now if you look at the Tests OUTPUT pane you'll have no clue about what's the problem. This is extremely helpful... :)

I know VS 11 is in beta but it used to work...

I've already restarted VS but it didn't work after that too.

Any ideas about what's going on? Would it be a bug somewhere?

Note: the only thing I can think is related with VS 2010 uninstall I did sometime ago. Maybe it uninstalled some necessary bits. Beats me...

EDIT 1
I just did a repair on VS 11 Beta Ultimate. It asked to reboot the computer once and I did. Then it continued the repair but kept working for more than 12 hours. I just killed the repair process.

In the meantime I uninstalled Visual Studio 11 Express for Web. I had this one side by side with VS 11 Beta Ultimate.

Crazily enough, it started working again after I did both things. So I don't know for sure what has solved the problem: the killed repair process or the uninstall of VS 11 Express for Web.

EDIT 2
For my disappointment now I see this is an intermittent thing. After restarting VS 11 Ultimate Beta the problem persists. :(

EDIT 3
I filled a Connect ticket at Microsoft but they closed it as not reproducible.

I made a 2nd try with VS 11 Ultimate Beta repair option and this time it finished as expected. To isolate the problem I created a brand new test project with a default UnitTest1.cs file within a new Solution and after building it I get the same error screen as shown above. So the repair option did not solve the problem. Looks like something is missing in my system.

This is the info from VS About window:

Microsoft Visual Studio 11
Version 11.0.50323.1 QRELB
Microsoft .NET Framework
Version 4.5.50131 QRELB

Installed Version: Ultimate

EDIT 4
I found a similar problem here but the solution given there doesn't apply in my case since I do not have the DLL described.

EDIT 5
With the help of Aseem Bansal's (a Microsoft employee) I finally got the logs and saw this exception:

W, 2124, 19, 2012/04/19, 11:51:32.644, 53768626724, devenv.exe, Exception occured while initialization System.InvalidOperationException: Cannot start process because a file name has not been provided.
   at System.Diagnostics.Process.Start()
   at Microsoft.VisualStudio.TestPlatform.Core.Utilities.CommonUtilities.LaunchProcess(String exeFileName, String commandLineArguments, String workingDirectory, IDictionary`2 environmentVariables)
   at Microsoft.VisualStudio.TestPlatform.Client.TestRunnerServiceClient.SetupProcess(Boolean forceX86Discoverer)
   at Microsoft.VisualStudio.TestPlatform.Client.TestRunnerServiceClient.Initialize_NoLock(Boolean forceX86Discoverer)
   at Microsoft.VisualStudio.TestPlatform.Client.TestRunnerServiceClient.EnsureInitialized(Boolean forceX86Discoverer)
   at Microsoft.VisualStudio.TestPlatform.Client.TestRunnerServiceClient.EnsureInitialized_NoError(Boolean forceDiscoveryInX86Mode)

EDIT 6
I tried executing the tests using the mstest.exe command-line tool (with and without the /noisolation option). The tests run as expected as can be seen here. So the problem is really something inside VS 11 Beta.

Leniel Maccaferri
  • 100,159
  • 46
  • 371
  • 480
  • Well I hope somebody will be able to help you but thing is you are creating and running unit tests on a beta/unstable product. Can you guarantee that your unit tests work as they are supposed to work? Since Visual studio itself is not production ready I suppose neither the unit test framework is... – Marino Šimić Apr 16 '12 at 17:01
  • Can you give us a bit more information about your system, the solution, and project types? Are any other versions of VS installed? – Peter Provost Apr 18 '12 at 21:19
  • @PeterProvost: I use a Mac mini with MAC OS and so I have Windows 7 running inside a Parallels 7 virtual machine. => VS 11 Ultimate Beta solution with 3 projects (1 ASP.NET MVC 4 + 1 Class library + 1 Test Project). All projects built against .NET Framework 4. No other VS is installed. The ones that I had in parallel were uninstalled as I mention in the question. – Leniel Maccaferri Apr 19 '12 at 00:55

5 Answers5

3

Leniel,

Thanks for raising this issue.

As we discussed here, it indicates that shadow copy is causing the problem.

Please ensure that the Microsoft.VisualStudio.TestPlatform.Core.dll is loaded from its installation location %VSInstallDir%\Commmon7\IDE\CommonExtensions\Microsoft\TestWindow path and not from a temporary path like %appData%\assembly\dl3\ that you are observing right now. This should fix the problem for you.

Also I wanted to update you that in the latest code, we have improved our logic and with the improved logic, it would not matter from where the binary is getting loaded and it would just work for you.

Regards

Aseem Bansal

Community
  • 1
  • 1
Aseem Bansal
  • 799
  • 4
  • 14
  • Yeah. Thank you very much my friend... I saw your reply yesterday and I was going to post a reply. Thanks for letting me know here since MSDN blogs do not have a notification system for new comments. :) – Leniel Maccaferri Apr 25 '12 at 14:16
  • I'm experiencing this error also. It's quite frustrating, how can I make sure Microsoft.VisualStudio.TestPlatform.Core.dll is loaded instead of the %appdata% assembly version? – ryanjones May 10 '12 at 18:39
  • I am running into this in the new VS 2012 RC I read through the comment stream on the linked blog post...I have shadow copy turned off. The only thing I can think of that changed between when it worked and when it didn't is that VS 2012 crashed on me the other day and then when I started it said windows made changes to run it in compatibility mode – chrisortman Jun 14 '12 at 14:27
  • 3
    Deleting everything from %appdata%\assembly\dl3 seems to resolve the issue (for now) – chrisortman Jun 14 '12 at 14:38
  • I am experiencing the same problem on VS 11 RC. However, for me, the problem only appears when I run VS in administrator mode (or when UAC is turned off). I have used process explorer to verify that shadow copying is causing the issue, but only in Admin mode. – flipchart Jun 29 '12 at 03:48
3

Found a correlation:

When NuGet auto-pull is enabled, I run into this issue on VS 11 after about ~15 builds. Deleting the Packages folder and forcing a re-pull of dependencies on build corrects.

I also noticed that if I manually purge the obj/bin folders in the solution root, the solution is corrected.

Therefore, I am thinking this sounds like the Test Suite is not updating cached dlls with that of the current solution configuration. As we edit, the dlls are getting out of sync and thus causing the unit test fixture to fail to initiate.

Hope this helps.

deepelement
  • 2,457
  • 1
  • 25
  • 25
1

I had this problem, I tried the suggestion in a comment by @chrisortman and it solved my problem.

He suggested deleting: %appdata%\assembly\dl3

Although I found it here: %appdata%..\..\Local\dl3

I was going mad. Truly mad.

joshcomley
  • 28,099
  • 24
  • 107
  • 147
0

Thanks Leniel and Aseem Bansal for you help.

I have similar problem, but solution with this post not help me, My VS 2012 + silk4net not load test in Test Explorer.

Before I removed Telerik Test Studio from my PC. But extension for VS not removed. After I removed this extensions started to work correctly. Who see the problem persists, please view extension may be a problem in them.

Hope this helps.

Opal
  • 81,889
  • 28
  • 189
  • 210
0

One more point:

Environment.ExitCode = 0;

Needs to add to end of each test during its clean-up! I learned this hard way. MS unit test framework checks this, and not run next test with non-zero ExitCode from previous test!

This is a very good thread, I solve almost all my unit test issues in this thread.

Herbert Yu
  • 578
  • 6
  • 16