title: Exception handling in FitNesse
body: <p>Gojko Adzic, in his book <a href="http://gojko.net/FitNesse/book/ch05s04.html" rel="nofollow noreferrer"><em>Test Driven .NET Development with FitNesse</em></a>, gives some basic tips on reducing the test code. There's a method called <code>LogIn</code> which, based on the username and password, returns player's id or throws an exception when there's no such registered player. Here's the initial version of the test code:</p>
  
  <pre><code>public class CheckLogIn : fit.ColumnFixture
  {
      public string username;
      public string password;
  
      public int LoggedInAsPlayerId()
      {
          try
          {
              SetUpTestEnvironment.playerManager.LogIn(username, password);
              return true;
          }
          catch (Exception)
          {
              return false;
          }
      }
  }
  </code></pre>
  
  <p>This is then replaced with a shorter version:</p>
  
  <pre><code>public class CheckLogIn : fit.ColumnFixture
  {
      public string username;
      public string password;
  
      public int LoggedInAsPlayerId()
      {
          return SetUpTestEnvironment.playerManager.LogIn(username, password);
      }
  }
  </code></pre>
  
  <p>Now the second test has an added bonus of verifying if a correct id is returned, but it doesn't allow you to check if the system rejects an unknown user/wrong password. <strong>Is there any special value which can be used in a column to indicate an exception?</strong> Or do I have to combine both tests to cover all scenarios? I remember, albeit vaguely at this very moment, there was some kind of unit test pattern for handling exceptions, but I'm sure somebody has already asked about it, so I don't want to duplicate. Unless the community is OK with that, then please suggest a best practice for testing such methods.</p>
  
  <p>In case I'm not being clear: </p>
  
  <p>Say I got one registered player: <code>john.doe/test123/101</code> (username/password/id). Two of the combinations I would want to test the system against are <code>john.doe/test123/101</code> and <code>john.doe/johnny/&lt;WrongUserOrPasswordException&gt;</code></p>