Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing "friend"-declarations for unit testing. Bad idea?
    primarykey
    data
    text
    <p>[<em>Of course, the question is not restricted to a specific "friend" implementation, feel free though to point out implementation specifics if relevant</em>]</p> <p>Reading through the unanswered questions, I stumbled upon the <a href="http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute.aspx" rel="noreferrer"><code>InternalsVisibleTo</code></a> attribute:</p> <blockquote> <p>Specifies that types that are ordinarily visible only within the current assembly are visible to another assembly.</p> </blockquote> <p>The <a href="http://msdn.microsoft.com/en-us/library/67ef8sbd.aspx" rel="noreferrer">C# Programming Guide</a> on <a href="http://msdn.microsoft.com/en-us/library/" rel="noreferrer">MSDN</a> has a section <a href="http://msdn.microsoft.com/en-us/library/0tke9fxk.aspx" rel="noreferrer">Friend Assemblies</a> describing how to use the attribute to allow the use of <code>internal</code> methods and types to another assembly.</p> <p>I'm wondering whether it would be a Good Idea to use this to create a "hidden" interface for instrumenting a library for use by the unit testing assembly. It seems to increase coupling massively in both directions (testing code in the production assembly, intimate internal knowledge about the production assembly in testing code), but on the other hand it might help in creating fine-grained tests without cluttering the public interface.</p> <p>What is your experience with using friend declarations when testing? Was it your Silver Bullet, or did it start the Death March? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload