Datapoint Initialization In TestFixtureSetUp Methods
Unit testing for .NET
Brought to you by:
charliepoole
Currently you can only initialize instance variables marked with either the Datapoint or Datapoints attribute at their declaration or in the class constructor. Any changes you make to these variables after that do not affect the tests. That is generally a good thing. However it would be nice to be able to initialize these variables in methods marked with the TestFixtureSetup attribute. This would allow you you to move complex initialization code out of the constructors. Moving initialization out of the constructor would be nice because then code coverage tools would not show hits from when the constructors are called for tests that are not even being run, which currently happens.
As a workaround, I suggest using a TestCaseSource located in the fixture or in a separate class. Since TestCaseSource can designate a method, complex initialization can be more easily accomplished. If you use a static method,
no extra object construction takes place.