If I have a class with static Facts (test methods) and the class has a static constructor, is the constructor called for each 开发者_C百科Fact or only once for all Facts in a class? I guess it depends on how the runner loads/unloads test classes?
Out of experience, I know that it is only called once for the class. It is the same if you use a static class (i.e. settings class) in your non-static tests (facts). The static object constructor is only called once for the whole test class.
If anything (eg. Facts) use static method or class first time that static constructor is called ones. If there are no references to the static class the static constructor is not called at all. If you are considering to run code before and after the tests (setup/dispose) ONES I recommend to use Fixtures (see https://xunit.net/docs/shared-context).
精彩评论