On a system without installed kcoreaddonsl language package kformattest does not return any error: ~/src/kf5/kcoreaddons-build> bin/kformattest ********* Start testing of KFormatTest ********* Config: Using QtTest library 5.11.1, Qt 5.11.1 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 4.8.5) PASS : KFormatTest::initTestCase() PASS : KFormatTest::formatByteSize() PASS : KFormatTest::formatDuration() PASS : KFormatTest::formatDecimalDuration() PASS : KFormatTest::formatSpelloutDuration() PASS : KFormatTest::formatRelativeDate() PASS : KFormatTest::formatValue() PASS : KFormatTest::cleanupTestCase() Totals: 8 passed, 0 failed, 0 skipped, 0 blacklisted, 2ms ********* Finished testing of KFormatTest ********* With installed kcoreaddons language package it returns on a system using 'de_DE' locale ~/src/kf5/kcoreaddons-build> bin/kformattest ********* Start testing of KFormatTest ********* Config: Using QtTest library 5.11.1, Qt 5.11.1 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 4.8.5) PASS : KFormatTest::initTestCase() PASS : KFormatTest::formatByteSize() FAIL! : KFormatTest::formatDuration() Compared values are not the same Actual (format.formatDuration(singleSecond, options)): "0 h 00 m 04 s" Expected (QStringLiteral("0h00m04s")) : "0h00m04s" Loc: [/home/ralf/src/kf5/kcoreaddons/autotests/kformattest.cpp(226)] FAIL! : KFormatTest::formatDecimalDuration() Compared values are not the same Actual (format.formatDecimalDuration(10)) : "10 Millisekunde(n)" Expected (QStringLiteral("10 millisecond(s)")): "10 millisecond(s)" Loc: [/home/ralf/src/kf5/kcoreaddons/autotests/kformattest.cpp(302)] FAIL! : KFormatTest::formatSpelloutDuration() Compared values are not the same Actual (format.formatSpelloutDuration(1000)): "1 Sekunde(n)" Expected (QStringLiteral("1 second(s)")) : "1 second(s)" Loc: [/home/ralf/src/kf5/kcoreaddons/autotests/kformattest.cpp(318)] FAIL! : KFormatTest::formatRelativeDate() Compared values are not the same Actual (format.formatRelativeDate(testDate, QLocale::LongFormat)): "Heute" Expected (QStringLiteral("Today")) : "Today" Loc: [/home/ralf/src/kf5/kcoreaddons/autotests/kformattest.cpp(341)] PASS : KFormatTest::formatValue() PASS : KFormatTest::cleanupTestCase() Totals: 4 passed, 4 failed, 0 skipped, 0 blacklisted, 1ms ********* Finished testing of KFormatTest ********* and with 'C' locale ~/src/kf5/kcoreaddons-build> LC_ALL=C bin/kformattest ********* Start testing of KFormatTest ********* Config: Using QtTest library 5.11.1, Qt 5.11.1 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 4.8.5) PASS : KFormatTest::initTestCase() PASS : KFormatTest::formatByteSize() PASS : KFormatTest::formatDuration() FAIL! : KFormatTest::formatDecimalDuration() Compared values are not the same Actual (format.formatDecimalDuration(10)) : "10 milliseconds" Expected (QStringLiteral("10 millisecond(s)")): "10 millisecond(s)" Loc: [/home/ralf/src/kf5/kcoreaddons/autotests/kformattest.cpp(302)] FAIL! : KFormatTest::formatSpelloutDuration() Compared values are not the same Actual (format.formatSpelloutDuration(1000)): "1 second" Expected (QStringLiteral("1 second(s)")) : "1 second(s)" Loc: [/home/ralf/src/kf5/kcoreaddons/autotests/kformattest.cpp(318)] PASS : KFormatTest::formatRelativeDate() PASS : KFormatTest::formatValue() PASS : KFormatTest::cleanupTestCase() Totals: 6 passed, 2 failed, 0 skipped, 0 blacklisted, 1ms ********* Finished testing of KFormatTest *********
One of the problem is that the test case is designed not to use translation, but a translation is always loaded from the kcoreaddons library. This is configured in the cmake build system by calling ecm_create_qm_loader(kcoreaddons_QM_LOADER kcoreaddons5_qt) which adds loading of a translation to qAddPreRoutine() unconditional. This support needs to be disabled for the test app by not loading a translation if current locale is != 'C'. Second in main() 'C' locale needs to be set before using QCoreApplication. Unfortunally main is hidden in the macro QTEST_MAIN(KFormatTest)
See https://phabricator.kde.org/D14779 for the related review