+ Start a Discussion

Static members and initializers in test classes

If you have a test class with multiple test methods in it, and some static member along with a static initializer, then 
1) Test methods will run in no particular order (i'm sure you knew this one already).
2) Static members are nulled out for each test method being run.
3) Static initializer runs for every test method, instead of just once for the class.
4) Governor limits are reset for every test method.
5) Governor limits are shared by the test method and static initializer.

So question: is #2 and #3 - expected behavior or a bug?
I would say expected behavior.  Each test method should be self-sufficient.

One thing I would like to see is some type of "setup()" method built-in to a test class.  This setup method would run prior to any code within a test method.