title: JUnit test a public method impact on non-public fields
body: <p>In a package are two classes A and B. Each A object has a reference to a B object. The state of a B instance should only be visible by A, meaning all the B attributes have a package visibility. This is due to the A class being too complex - I had split it in two (and it was semantically correct to do so).</p>
  
  <p>The B class has a public method duplicate() performing a kind-of-deep-copy (meaning some attributes are deeply copied recursively, and for some only the reference is copied).</p>
  
  <p>Problem is I need to make test the duplicate method:</p>
  
  <ul>
  <li>I can call the duplicate method</li>
  <li>I cannot check the state of the newly created object against the state of the original object due to the package visibility</li>
  <li>I would like to avoid creating getters as the state of a B object is not supposed to be visible outside of the package</li>
  </ul>
  
  <p>Is there a way to make the attributes in B visible for testing only?</p>