Menu

CppUnit and sub-directories

Help
Anonymous
2002-11-07
2002-11-29
  • Anonymous

    Anonymous - 2002-11-07

    Hi,

    I'm trying to set up cppunit on a project with multiple directories, each containing a module.

    I'd like to have a single main() file which creates and runs the testrunner.  The problem is, the suite registration macros don't seem to work with directories.

    I have a single test class with a few simple tests.  If this class is in the same directory as my main() file, everything works fine.  When I put the file in a subdirectory, the main() file says there are zero tests!

    My subdirectory is being compiled as a static library, then linked with my main() file.

    Should this work?  How can I get this to work?

    Thanks for any help!

     
    • Anonymous

      Anonymous - 2002-11-08

      Just to let you know,

      I solved the problem myself.  It turns out the the linker won't link an object file from a library into the executable if that object isn't referenced from the non-library code.

      Because of this, my test fixtures weren't getting included, and therefore weren't getting registered with the TestFactoryRegistry.

       
      • Tom Plunket

        Tom Plunket - 2002-11-08

        ahh yes, of course.  There is a way to get around this with most development environments.  I don't know what that is in MSVC, but in Codewarrior one says #pragma force_active on to get the linker to link in the stuff you want.

         
        • Johan Nilsson

          Johan Nilsson - 2002-11-29

          There is at least one way of doing it, I believe; add the option /OPT:NOREF
          to the linker. This has the disadvantage that _no_ unreferenced functions or
          data will be discarded, but I guess you could have a special build when
          building for tests only.

          If anyone comes a pragma in VC that enforces this for a specific function,
          please let me know.

          // Johan

          "Tom Plunket" <plunket@users.sourceforge.net> wrote in message
          news:89@37108.11795.sourceforge.net...
          >
          > ahh yes, of course.  There is a way to get around this with most
          development environments.  I don&#039;t know what that is in MSVC, but in
          Codewarrior one says #pragma force_active on to get the linker to link in
          the stuff you want.
          >

           

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.