0

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++

callmebob
  • 6,128
  • 5
  • 29
  • 46
  • Have you verified the files actually exist? I don't use ubuntu (or any apt-based distro), but they're probably under `/usr/include`. Also, please include the full compilation line (it's probably above the error you already provided). – Stephen Newell Mar 06 '19 at 13:27
  • Build log added. Also on top of my post there is output "ls -la /usr/include" where you can see UnitTest++. It's with capitals and doesn't have .h at the end. I tired including with no .h with the same results though. – callmebob Mar 06 '19 at 13:37
  • Based on your `ls` output, my hunch is that the directory name in your code is incorrect. Try changing the first line to `#include ` (you may want to verify the contents of `/usr/include/UnitTest++` first). – Stephen Newell Mar 06 '19 at 13:42
  • @StephenNewell: you were correct. I had to change it to at the end. From here, I was able to build, but now on CTRL+F5 I was getting nothing at all. Seems like I have to do CTRL+F9 (Build and run) to get results - not sure why, but it works. If you want add an answer and I will accept it as you pointed me to the correct direction. – callmebob Mar 06 '19 at 13:55
  • Glad it worked! – Stephen Newell Mar 06 '19 at 14:24

1 Answers1

1

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.

Stephen Newell
  • 7,330
  • 1
  • 24
  • 28
  • Yes, that's a bit weird with the lowercase. My initial code was also auto-generated with lowercase, like in my example. Probably best if I report a bug. – callmebob Mar 06 '19 at 14:42