<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">On 03/14/2014 11:07 AM, Tiemo Kieft
      wrote:<br>
      <blockquote
        cite="mid:A982720E-BCF4-4538-ADA5-0EBA6ADFEAD7@infinitesimal.nl"
        type="cite">
        <pre wrap="">Ideally you’d have each unit test running in a clean environment, which means creating a new database per test case.</pre>
      </blockquote>
      <br>
      Personally, I think this is overkill.  We approach this by making
      tests responsible for cleaning and/or setting up any tables they
      need.  So, if I have to have certain data in my orders table, then
      I'm responsible for:<br>
      <br>
      <br>
      # delete all orders and anything dependent on orders, this method
      is responsible for knowing what depends on orders and calling
      dependent_object.delete_all_cascaded() for those tables.  But only
      one level deep since the dependent objects are also responsible
      for taking care of dependencies.<br>
      <br>
      Orders.delete_all_cascaded() <br>
      <br>
      # create order with sane defaults, pass in parameters to change
      values that need to be updated for testing.<br>
      Orders.testing_create(...)<br>
      <br>
      FWIW.  :)<br>
      <br>
      <div class="moz-signature"><br>
        <b>Randy Syring</b><br>
        <small>Husband | Father | Redeemed Sinner</small><br>
        <br>
        <i><small>"For what does it profit a man to gain the whole world<br>
            and forfeit his soul?" (Mark 8:36 ESV)</small></i>
        <br>
        <br>
      </div>
      <br>
    </div>
  </body>
</html>