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 6381533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:24:25+00:00 2026-05-25T02:24:25+00:00

I am about to write unit tests for a new web application. My preferred

  • 0

I am about to write unit tests for a new web application.

My preferred method is to test against the live database structure rather than an in-memory database.

I understand that I can wrap my unit test database calls inside transactions that are not committed.

What I think is a better approach is to copy the live database before initialising the tests, and allow the transactions to commit to the test database. If the tests are run in the correct order this will allow me to create a complete test story from registering the first account, through their various interactions, ending with an account closure. i.e. a real world lifecycle. I am convinced this should be an excellent approach, but having never put this into practice yet I was wondering if people had attempted a similar approach and what the feedback is before I proceed. Thanks in advance.

  • 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-25T02:24:25+00:00Added an answer on May 25, 2026 at 2:24 am

    I know I am going to be that guy by doing this, but lets establish our terms here before moving forward. Skip this part if you only care about the answer.


    A Unit Test should test just that, a single unit. It should not rely on external dependencies such as databases, web services, or file systems. Instead, those dependencies should be mocked so that the state of each individual test can be precisely controlled.

    A Unit Test should be atomic, consistent and repeatable. As John points out, the test should be able to be run by itself, or in a suite with the exact same behavior every time.

    An Integration Test should test the interaction between the various units that compose your system. Thus, they should never seek to stub or mock any dependencies. These tests should be as close to testing what will be deployed to production as can be achieved.


    Let me be the first to tell you that while it is quite common for Integration Tests to be dependent on setup and tear down, tread lightly in this arena.

    Sure it seems like a really good idea to begin with, but for the same reason that procedural code usually ends up as a nightmare to maintain, procedural tests are even worse. Since they are so tightly coupled to the implementation details of the underlying code, you will end up having to change massive sets of tests if you ever change those details.

    In the best case scenario you will throw away large sets of tests and start over. In the worst scenarios you will hesitate to refactor your system because you don’t want to break your tests… and thus rob you of the very advantage they are supposed to bring.

    The best advice I can give you is to start reading up on Acceptance Testing, and Behavior Driven Development.

    Some People who can help:

    Gojko Adzic, Bob Martin

    Some Tools that can help:

    FitNesse, SpecFlow, Cucumber

    Please! Please! Please! read and learn from those guys, and those communities. They will steer you in the right direction and help you avoid long term problems with automated testing.

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

Sidebar

Related Questions

I'm about to write a Scala command-line application that relies on a MySQL database.
Greetings, I want to write a unit test to make sure that our web
Today I finally started to write some unit tests for my new ASP.net MVC
I am about to write junit tests for a XML parsing Java class that
I'm just about to write my first application in a duck typed language (Groovy).
say I'm about to write an application with a thin GUI layer, a really
My company is fairly new to unit testing our code. I've been reading about
I have an ant task set up like so: <target name=unit-test description=unit tests depends=compile-tests>
I am fairly new to unit testing. I am building an ASP.NET MVC3 application
It is usually more complicated to write unit tests due to having to deal

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.