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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:04:40+00:00 2026-05-27T01:04:40+00:00

How to do TDD/BDD with asp.net 4.0 Web Forms? I have an existing website

  • 0

How to do TDD/BDD with asp.net 4.0 Web Forms? I have an existing website that has very large scale and we dont have any test with each change in database we have to guess what will break? I want to introduce unit testing please give me pointers?

  • 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-27T01:04:40+00:00Added an answer on May 27, 2026 at 1:04 am

    A lot will depend on how your existing codebase is structured.

    It can take a lot of work to retrofit Unit testing and especially TDD into a legacy project. Typically you’ll find database and business logic residing in the code behind file of the web pages.

    Use of interface types are your friend here as Visual Studio can generate Interface classes automatically for you. (Place the cursor over a class name, right click, select refactor and extract interface)

    I would work towards separating your database code into a class library project of it’s own. You can then specify the public interface through which the business logic etc can access the database. All other code should treat the database repository as a black box.

    Create a factory to make your repository (based on that Interface), have it create a test type and a live type. The live type will link into your current database code. The test type will just return hard coded values. You can write tests using the live database, then you can write tests for the “test” database in a TDD manner.

    Once they both match (all tests pass) any new database functionality is added by writing the test that runs on the “test” database first and then on the live database.

    Remember all code should only use the Interface to the database not an instantiated live database class.

    Once you’ve got the hang of the process you can delve deeper (if you wish) within the database code, but I would say that following the same process in separating and testing business and UI logic is more practical on a legacy project.

    You may find that a pragmatic approach is to only separate out functionality following the process that I’ve described as you go to add new code. In other words before you add new functionality, separate out the code as described writing the tests that show that it passes (live and test version) then alter or add test for new functionality using whether the test passes or fails to guide your coding.

    If covering all bases you want a test for failure, test for pass and maybe a test for exception scenario.

    Good luck. It’s not a job for the faint hearted (having had to do it many times in the past).

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

Sidebar

Related Questions

I recently heard of BDD and found it very similar to TDD. Which of
For TDD you have to Create a test that fail Do the simplest thing
I am learning TDD and I currently have a method that is working but
Whilst practicing some TDD at work for an ASP.Net MVC project, I ran into
My team is writing a content-managed web-hosting application in ASP.Net MVC 2 with the
I am trying to learn TDD/BDD using NUnit and Moq. The design that I
BDD has been touted as TDD done right. However TDD is widely used with
I just started devoloping ASP.NET MVC Web applicatons . One thing I like about
I want to start diving into BDD. I have never used TDD before and
When doing TDD , how to tell that's enough tests for this class /

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.