views:

31

answers:

3

Hi all

I am writing a some unit test classes and i only want to run them in debug mode .

Is there some way not to deploy the classes itself to the final assemblies when i run in different mode .

I am not talking about their content (#if DEBUG flag) , the files them self .

I use VS2005.

Thanks.

A: 

Use #if DEBUG around the attribute that marks the classes as a test? (Details will depend on the testing system you are using.)

Without that indication the class looses its test status, but will still be included in the assembly.

Richard
+1  A: 

The standard practice is to put test classes in separate assemblies. That way you can simply deploy only the assemblies containing actual production code.

John Sibly
A: 

Also you may be able to use the condition attribute specifing DEBUG as its parameter onto the class.

But the way to exclude the entire file from compiling would be defining a condition in the project (.??proj) file, so if you have something like <ItemGroup> <Compile Include="Form1.vb"> <SubType>Form</SubType> </Compile> <Compile Include="Form1.Designer.vb"> <DependentUpon>Form1.vb</DependentUpon> <SubType>Form</SubType> </Compile>

you may add a condition to the ItemGroup:

Condition=" '$(Configuration)' == 'Debug' "

Note you can define more than one ItemGroup.

Sid