title: How strict should I be in the "do the simplest thing that could possible work" while doing TDD
body: <p>For TDD you have to </p>
  
  <ol>
  <li>Create a test that fail</li>
  <li>Do the simplest thing that could possible work to pass the test </li>
  <li>Add more variants of the test and repeat</li>
  <li>Refactor when a pattern emerge </li>
  </ol>
  
  <p>With this approach you're supposing to cover all the cases ( that comes to my mind at least) but I'm wonder if am I being too strict here and if it is possible to <em>"think ahead"</em>  some scenarios instead of simple discover them.  </p>
  
  <p>For instance, I'm processing a file and if it doesn't conform to a certain format I am to throw an <code>InvalidFormatException</code> </p>
  
  <p>So my first test was:</p>
  
  <pre><code>@Test 
  void testFormat(){
      // empty doesn't do anything nor throw anything
      processor.validate("empty.txt"); 
      try {
          processor.validate("invalid.txt");
          assert false: "Should have thrown InvalidFormatException";
      } catch( InvalidFormatException ife ) {
          assert "Invalid format".equals( ife.getMessage() );
      }
   }
  </code></pre>
  
  <p>I run it and it fails because it doesn't throw an exception. </p>
  
  <p>So the next thing that comes to my mind is:  <em>"Do the simplest thing that could possible work"</em>, so I :</p>
  
  <pre><code>public void validate( String fileName ) throws InvalidFormatException {
      if(fileName.equals("invalid.txt") {
          throw new InvalidFormatException("Invalid format");
      }
  }
  </code></pre>
  
  <p>Doh!! ( <em>although the real code is a bit more complicated, I found my self doing something like this several times</em> ) </p>
  
  <p>I know that I have to eventually add another file name and other test that would make this approach impractical and that would force  me to  refactor to something that makes sense ( which if I understood correctly is the point of TDD, to discover the patterns the usage unveils ) but: </p>
  
  <p><strong>Q:</strong> am I taking too literal the <em>"Do the simplest thing..."</em> stuff?</p>