Can the internal code be tested without having to mark the test code as internal?

I have an F # library with many non-public things that I want to test. Currently, all code that is not part of the public assembly API is flagged internal(in particular, it is placed in the modules marked internal). I use InternalsVisibleToAttributeto make this code visible to my test build. However, in order to build a test assembly, all tests that use internal types in their signature (most of them, since I use FsCheck to automatically generate test inputs) should also be marked as internal (this should apply to everyone because internal modules will not be detected by xunit). In addition, any types used solely to generate FsCheck (for example type ValidCustomer = ValidCustomer of Customer, whereCustomer - my internal domain type) should also be marked as internal, and FsCheck seems to get stuck when creating internal types, so the tests are not executed.

Is there a way to check the internal F # code (from a separate test assembly) without having to mark all tests whose signature depends on the internal types as internal? Now I'm just inclined to not do something internal at all in the source code, but ideally there is a way to get my clean API pie and eat it too.

+4
source share
1 answer

I found that the OO world will generally be very opposed to trying to verify something internal / private directly.

, , . . .

Haskell, , .

...

, , -. , API.

...

. =)

, , , .

, __INTERNAL__, .

+2

Source: https://habr.com/ru/post/1686862/


All Articles