Home > View Post

Assembly Initialize and CleanUp in Test Projects

If you are using remoting and want to run some tests you may have to configure the remoting framework using the RemotingConfiguration's Configure function. This function should only be called once so the perfect place to make this call is in a function marked with the [AssemblyInitialize] attribute.

Clean up or tear down code would be placed in the method marked with the [AssemblyCleanup] attribute.

I like to put assembly initialization and clean up code into a separate test file and call it something obvious like indicated below:

Test Project in Solution Explorer

Only one method in an assembly can be marked with the AssemblyInitialize and AssemblyCleanup attribute respectively.

Note: The underscore in the class name is simply a personal preference so that the class ends up at the top when viewing the Test Project in the VS.NET solution explorer.

Tags: .NET

Bruusi Post By Bruusi
1:11 PM
11 Jun 2006

» Next Post: Save space with System.IO.Compression
« Previous Post: SSIS Set Variable Custom Task

Comments are closed for this post.

© 2005 - 2022 Josh Twist - All Rights Reserved.