Jump to content
Roger Cigol

Google Tests (unit testing framework) working with Embarcadero C++ clang compiler?

Recommended Posts

Has anyone got Google Tests (unit testing framework) working with Embarcadero C++ clang compiler? if so, using clang32 or clang64 bit? [or, ideally, both?] I can't find any web documentation that tells me if this is currently possible (Embarcadero 10.4.1) or not. (If there is a helpful URL then I would be grateful if anyone can oblige).

Share this post


Link to post

Hi Roger, did you get any further with using Google Test in 10.4.2?  We're currently looking for a replacement for DUnit so we can migrate to using the Clang compilers, so we'd be interested in any experience you have to share.

Share this post


Link to post

Hi @RobinP, we have been delayed (again) on moving to Clang because we have found there are some problems Embarcadero have yet to resolve re: building / using your own VCL components that are written in C++. We have a set of "in house" VCL components written in C++ that we use in most (virtually all) projects. It seems we can't use Clang32 or Clang64 with "in house" C++ components at the moment. So we are still on "classic" compiler. Frustrating because we really want to use C++17 constructs now. So we are still on DUnit - (which works fine but is a bit limited). We will come back to this posting when we move forward. (We are waiting for 10.5 which will fix this C++ component issue).

Share this post


Link to post

Thx @Roger Cigol, looks like you are in a similar place to us.  I'm with you on looking forward to C++17, and not looking forward to migrating 100 DUnit test projects to something else.  I really like the GUI runner in DUnit so would prefer something similar (there do seem to be a couple for GoogleTest that look interesting).

Share this post


Link to post

Out of interest - and possibly even making sure that TestInsight works with C++ using DUnit (no promise though) - what does not work with DUnit in C++?

Share this post


Link to post

DUnit works fine using the classic C++ compiler, but with Clang some tests wouldn't build due to a missing overload of CheckEquals.  I reported it but they said it was a DUnit issue so nobody is going to fix it.

 

https://quality.embarcadero.com/browse/RSP-27695

 

Since DUnit seems to have been a dead project for many years it makes sense to move to something else now as part of our Clang migration.  I know there are spinoffs but I think DUnitX is now deprecated or will not be supported by Embarcadero, and I'm not sure how far DUnit2 got or if it works with C++ and Clang.

Share this post


Link to post

DUnit is not actively being maintained, true. But I am planning to keep on using it - it achieved a nice balance between being flexible enough but at the same time very simple and not overengineered, ymmv.

I don't care what some guy in that issue says - they have been doing modifications to DUnit themselfes for ages and suddenly its a DUnit issue they cannot/don't want to fix? How ridiculous tbh.

 

I have my opinion about DUnitX - but it's certainly not deprecated but Vincent does not care for adding C++ support afaik.

 

I was in fact looking into dusting off DUnit, removing old cruft like the CLR stuff and applying some optimizations such as making parameters const, reducing unnecessary overhead in Check methods and so on (doing so improves the overall runtime of my tests by like 10% simply because the CheckSomething methods are faster!) while doing that I could look into making it work with C++

Share this post


Link to post

I agree with all you say about DUnit. I had a quick look into fixing it myself but since we are currently a pure C++ shop (don't even have Delphi installed) I thought it was too much of a learning curve and would probably be easier just to move to a more actively maintained framework, hence my interest in GoogleTest.  I have a feeling there were more issues with DUnit and Clang but can't remember exactly what.

Share this post


Link to post

What's so special in "testing framework"? It must run tests, have convenient way of adding tests, maybe pretty GUI and, more important, file output to most used formats. Talking about checking methods, AreEqual, AreNotEqual and WillRaise are enough. So what's the demand?

Share this post


Link to post
54 minutes ago, Fr0sT.Brutal said:

What's so special in "testing framework"? It must run tests, have convenient way of adding tests, maybe pretty GUI and, more important, file output to most used formats. Talking about checking methods, AreEqual, AreNotEqual and WillRaise are enough. So what's the demand?

The demand is being able to compile the existing framework 😉

  • Sad 1

Share this post


Link to post
10 hours ago, RobinP said:

I know there are spinoffs but I think DUnitX is now deprecated or will not be supported by Embarcadero

Ok, that's news to me (DUnitX author). 😉

  • Haha 1

Share this post


Link to post
10 hours ago, Stefan Glienke said:

I have my opinion about DUnitX - but it's certainly not deprecated but Vincent does not care for adding C++ support afaik.

It's not that I don't care for it, I just don't have the time (or skills for it). Happy to look at contributions to achieve this. I do know there are some issues with constructor overloads that would need to be addressed. 

Share this post


Link to post
16 hours ago, Stefan Glienke said:

The demand is being able to compile the existing framework 😉

Is there a trouble with DUnitX? CB consumes Delphi code AFAIK.

Share this post


Link to post
4 minutes ago, Fr0sT.Brutal said:

Is there a trouble with DUnitX? CB consumes Delphi code AFAIK.

CB can use most of the Delphi code, but not all.

Share this post


Link to post
1 minute ago, Dalija Prasnikar said:

CB can use most of the Delphi code, but not all.

Anyway I guess adopting DUnitX would be much easier than trying to glue with completely different platform

  • Like 1

Share this post


Link to post

Ok seems to be my mistake, DUnitX is clearly still used for Delphi, but the 10.4 wiki clearly states that it does not work with C++ Builder, and they even suggest using GoogleTest: http://docwiki.embarcadero.com/RADStudio/Sydney/en/DUnitX_Overview

 

So if I want to migrate to the Clang compilers this leaves 3 options:

1. Hope somebody updates DUnit or DUnitX to work with Clang (32 and 64 bit).  I could maybe do some testing for this but can't put much time into it.

2. Move to another already existing C++ framework such as GoogleTest.

3. Write my own home brew test framework.

 

At the moment I don't really have any idea which would be easier. 

Share this post


Link to post

In 1. you write that you don't have much time. Do you think that 2. or 3. would require less time?

  • Like 1

Share this post


Link to post

I personally use attributes only to mark Setup/Teardown methods, rarely to ignore some parts. The former could be achieved by adding empty virtual methods to TTestSuite

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

×