java - Make member public to unit-test it -
i know there many question concerning unit-tests of private members within classes. of them come conclusion having private members need tested design-flaw needs refactoring (e.g. see here). still have 1 last question:
when refactor private members new classes become (public) api-members intended avoid. simplifying our client class polute our api designing new publicly visibly helper-class. of course 1 might write test-code within assembly , make helpers internal we´d ship test-code production-site.
i assume there no right answer issue perhaps have great ideas avoid situations?
regarding c# there 1 last trick try
- make
class
/membersinternal
- in assembly test, open assemblyinfo.cs file , make internals visible test-project/assembly adding following attribute:
[internalsvisibleto("yourtestproject")]
this makes members invisible outside assembly, except sake of test within "yourtestproject"-assembly.
more info on attribute can found on msdn.
Comments
Post a Comment