Search code examples
c++unit-testingnetbeansintegration-testingcppunit

Managing Integration Tests in C++


I'm using Netbeans for developing an enterprise project which has unit tests and integration tests. I'm using CPPUNIT for developing unit tests but I have a problem. As you know unit test should be quick so I developed them small and I can run them by using IDE plugin every time I need. But integration test are some time consuming test which cannot be run time to time. So where should I store them? If I put them into another project their management will become a nightmare. If I put them in current project I cannot tell the Netbeans that they should not be run in executing unit tests. What is your idea about my problem?


Solution

  • I assume you are using the NB make build management (= default C++ project). It's very tricky with those; you my try using different configurations, but that's not perfect though.

    My recommendation is using a dedicated build tool like Cmake, which is greatly supported by Netbeans. This will allow you a clear separation of Unit- and integration tests within one project.

    So your project might look like this:

    <project>
    |
    +-- src/
    |
    +-- include/
    |
    +-- test/ (unit tests)
    |
    +-- integration/ (integration tests)
    |
    …
    

    You than can use different make targets; eg. make unittest or make integrationtest. It's also possible to disable each kind of test as you need them (so they wont compile / carry dependencies).

    In the build settings you can even set, that the unittests should be build and executed after each build by default - while you run the integration tests manually whenever you need to.

    Btw. the project isn't bound to an IDE from now on. You can develop using whatever tool you want to + Continuous Integration server can handle it too.