TestInitialize Called More Than Once Per Class? And TestContext.WriteLine()

Hello,

I started having issues with a set of unit tests that I wrote when I added a File.Copy routine to the TestInitalize method. It seems that the initialization is happening once per test in the class, not once for the entire class. Is that the correct behaviour? Isn't it supposed to be once per class?

To try and test this theory further (without having to step through it) I tried the TestContext.WriteLine() method to write some text out. I put this in the Cleanup to see if the text shows up more than once. The only problem is, I can't find where this is being written to! Anybody know where this goes?

Thanks so much for any information!

[656 byte] By [CindyBrucato] at [2008-2-15]
# 1
You need to use [ClassInitialize] and [ClassCleanup].

We have 3 sets of Init/Clean up.

AssemblyInitalize/Cleanup -- This is Called once per Test Assembly
ClassInitialize/Cleanup -- This is called once per class per test run
TestInitialize/Cleaup -- THis is called once per test.

dhoptonMSFT at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Visual Studio Performance Tools (Profiler)...
# 2
Thank you!
CindyBrucato at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Visual Studio Performance Tools (Profiler)...

Visual Studio Team System

Site Classified