title: Mockito - Mocking behaviour of a File
body: <p>I have a class that takes in a single file, finds the file related to it, and opens it. Something along the lines of</p>
  
  <pre><code>class DummyFileClass
  {
      private File fileOne;
      private File fileTwo;
      public DummyFileClass(File fileOne)
      {
           this.fileOne = fileOne;
           fileTwo = findRelatedFile(fileOne)
      }
  
      public void someMethod()
      {
           // Do something with files one and two
      }
  
  }
  </code></pre>
  
  <p>In my unit test, I want to be able to to test someMethod() without having to have physical files sitting somewhere. I can mock fileOne, and pass it to the constructor, but since fileTwo is being calculated in the constructor, I don't have control of this.</p>
  
  <p>I could mock the method findRelatedFile() - but is this the best practice? Looking for the best design rather than a pragmatic workaround here. I'm fairly new to mocking frameworks.</p>