Jump to content
Sign in to follow this  
Camilo

can't get DUnit Tests to run with Classic Compiler for Win32

Recommended Posts

I am working on an big project developped in C++Builder, that is using Classic compiler for Win32 plattform. This project has many modules (that have their own folder). 
It has also many Lib directories. When I build this Project, there is no problem. 
I am trying now to test one module.

 

For that, I created firs an unit test project then created an unit test cpp. 
On this stage, when I compiled my unit test project, every things was fine.
Then I included in the unit test cpp the header file of the module (class) under test, so that I would be able the call the methodes of the class under test.
When I compiled my unit test project on this stage, I got bug notification: The header files that are included in the header file of the class under test cannot be opened.
I tried also to include the root folder of the whole project (in the include path option) in the unit test project. I still have the same problem.

 

I don't know what to do know. 

Cann some one help please?

 

Thanks!

Share this post


Link to post

In your unit test project you also need to include the *.cpp "modules" that you are going to test. As soon as you add these to the unit test project the compiler will know where to find the corresponding header file.

Share this post


Link to post

Hi Roger,

Thanks for help. I added the *.cpp modules. I also had to add all the *.cpp module of the whole project. When I compiled, I got the message (translation of german to english) Faltal error: too little memory.

Please do you know how I can solve this problem?

 

Thank you. 

Best regards.

 

Share this post


Link to post

Did it compile ok (all files) and then give this message when trying to link ?

Can you state with version of C++ Builder you are using (hopefully Alexandria 11.1). ?

Share this post


Link to post

Hi Roger,

 

sorry for the Delay. I didn't give you the feed-back. The solution you proposed me on April 13 could be applied succesfuly. I am now writing some simple unit-Test. And there are working.

Please, do you know where I can get more information about Unit testing usind DUnit for C++ Builder? Else I will still need to ask you every time many question. You are the only person I found in the web dealing with C++ Builder. There too much help for Delphi with Pascal, but not for C++ Builder.

 

I am also trying to mock some methodes to perform more complex tests. But I don't know how to proceed. Please do you have any Idea? Or where can I find information about that?

 

Thank you very much in advance.

Best regards

Share this post


Link to post

Hi Camilo,

 

It is entirely possible (and maybe advantageous) to write your main (typically legacy) project using the Classic compiler but to write your unit tests using clang32 and the Google Tests framework.

 

See https://cigolblog.wordpress.com/2022/05/12/using-google-tests-with-classic-compiler-projects/

 

The big advantages of using GoogleTests over DUnit are

 

a) There is good documentation provided by Google out on the web

b) it supports all commonly used unit testing techniques (including building mocks)

c) if/when you move your Classic based project to Clang32 your unit tests will all still be valid / useful

 

I've ditched DUnit completely in favour of using GoogleTests - even though many of my existing projects for customers are still based on the Classic compiler

Edited by Roger Cigol

Share this post


Link to post

Hi Roger,

 

I though it's not possible to perform unit test for Classic compiler. That is the reason why I choosed DUnit. 

 

I tried to open your link https://wordpress.com/post/cigolblog.wordpress.com/409

 

But it didn't work. The Page I got, wanted me to login for creating Web page using wordpress. 

 

Could you please actualise the link?

 

Thank you 

 

Best regards.

 

Camilo.

 

Share this post


Link to post

It is true: you cannot use the Classic compiler to compile GoogleTests. But there is nothing (or at least normally very little) to stop you using the Classic compiler for your main project but to use Clang32 for your unit testing project

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×