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!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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'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.
>
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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!
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.
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.
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'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.
>