简体   繁体   中英

Which C++ Unit Test framework does not require I build my application as a library?

I would like to write some test code for a C++ class. Because the class is part of an application but not a part of library I would like to know which unit test framework does not require building project as a library in order to run unit test code?

I tried the WinUnit but it seems only can test a library.

Any testing framework I know would allow that. It is an issue with the setting for your build environment, not the testing framework itself.

The easiest way to maintain it is to set up a library for your application code though.

I never used WinUnit, but I have used CppUnit and GoogleTest within VisualStudio projects where the code under test was not in a library, but the implementation files for the SUT were referenced (included) in the unit test project and it worked out.

Executables don't export symbols by default. You need to enable that with -Wl,--export-dynamic then link against the produced executable as though it was a library. This also means you need to do proper import/export on the classes you want to use etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM