To continue logging my progress with NetBeans.
I wanted to get into this whole unit testing business, since there's never been a class I actually used that for, and a lot of actual jobs want you to know it. So, since NetBeans is my current IDE of choice (I actually do not have a reason for this, except that I managed to make GDB and C++ work on it) and since the project has a logical folder called "Test Files", I decided to give it a try.
I'm mostly using
this guide, but it's sort of misleading, since it's doing CUnit and I wanted to do CppUnit. So, I followed that guide to install CUnit, and then I went on to add a CppUnit, oops. Turns out those two are different, so I had to install the CppUnit also. Which was confusing on Mac OS (I downloaded the file but couldn't figure out how to configure it on the first go through).
Then I remembered that I have Homebrew installed, so I decided to take full advantage of that. So, I did a:
brew install cppunit
which worked out-of-the-box.
And then I went on following the guide. I wrote the equivalent of their example (yeah, removed the .h includes essentially)
#include <cstdlib>
#include <iostream>
using namespace std;
long factorial(int arg) {
long result = 1;
int i;
for (i = 2; i <= arg; ++i) {
result *= i;
}
return result;
}
int main(int argc, char** argv) {
printf("Type an integer and press Enter to calculate the integer's factorial: \n");
int arg;
cin>>arg;
cout<<"factorial("<<arg<<") = "<<factorial(arg)<<endl;
return 0;
}
And then I right-clicked on the cpp file, selected Create Test -> New CppUnit Test, and then selected my cpp file (at the top of the options, which automatically also selected the factorial function). I left everything else default, per the tutorial.
And then I happily right clicked the Test Files logical folder, and selected Test from there, only to get a bunch of errors. Turns out Homebrew doesn't put the cppunit files where Netbeans expects them.
Turns out the newtestclass.h file contains this include
#include <cppunit/extensions/HelperMacros.h>
And the compiler has no idea where to look for that. This was an easy fix:
Preferences -> C/C++ -> Code Assistance -> C++ Compiler
Select Add on the right-hand-side, and add this:
/usr/local/Cellar/cppunit/1.12.1/include
So, that gets rid of the warning, but then the big error came.
/bin/sh: cppunit-config: command not found
along with many other information.
But! If I went to my terminal and ran
cppunit-config
it worked!
So, I googled forever for an answer, which took me through the netbeans.conf file to no avail. The only thing that worked was starting Netbeans from the terminal.