Automated Tests and KConfig

Matthieu Gallien gallien.matthieu at gmail.com
Tue Aug 18 20:41:45 BST 2020


Hello,

On mardi 18 août 2020 01:42:29 CEST Albert Astals Cid wrote:
> El dilluns, 17 d’agost de 2020, a les 23:57:20 CEST, Matthieu Gallien va 
escriure:
> > Hello,
> > 
> > I have been wandering if there is a general solution to use KConfig inside
> > automated tests.
> > 
> > I have been having difficulties (and another contributor to Elisa) to
> > integrate the singleton object lifetime with the need to run different
> > tests isolated and using the singleton (including code to initialize it).
> *
> Call
>   Elisa::ElisaConfiguration::instance(("testfoo"));
> in the initTestCase() function of each testfoo app?

In my case, I tried doing that but because the code I was testing is also 
calling it, I had troubles.
The currently failing test can be solved this way. Thanks for the help.

> Potentially include QStandardPaths::setTestModeEnabled(true) too?

Somehow, I had overlooked that. I will definitely makes good use of that.

> Or when you say "test" you mean each of the subtests inside a test app?
> 
> If you need to reset the values between them i guess you can just call
> setDefaults() in the init() function of each test app?

This is what I need. I also had overlooked that.

> Cheers,
>   Albert

Thanks Albert for the help

> > One problem I am trying to solve is calling <Class name>::initialize
> > multiple times.
> > 
> > One solution I have been using is encapsulating all KConfig code inside a
> > class and fake it in the tests. Is there other solution ?
> > 
> > Thanks
> > 
> > Best regards

Best regards






More information about the kde-core-devel mailing list