开发者

Where to put my xUnit tests for an F# assembly?

开发者 https://www.devze.com 2022-12-22 01:10 出处:网络
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,

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开发者_如何学C 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'?


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...)")>]
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号