views:

108

answers:

2

Is there a Test Stripper (as defined in xUnit Test Patterns) available that supports removing classes containing methods tagged as [Fact]s etc. plus the dependency on xunit.dll from binaries [as part of a build process] ?

Further details of the full requirements and context are at this xUnit CodePlex post.

Failing that (something that removes the tests and the reference to the DLL), does anyone have a utility/proven clean approach to removing the xunit.dll dependecy without too much monkeying around in .vcproj files etc.

Open source preferred. A cleanly written one for NUnit might potentially serve as a base.

NB: I'm aware of the negatives of embedding code into assemblies - this question isnt about that (unless you feel after reading the codeplex thread that some key points are being missed).

+2  A: 

If your unit tests are placed in a project resp. assembly of their own there should be no need to strip test classes prior to deployment. What's wrong about this approach?

The Chairman
Read http://xunit.codeplex.com/Thread/View.aspx?ThreadId=69022 (In short, you need to make more stuff public and/or conditionally compile in lots of stuff to make stuff visible to the tests)
Ruben Bartelink
And you end up with twice as many projects. It's one of the [misguided, but no less real for that] motivations for MSTest's publicize.exe utility for creating 'Private Accessor' assemblies
Ruben Bartelink
Doesn't InernalsVisibleTo solve this issue?
@Miriam: As discussed in the CodePlex post, the key problem with InternalsVisibleTo is how that gets messy with Strong Naming. (And the fact you end up with twice as many projects)
Ruben Bartelink
A: 

As noted in the codeplex post where I specified the requirements, I implemented a basic stripper with Mono.Cecil but ended up leveraging the fact that unused references get optimised out in a release build to 'strip' tests out by excluding them based on a #define, which I control from outside via the MSBuild invocation

Ruben Bartelink