I got my Qt project and I’m using Qt Creator. I want to unit-test all my code.
However I’m quite new at QTestLib framework but everyone recommended it for testing Qt-based source. Now I’m a little confused how to structure test project with app project.
- Can I put all source and testing code in same project? If so, how could I manage them? I didn’t find any option that let me start app or start test in one project.
- If I put app source and testing code in separate projects, the testing project will reference app project, that’s not quite convenient.
- For lots for classes required to be tested, how do I manage testing code?
How do you guys manage testing code in such a situation? Thanks.
First structure source like below:
Under
MyAppproject, use aMyAppSrc.prito locate source files:Include this
.priinMyApp.prolike:Then structure the testing project exactly like the main project, with one extra include in
MyAppUnitTest.pro: