Skip to content
awaldow edited this page Dec 7, 2012 · 6 revisions

We're currently using the Google Unit test framework gtest. Unfortunately, Google removed the precompiled version of the testing framework from the Ubuntu repository claiming that one should compile it from source with the same compiler flags used on the tests to avoid linking/runtime issues. Here's a quick cheat sheet to get it installed and working with the NovaTest folder. It's assumed that NovaTest resides in ~/Code/Nova/NovaTest. Gtest will be put into ~/Code/.

cd ~/Code
wget https://googletest.googlecode.com/files/gtest-1.6.0.zip
unzip gtest-1.6.0.zip
cd gtest-1.6.0
./configure
make
sudo cp -d ~/Code/gtest-1.6.0/lib/.libs/*.so* /usr/lib/
sudo cp -fr ~/Code/gtest-1.6.0/include/gtest /usr/include/gtest
sudo ldconfig
cd ~/Code/Nova
make test

Import NovaTest into Eclipse as an existing Eclipse project. The NovaTest project should build and run now in Eclipse. A sample output is shown below.

	[==========] Running 18 tests from 5 test cases.
	[----------] Global test environment set-up.
	[----------] 2 tests from ConfigTest
	[ RUN      ] ConfigTest.test_instanceNotNull
	[       OK ] ConfigTest.test_instanceNotNull (5 ms)
	[ RUN      ] ConfigTest.test_setEnabledFeatures
	[       OK ] ConfigTest.test_setEnabledFeatures (0 ms)
	[----------] 2 tests from ConfigTest (5 ms total)

            ...

	[----------] 10 tests from SuspectTableTest
	[ RUN      ] SuspectTableTest.Begin
	[       OK ] SuspectTableTest.Begin (5 ms)
	[ RUN      ] SuspectTableTest.End
	../src/tester_SuspectTable.h:59: Failure
	Value of: table.End().GetIndex()
	  Actual: 0
	Expected: (uint)1
	Which is: 1
	[  FAILED  ] SuspectTableTest.End (9 ms)
	[ RUN      ] SuspectTableTest.Find
	[       OK ] SuspectTableTest.Find (5 ms)
	[ RUN      ] SuspectTableTest.Size
	[       OK ] SuspectTableTest.Size (5 ms)
	[ RUN      ] SuspectTableTest.GetKeys
        
            ....

	[----------] Global test environment tear-down
	[==========] 18 tests from 5 test cases ran. (105 ms total)
	[  PASSED  ] 17 tests.
	[  FAILED  ] 1 test, listed below:
	[  FAILED  ] SuspectTableTest.End

	 1 FAILED TEST

NovaTest can be run in the debugger like any other program for debugging of failed tests.

For creating new tests, there's a file 'tester_TEMPLATE.h' in the NovaTest project that has an outline for setting up tests.