title: Swift - Unit testing functions that involve IBOutlets?
body: <p>I am setting up unit testing for my Swift project and am having trouble testing a class function that involves updating IBOutlets.</p>
  
  <p>I have a function, validateUrl, which expects a string to be passed, then validates it. If it is valid, it enables a UIButton, if it is invalid, it disables a UIButton. When I run a test that calls this function, the app crashes on the line of code that enables or disables the UIButton.
  The storyboard and controllers both has the proper Test target set.</p>
  
  <p>This line of code:</p>
  
  <pre><code>    self.submitButton.enabled = true// Enable Submit Button
  </code></pre>
  
  <p>Spits out this error: </p>
  
  <pre><code>fatal error: unexpectedly found nil while unwrapping an Optional value
  </code></pre>