# Unit testing ¶

Here we will just add a test that checks that forty plus two are forty-two. (Just in case ...)

Call  qi_create_test  with the first argument being the name of the test, and the rest being the sources of the executable.



qi_create_test(foo_test test.cpp)



If you have arguments to pass to the executable you want to test, simply add them to the  qi_create_test  call, like this:



qi_create_test(foo_test foo_test.cpp ARGUMENTS "--foo=bar")



If you have  gtest  installed, you can use  qi_create_gtest  :



qi_create_gtest(foo_test foo_test.cpp
DEPENDS gtest)



This will automatically add the –xml-output option to store the results of the test as XML files in  foo/build-<config>/tests-results  , which is useful when you are doing continuous integration.

If you need to run the same executable with different arguments, you should use a lower-level function called  qi_add_test 



qi_create_bin(test_launcher
test_launcher.cpp NO_INSTALL)


Please read Note for CTest users before using  qibuild test  for continuous integration.