Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>What are the best practices in database unit testing? </p> </blockquote> <p>The <a href="http://dbunit.sourceforge.net/" rel="noreferrer">DbUnit</a> framework (a testing framework allowing to put a database in a know state and to perform assertion against its content) has a page listing database testing <a href="http://dbunit.sourceforge.net/bestpractices.html" rel="noreferrer">best practices</a> that, to my experience, are true.</p> <blockquote> <p>What are the primary concerns when doing db unit testing</p> </blockquote> <ul> <li>Creating an up to date schema, managing schema changes</li> <li>Setting up data (reference data, test data) and <strong>maintaining</strong> test data</li> <li>Keeping tests independent</li> <li>Allowing developers to work concurrently</li> <li>Speed (tests involving database are typically slower and will make your whole build take more time)</li> </ul> <blockquote> <p>and how to do it "right"?</p> </blockquote> <p>As hinted, follow known good practices and use dedicated tools/frameworks:</p> <ul> <li>Prefer in memory database if possible (for speed)</li> <li>Use one schema per developer is a must (to allow concurrent work)</li> <li>Use a "database migration" tool (à la RoR) to manage schema changes and update a schema to the ultimate version</li> <li>Build or use a test harness allowing to put the database in a known state before each test and to perform asserts against the data after the execution (or to run tests inside a transaction that you rollback at the end of the test).</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload