Does anyone have any good hints for writing code for database backend development where we have to heavly depend on state?

Specifically, I have to write tests for code that retrieve records from the database, but the answers will depend on the data in the database (which may change over time).

Do people usually make a separate development system with a 'frozen' database so that any given function should always return the exact same result set?

I am quite sure this is not a new issue, so I would be very interested to learn from other people's experience.

Are there good articles out there that discuss this issue of web-based development in general?

Views: 116

Reply to This

Replies to This Discussion

I would propose to use three databases. One production database, one development database (filled with some meaningful data for each developer) and one testing database (with empty tables and maybe a few rows that are always needed).

A way to test database code is:

  1. Insert a few rows (using SQL) to initialize state
  2. Run the function that you want to test
  3. Compare expected with actual results. Here you could use your normal unit testing framework
  4. Clean up the rows that were changed (so the next run won't see the previous run)

The cleanup could be done in a standard way (of course, only in the testing database) with DELETE * FROM table.

it's a pleasure to meet you. I am USA Army personnel, i have an important thing to discus with you.
Please write me on my email (


PeopleSoft Jobs in US


  • Add Videos
  • View All

© 2022   Created by Maisam Agha.   Powered by

Badges  |  Report an Issue  |  Terms of Service