title: How do I manipulate core data in unit tests while not exposing private functions?
body: <h3>Thanks in advance for any help.</h3>
  <p>I have a caching service I've implemented with a core data stack in Swift 3.1.  The exposed interface conforms to this protocol:</p>
  <pre><code>protocol WeekForecastCacheService {
    func add(cacheModels: [DayForecastCacheModel])
    func get(cityId: Int, callback: @escaping ([DayForecastCacheModel]?) -&gt; () )
  }
  </code></pre>
  <p>Ideally I want the internals of my core data stack to stay private.</p>
  <p>However I also want to be able to unit test the class.  Specifically the exposed interface.  Because the core data stack is persistent I want to be able to delete every entity (a reset if you will to start tests in a known state).  How do I go about doing this while keeping the unit test implementation outside of my main target.</p>
  <p>Ideally I would also like my tests to be independent of implementation...</p>
  <p>I'm thinking along the lines of the following but could do with some advice:</p>
  <ul>
  <li>Add a delete all function to the cache class</li>
  <li>Use a class extension and implement the functionality there - it would mean a fair amount of copy paste</li>
  <li>Change private functions / variables to be internal giving enough access to easily create a delete all function in a class extension</li>
  <li>Stop worrying because only protocols are used by classes consuming the service so it doesn't matter if functions and properties within the class are not private</li>
  </ul>