Unit Testing with Boost and Eclipse

2019-07-26 20:23发布

问题:

I can't work out how to get unit testing to work with Boost and Eclipse. I get lots of different errors depending on where I put the source files.

Where are the tests supposed to go? (ie should I create a test folder in root, in src, no folder at all or what)

Do I need to specify something somewhere if I don't intend to have a main(), and just lots of tests?

I'm really confused, and I know I'm being quite lite on the details - hopefully you can show me the proper way to do Unit Testing with Boost in Eclipse rather than whatever I'm currently doing.

回答1:

Compile your application in eclipse first normal without unit tests.

After that create a new Project and reference it to the former Project with your application. Than you create a main.cpp and insert your unit tests there.

You should be able to use the other projects classes from the new Project. Therefore, you are able to Instantiate Objects and do your asserts or whatever you like. If you have any further questions, please post your actual error and provide a screen-shot of your current structure.