I am "translating" a NUnit test to Visual Studios unit testing and I am wondering if the attribute [ClassInitialize()]
in VS is equivalent to [SetUp()]
in NUnit?
SetUpAttribute (NUnit 2.0 / 2.5) This attribute is used inside a TestFixture to provide a common set of functions that are performed just before each test method is called. It is also used inside a SetUpFixture, where it provides the same functionality at the level of a namespace or assembly.
The SetUp attribute is inherited from any base class. Therefore, if a base class has defined a SetUp method, that method will be called before each test method in the derived class. You may define a SetUp method in the base class and another in the derived class.
A SetUp method runs before each test method within a test class so is used to set up common code required for each method - this could be providing stubs/fakes/mocks for any dependencies that the System Under Test requires, as well as perhaps instantiating an instance of the System Under Test.
[SetUp]
corresponds to [TestInitialize]
[TestFixtureSetUp]
corresponds to [ClassInitialize]
Here's the full picture.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With