title: Writing test code for verifying database entries when testing an API
body: <p>I'm writing test code to test a client-server application. The application under test consists of </p>
  
  <ol>
  <li>an application that runs on Tomcat
  or another Java EE application server, and  </li>
  <li>client jars that expose an API.</li>
  </ol>
  
  <p>I'm basically writing test code that uses this client API to connect to the server.</p>
  
  <p>In addition to extensively testing the API operations, my superiors have advised me to connect to the database on the server and verify that fields are being populated properly. I have done that for some of my test cases, but it hasn't really caught any bugs during regression. </p>
  
  <p>Bugs are caught when a particular functionality fails, but that anyway gets revealed in the code that tests the API itself. It seems that DB data verification is not really useful, especially considering the extra effort required to write and maintain all that code.</p>
  
  <p><strong>My question is:</strong></p>
  
  <p>Is there any real benefit to write test code for connecting to the DB and verifying entries in this manner? Do the benefits pay off for the costs incurred in writing such code?</p>