There will always be dependencies in your code. Well, if you have code reuse, you will have dependencies. Since you are testing an outdated system, a wholesale restructuring is out of the question.
Therefore, you just need to accept the dependencies. The most convenient and practical approach is a project with one unit testing. This project contains all your unit tests. Use the capabilities of your runner program to run only specific tests at any given time.
This causes your project to have the same list of units in the .dpr file as the main project. This is what you tried now, and this is the right approach.
Your problem is this: you are sharing the DCU directory (module output directory) between the main project and the unit test project. And you have different compiler options for two projects. This is the most likely explanation for the error you are reporting.
There are several obvious solutions:
- Combine the compiler options for both projects. Then they can share the DCU.
- You have separate DCU directories for two projects.
Option 2 is much more reliable and is best practice. However, you should try to understand why the compiler options are different. It is possible that your compiler options in the new unit test project will need to be changed so that the modules 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 entirely correct, since I need 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.
source share