My current employer doesn't do unit testing (shudder). In fact there is no host based testing at all; everything is tested (black box) on target. And none of it can be automated (the horror! the horror!).

After some nagging I have been very grudgingly given permission to look into host testing - initially at subsystem level. Not ideal, but it's a start, and it can be automated for regression testing porpoises, and, if it works, I might even get to try unit testing.

The build system for the target doesn't have anything as simple as a make file, oh no, indeedie. It has a Bash script, which runs a Perl script, which invokes a few Python scripts, which use XML files to generate build commands on the fly.

I would like to stay well away from it (maybe in the next country, maybe even in the next job).

The subsystem has 200+ .CPP files. Neither source nor header include the .H files which they need, preferring to rely on others to do so (the further horror! the further horror!). Mostly this gets done by the aptly named enums.h (or, do I mean ineptly?).

Question: I am looking for a tool which will scan those 200+ source & associated header files, and figure out which classes, functions, structures, enums, etc are referenced, but not declared and generate mocks/stubs/dummies/WhateverYouCareToCallThem, which I can expand upon for testing?

Thinks: perhaps it could just scan the compiler/linker error messages in order to determine what to create?

Windows or Linux. Preferably free, but as that is so unlikely, if there is something commercial where I can try a demo, I might be able to get them to spring for a license.

Important: it must be able to use the current production code - unchanged. Tools like Google Mocks require me to declare things as virtual solely in order to be able to test.

[Update] I am looking for a free solution which is licensed for commercial use.

  • 2
    Each and every mocking framework relies on methods being virtual. The only framework which omits some limitations that I know is Java's PowerMockito which modifies bytecode to allow some normally not allowed tasks. C++ has no JVM and no reflection you could use to get away with your idea. False objects and Mock objects are drop-in replacements for actual objects - if your code is so tightly coupled that you cannot swap implementations no framework is going to help you anyway. In your case book Working effectively with legacy code by M. Feathers might be what you actually need. Commented Feb 10, 2015 at 15:54
  • What do you mean, "referenced but not declared"? How can a code entity be used, if it doesn't have declaration/definition somewhere?
    – Ira Baxter
    Commented Mar 6, 2015 at 10:24
  • Yes another job, and I encounter the same problem. is there a market for this, if I develop it myself?
    – Mawg
    Commented Sep 14, 2016 at 8:24

1 Answer 1


Not free or even cheap but you might be able to get a demo licence but this sounds like a job for LDRA TBRun &/or LDRAunit - the nice thing is that it will quite rapidly tell you which stubs are needed and generate the framework for them, both at unit level and sub-system level.

It will also allow unit testing on the target hardware as well as on a host and provides very thorough static analysis & data flow analysis both of which might be good selling points to your boss.

I have used it a lot and to me it is a lot less work to generate useful tests than many of the competitors that I have also used.

(N.B. Just to clarify I don't work for LDRA but I do use it at work)

  • This looks very good, @SteveBarnes. Do you have any idea of cost?
    – Mawg
    Commented Feb 11, 2015 at 8:10
  • 1
    I think that the first years licence is of the order of 10k+ depending, on options, and then less for each years renewal but that is just a rough number. If you are in an industry sector that they are keen to break into you may be able to get a better deal. @Mawg Commented Feb 11, 2015 at 19:26
  • Sorry about unawarding the answer, Steve, but the company won't go for it and I would like a free answer to this question. I hope that you don't mind too much.
    – Mawg
    Commented Jun 3, 2015 at 12:48
  • 1
    @Mawg - If I had a free answer I would be using it! Sorry I can't point you at one, in more ways than one! Commented Jun 3, 2015 at 17:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.