Night Walker
Night Walker

Reputation: 21260

Including class only in debug mode

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.

Upvotes: 2

Views: 291

Answers (3)

Michele Di Cosmo
Michele Di Cosmo

Reputation: 591

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.

Upvotes: 0

John Sibly
John Sibly

Reputation: 23056

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

Upvotes: 2

Richard
Richard

Reputation: 108975

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.

Upvotes: 0

Related Questions