Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6847383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:44:18+00:00 2026-05-27T00:44:18+00:00

I have a database-backed application which, sadly, has very few tests of its database.

  • 0

I have a database-backed application which, sadly, has very few tests of its database. I’m trying to get up to speed on effectively testing the database.

So far, I’ve learned:

  • test the ability of the application to put/fetch data to the database
  • use mock DB’s to test object/relation-mapping code

I’m still struggling to implement the first point. It seems that the only way to test that is to insert data into the real tables. But of course the user won’t want to see my test data. Here’s what I’m currently doing in pseudo-code:

begin a transaction
insert a few rows
check that no error has occurred
'select' the rows back out
check that no error has occurred, check that data out matches data in
tell the test framework that it's successful
abort the transaction

Is this a best practice, or some kind of horrible anti-pattern? Any better suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T00:44:18+00:00Added an answer on May 27, 2026 at 12:44 am

    Your user definitely shouldn’t see your test data, because testing in production is really bad practice! You should try to create a test environment and do your testing there.

    One solution I’ve found to work is to create a separate database instance, populate it with some known data, and use that for your integration testing. Be sure to clean up your database after each test case, as test cases should be independent.

    Using transactions in the test database is not such a bad practice, since you can confirm things and then rollback the transaction, but I would be concerned that you’re going to call code that will commit to the database, thereby changing the parameters for following tests. Of course, if your DB supports nested transactions, this isn’t a big deal, but ISTM that not all DBs do that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using VS2005 C#, and I have an application which has a few
We have an application which uses an instance of Sql Server locally for its
I am running a Spring MVC application, backed by a MySQL database which I
I have a C# WinForms application with a database backend (oracle) and use NHibernate
As the title suggests, I've inherited a php/MySQL application which has fairly well written
We have a client running our .NET application which connects to SQL Server 2005
I have a Spring MVC application which communicates with the frontend with AJAX /
Consider, please this setup for a database backed application. ( in my case DB
i am facing a big speed problem with my application..we have to go for
Im creating an IPad Application which will have an SQL Server backend. My question

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.