views:

89

answers:

1

I'm working on my first 'real' F# assembly, and trying to do things right.

I've managed to get xUnit working too, but currently my test module is inside the same assembly. This bothers me a bit, because it means I'll be shipping an assembly where nearly half the code (and 80% of the API) is test methods.

What is the 'right' way to do this? If I put the tests in another assembly, I think that means I have to expose internals that I'd rather keep private.

I know that in C# there is a friend mechanism for tests (if that's the right terminology), is there an equivalent in F#?

Alternatively, can anyone point me to an example project where this is being done 'properly'?

+3  A: 

you could use the InternalsVisibleTo-Attribute to expose your internals to some other assembly.

http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute(VS.100).aspx

EDIT

If your assembly is signed, you will also need to sign the Friend assembly, and provide the public key in the InternalsVisibleTo attribute:

[<assembly: InternalsVisibleTo("ProcessorTests, PublicKey=0024000004800...)")>]
stmax
Benjol
Can't get the compiler to accept concatenated string for my PublicKey though - makes things a bit ugly, but appears to work all the same.
Benjol

related questions