title: Random data in Unit Tests?
body: <p>I have a coworker who writes unit tests for objects which fill their fields with random data. His reason is that it gives a wider range of testing, since it will test a lot of different values, whereas a normal test only uses a single static value.</p>
  
  <p>I've given him a number of different reasons against this, the main ones being:</p>
  
  <ul>
  <li>random values means the test isn't truly repeatable (which also means that if the test can randomly fail, it can do so on the build server and break the build)</li>
  <li>if it's a random value and the test fails, we need to a) fix the object and b) force ourselves to test for that value every time, so we know it works, but since it's random we don't know what the value was</li>
  </ul>
  
  <p>Another coworker added:</p>
  
  <ul>
  <li>If I am testing an exception, random values will not ensure that the test ends up in the expected state</li>
  <li>random data is used for flushing out a system and load testing, not for unit tests</li>
  </ul>
  
  <p>Can anyone else add additional reasons I can give him to get him to stop doing this?</p>
  
  <p>(Or alternately, is this an acceptable method of writing unit tests, and I and my other coworker are wrong?)</p>