Search code examples
c++unit-testingcodeliteunittest++

codelite unittest++/UnitTest++.h: no such file or directory


I am trying to do unit testing with C++/Codelite. I have UnitTest++ plugin installed from codelite-plugins package (Ubuntu 18.04). I can also see this:

$ ls -la /usr/include | grep Unit
drwxr-xr-x  3 root root   4096 Mar  2 11:47 UnitTest++

$ sudo dpkg -l | grep unittest++
ii  libunittest++-dev         2.0.0-2      amd64        unit testing framework for c++, static library and headers
ii  libunittest++2:amd64      2.0.0-2      amd64        unit testing framework for c++, runtime library

So I create a test project in Codelite and I add this:

#include <unittest++/UnitTest++.h> // This line and main are auto-created

TEST(SanityTest) 
{
    CHECK_EQUAL(1, 1);
}

int main(int argc, char **argv)
{
    return UnitTest::RunAllTests();
}

Now I would expect test results after I press CTRL+F5. But when I do, I only get a popup window saying there are no tests:

enter image description here

I also noticed that when I go to Build > Build Project I get an error message:

fatal error: unittest++/UnitTest++.h: No such file or directory

I also found THIS ANSWER and tried different variation of console commands as per answer/comments there, but I always get the same no such file or directory error.

Any idea what I am missing?

EDIT:

Build log as per Stephen's Newell request:

/bin/sh -c '/usr/bin/make -j8 -e -f  Makefile'
----------Building project:[ Test - Debug ]----------
make[1]: Entering directory '/home/callmebob/Documents/workspace-codelite/cpp/Test'
/usr/bin/g++  -c  "/home/callmebob/Documents/workspace-codelite/cpp/Test/main.cpp" -g  -o Debug/main.cpp.o -I. -I/usr/include/unittest++
/home/callmebob/Documents/workspace-codelite/cpp/Test/main.cpp:1:10: fatal error: unittest++/UnitTest++.h: No such file or directory
 #include "unittest++/UnitTest++.h"
          ^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Test.mk:95: recipe for target 'Debug/main.cpp.o' failed
make[1]: *** [Debug/main.cpp.o] Error 1
make[1]: Leaving directory '/home/callmebob/Documents/workspace-codelite/cpp/Test'
Makefile:4: recipe for target 'All' failed
make: *** [All] Error 2
====2 errors, 0 warnings====

Also if I right-click the project, go to Settings > Compiler, I can see:

Included Paths = /usr/include/unittest++


Solution

  • Based on your ls output, it looks like you should change your first line to this:

    #include <UnitTest++/UnitTest++.h>
    

    I'm not sure why the answer you linked to worked with a lowercase directory name; the examples in the project documentation all use the mixed-case directory name.