Skip to content

UNIT TESTING

Felipe Fonseca edited this page Mar 11, 2018 · 7 revisions

Installing LCOV

  • Need GCC compiler.

    • Note: MinGW compiler will have some issues with Windows. So it is preferred to use Ubuntu or Mac.
  • Need to install lcov http://ltp.sourceforge.net/coverage/lcov.php

  • On your test .pro file add the following lines:

    • LIBS += -lgcov
    • QMAKE_CXXFLAGS += --coverage
    • QMAKE_LFLAGS += --coverage
    • QMAKE_CXXFLAGS += -g -fprofile-arcs -ftest-coverage -O0
    • QMAKE_LFLAGS += -g -fprofile-arcs -ftest-coverage -O0
  • Build and Run Test Project, not SubutaiTray Project

  • Go to build directory of Test Project and write the following:

    • lcov --no-external --directory . --directory ../tray/commons ../tray/libssh2 ../tray/hub ../tray/commons ../tray/vbox --capture --output-file app.info
    • genhtml app.info
  • In this directory the index.html file will be created, go and look your coverage

  • Add this to run arguments to automatically run and build with lcov -txt > tlog && sudo chmod a+x /home/tilek/Desktop/tray/tests/AutoRunLcov.sh && /home/tilek/Desktop/tray/tests/AutoRunLcov.sh

  • Auto lcov running script - https://github.com/subutai-io/control-center/blob/master/tests/AutoRunLcov.sh

  • Check run in terminal checkbox

Running test

Configure Build by adding CONFIG += tests but it could be done by adding new build system as explained in this tutorial: http://xilexio.org/?p=125