Wednesday, 22 October 2014

Qt + CMake + code coverage

Yesterday I was working on getting reports on code coverage for Injeqt library. I've found several tutorials on the internet, but every one of them was missing a detail or two.

So here is what I've come with:

1. Update compiler and linker flags in CMakeLists.txt file of your tests:
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -W -g
    -fprofile-arcs -ftest-coverage -O0")
    -fprofile-arcs -ftest-coverage -O0")
    -fprofile-arcs -ftest-coverage -O0")
2. Link each test with gcov library:
target_link_libraries (test-target-name gcov)
3. Add new target for extracting coverage data:
add_custom_target (coverage
4. Insert script into directory of CMakeLists.txt:

lcov --capture --directory . --output-file
lcov --directory . --output-file \
    --remove "/usr/*" "*.moc" "test/*"
First lcov invocation will capture all data from previously executed tests. Second will remove useless data like coverage of generated moc files or of standard library headers and tests themselves.

5. Run tests and coverage:
make test
make coverage
6. Enjoy nice HTML coverage report.

Injeqt got 90,4% of lines coverage on first try! I hope to make it even better today.

Saturday, 11 October 2014


On Monday, just before leaving for Qt Developer Day, I was polishing my presentation on Injeqt. Of course HDD decided to crash at the very moment before exporting final version to PDF and moving it to pendrive.

Fortunately I was able to quickly recreate what I've lost and even order new drive (this time SSD) before leaving and now I'm slowly getting all my stuff installed and set up for further development. Kadu and Injeqt progress is delayed just a few days.

After that is done I hope to move all bugs for 1.0 from forum to redmine and start working on them a little bit before returning to writing tests for Injeqt. Stay tuned!

Thursday, 2 October 2014

Injeqt on Qt Developer Days

Next week I'll be attending Qt Developer Days in Berlin.

I'm giving lighting talk about Injeqt - a dependency injection framework for Qt that you will fall in love with! I hope a lot of people will show up ;)