I'm about to start a C++ project but I'm stuck at the basics.
I want to use the (linux) Code::Blocks IDE, and it's easy to create a normal project. However I want to do TDD using the UnitTest++ framework, and I don't know how to set everything up cleanly.
I've already asked a question about where to put the UnitTest::RunAllTests()
command, and they told me the best place is the main()
of a separate program.
How do I go about doing this in Code::Blocks? I think I need to create 2 projects:
main()
; main()
with UnitTest::RunAllTests()
inside. Then somehow have the first project build and run the second during its build process. I don't know how to do that yet but I can find out on my own.
My questions are:
I'll partly answer my own questions, as I've managed to get everything working.
UnitTest::RunAllTests()
. I put $exe_output
as a post-build process here, in order to have the tests executed automatically every time I build this project. With these settings I can work on my tests and on the real code, and I only have to build the real one to have the updated tests executed. Any failing test will also make the build fail.
Now two questions remain: "is this the best approach?" and "right now each project lives in a different directory. Is it wiser to leave it this way or should I put each test in the same folder as the real code to be tested?"
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.