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

  • Home
  • SEARCH
  • 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 92423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:11:05+00:00 2026-05-10T23:11:05+00:00

I am building a web application that uses the database for Users, Security/roles, and

  • 0

I am building a web application that uses the database for Users, Security/roles, and to store content.

It seems a little daunting to me to begin on the road of unit testing because I have to make sure my database has been initialized properly for my tests to run.

What are common practices to help in this regard?

i.e. while developing/testing, I might delete a user, but for my test to pass that user has to be in the database, along with his profile, security settings etc.

I know I can create a setup script, something to recreat the databas etc.

I don’t want to end up spending my entire time maintaining my tests and ensuring my database is in sych

Or is that the cost of Unit Testing/TDD?

  • 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. 2026-05-10T23:11:05+00:00Added an answer on May 10, 2026 at 11:11 pm

    It’s not a unit test if you are testing more than one unit.

    Usually you’ll have one component (your page, or the business layer) talking to a data layer object that is responsible for actually connecting and querying the database. My recommendation is to develop a unit test for the first component, using dependency injection to pass in a mock version of the DataLayer (which acts on hardcoded data, or a List you pass in, etc). This way you are testing your higher level code in isolation from the other components.

    Then you are free to develop other unit tests (and integration tests) for the data layer to ensure that it is handling it’s job (writing to the database) correctly.

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

Sidebar

Ask A Question

Stats

  • Questions 198k
  • Answers 198k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer My solution was to go open source :) Using Cecil… May 12, 2026 at 7:39 pm
  • Editorial Team
    Editorial Team added an answer Try this rule: RewriteCond %{REQUEST_URI} ^[^A-Z]*[A-Z].* [OR] RewriteCond %{QUERY_STRING} ^[^A-Z]*[A-Z].*… May 12, 2026 at 7:39 pm
  • Editorial Team
    Editorial Team added an answer Try Selenium, http://jimmyg.org/blog/2009/getting-started-with-selenium-and-python.html May 12, 2026 at 7:39 pm

Related Questions

It is pretty standard practice now for desktop applications to be self-updating. On the
I'm building a web application using Stripes and Spring. It needs to have a
I am building a web-store that uses URL encoding extensively. I have a list
I am building a client-server based solution; client being a desktop application and the

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.