No tests were run because all loaded or selected tests are disabled problem in VS 2010

April 09, 2012

I want to share with you one really nice pitfall I faced at work and that is this nice note once you want to run unit tests inside VS 2010 saying :

No tests were run because all loaded or selected tests are disabled once you try to load and run some of them.

vs2010 unit tests problem

Hmmm, now what? Hitting CTRL + SHIFT + B will build whole .sln and there is no compile time error (but under my conditions, please read whole article if you want to know more).

In general the reason is : In your test solution is some kind of problem, possibly build problem and VS can’t load it and run tests, there is nothing to load when you cant build it. The reason why you can’t build it may vary.

But hey, you just build the whole damn thing and there was no trace of error in console window. Well, in my case two things met.

  • In our particular solution, we are using WCF service + project that references it and this WCF service reference is used later in another project that connects to the service (everything in one solution),
  • Some colleague of mine just unchecked building of Service part unit test and because we have only WCF reference between Service and its consumer (not in References of project), then Test project of service isn’t really built.

Then we can have nice error in our .cs test file + whole .sln built at same time like this:

vs 2010 tests error

Nice, isn’t it? 🙂

For better explanation of common architecture here is small UML diagram (hope it’s correct) :

small soa diagram

We can have some functionality in class libraries (multiple ones) + unit tests regarding their functionality. Then we expose this functionality as service via WCF service.

Chain in which .csprojs are referenced is following : class libraries on service side and then WCF service it self.

Then we have WCF Reference library + things that depends on it like in this picture Web app, or any other app that will use it. Because it makes sense to mark Web app as starting project, if we uncheck building of test project,VS 2010 doesn’t see any reason to build them. They aren’t in chain, nothing really depends on them. At least from VS’s point of view.

In my test proj solution properties what to build can look like this :

test wcf project solution properties

OK, so now you know what happened in my particular case, hopefully this will help some of you to troubleshoot your particular problems. There is high chance, that problem will be very similar.

Small project I used to play with can be found here : https://skydrive.live.com/redir.aspx?cid=78a5783de37d2ebe&resid=78A5783DE37D2EBE!1830&parid=78A5783DE37D2EBE!1782

Hope this helps.


Profile picture

Written by Dušan Roštár - the "mr edge case" guy
my twitter : rostacik, my linkedin : rostar, drop me an email : here