No, I do not believe that they do it.
Usually, when people ask this question because they have whoch tests, depending on something difficult, for example, setting the database, which should be reset for each test. Usually the right thing here is to mock / drown / fake the addiction and remove the part that causes the problem. Of course, your reasons for this can be completely different.
Updated: So, thinking about this, I think you can do something with attributes and static types. You can add an assembly level attribute for each test assembly and pass it a static type.
[OnLoadAttribute(typeof(ProjectInitializer))]
When the assembly is loaded, the type will be allowed, and the static constructor will be executed at the first resolution (when the assembly is loaded).
Doing something at the solution level is a lot harder because it depends on how your unit test runner deals with tests and how it loads tests into AppDomains, per test, per test class, or per test project. I suspect that most runners create a new AppDomain for each project.
I do not recommend this because I have not tried it, and there may be some consequences. This is an idea that you might want to try. Another option is to infer all your tests from a common base class that has a constructor that solves a singleton, which in turn does your setup. This is less dangerous, but has a common base class. You can also use the aspect-oriented approach that I suspect.
Hope this helps. These are just thoughts on how you could do this.
Ade
source share