Team System Developer Center > Visual Studio Team System Forums > Visual Studio Team System - Testing > How can I have one TestCleanup() for all test classes?
Ask a questionAsk a question
 

General DiscussionHow can I have one TestCleanup() for all test classes?

  • Friday, October 30, 2009 3:35 PMpuromtec Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    How can I have one TestCleanup() for all my test classes? I have a test class for each class and have ended up with many test classes as result. I want to print to the output screen a dump of a static message log class.

            [TestCleanup()]
            public void MyTestCleanup()
            {
                Globals.MessageManager.Messages.ForEach(x => System.Diagnostics.Trace.WriteLineIf(x.Severity != Globals.Severity.Critical,
                    x.ErrorCode.ToString() + " --- " + x.Severity.ToString() + "    " + x.Text, "ErrorMessages"));
            }
    
    Thanks

All Replies

  • Monday, November 02, 2009 8:01 AMEdwer FangMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello,

    Sorry I am not able to understand 'How can I have one TestCleanup() for all my test classes? I have a test class for each class and have ended up with many test classes as result.', could you please offer more detailed information?

    Usually method marked with [TestCleanup()] is executed after each single test has run while method marked with [ClassCleanup()] is executed after all the tests have run. In addition, normally all the unit tests are organized in one single class.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Send us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.
  • Friday, November 06, 2009 2:40 AMEdwer FangMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    We are changing the issue type to “General Discussion” because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question” by opening the Options list at the top of the post window, and changing the type. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions.
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Send us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.