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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T06:11:19+00:00 2026-06-10T06:11:19+00:00

I have a messy Delphi 7 legacy system to maintain and develop. I am

  • 0

I have a messy Delphi 7 legacy system to maintain and develop. I am already reading “Working effectively with legacy code” and I like this book very much.

In order to start following the advices in the book, I created a test project and tried to write a single test. To do this I need to add some unit to the test project, but here lies the problem: the system under test has horrific uses dependencies. One unit uses some other unit, that uses some other unit and so on, and so on. It seems that most units directly or indirectly use one particular unit, and this unit in turn has 170 dependencies in its uses clause. There are indirect circular dependencies also.

Currently I am trying to add all of the legacy system’s units into the test project, but I am running into all kind of problems, like “unit xxx was compiled with a different version of xxx”, and others.

So I wonder if I am doing something wrong. I have used unit testing before, but in my own projects, that were smaller and with better structure and modularization. What are the options I have in this situation? Am I missing something?

  • 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-06-10T06:11:21+00:00Added an answer on June 10, 2026 at 6:11 am

    You will always have dependencies in your code. Well, as long as you have code re-use, you will have dependencies. Since you are testing a legacy system, wholesale re-structuring is out of the question.

    So you simply need to accept the dependencies. The most convenient and practical approach is to have a single unit tests project. That project contains all your unit tests. Use the facilities of your runner program to run only specific tests at any one time.

    This leads to your project have the same list of units in its .dpr file as the main project. That’s what you have currently tried and it’s the right approach.

    Your problem sounds like you are sharing the DCU directory (unit output directory) between the main project and the unit tests project. And you have different compiler options for the two projects. That’s the most likely explanation for the error you report.

    There are a couple of obvious solutions:

    1. Align the compiler options for both projects. Then they can share DCUs.
    2. Have separate DCU directories for the two projects.

    Option 2 is much more robust and is best practise. However, you should try to understand why the compiler options differ. It’s quite possible that your compiler options in the new unit tests project will need to be changed so that the units under test compile and function as desired. In modern Delphi I would use option sets to ensure consistency of compiler options.

    Now, there may be other technical problems that you are facing, and my explanation of the error may not be quite right since I’m having to guess a little. But the bottom line is that having the same list of units in your .dpr files is the way to go.

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

Sidebar

Related Questions

I have a messy html that looks like this: <div id=:0.page.0 class=page-element style=width: 1620px;>
In my code, I have messy things like // Enter key if (args.Event.KeyValue ==
I have been working on this tidy-up-messy-html tags with DOM, but now I realise
I have inherited a somewhat messy query that I am working on refactoring to
We have a large SQL driven software system which has been around since Delphi
My code is littered with things like this Write (thePhpFile, ' echo <option value=\'
I have a project with very messy code - lots of duplication and dead
I have a website (http://nottingham.subverb.net) that is mainly made up of messy procedural code
I have Perl code, which looks messy: my $x = $h->[1]; foreach my $y
Possible Duplicate: What's wrong with Delphi's “with” I am have a problem debugging code

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.