Thank you.

I think the g_test_init is necessary mainly for
the g_test_log_set_fatal_handler and/or the g_log_set_handler. So, I think
I will need it even after I replace the glib random numbers.

I personally don't like random numbers inside a test anyway.  Does it make
sense to use a fixed number in the range instead?


On Thu, Jan 22, 2026 at 12:15 AM John Ralls <[email protected]> wrote:

> Stefan,
>
> You write that you had to use TEST_F as if it was a bad thing. Using
> fixtures is a *good* thing.
> I think that the message handling is separate from g_test and doesn’t
> require g_test_init, but your custom main() also inits QOF and the logging
> system so I guess you’re stuck with it.
>
> I made some comments on your commit.
>
> Regards,
> John Ralls
>
>
> On Jan 21, 2026, at 11:53, Stefan Koch <[email protected]>
> wrote:
>
> (Thank you for merging my first commit test-qofid.cpp).
>
> I am moving on to adding more coverage, in particular I thought in the
> qofinstance would be a good low level next step.
>
> This is currently in part of the glib based test for test-oqf.  I am
> proposing removing it from there and making it a stand alone google test.
> I like the stand alone test because it allows me just to run this one and
> see the coverage of just this test. (That removes other tests from
> providing accidental coverage.)
>
> I also like full coverage since it is easy to check for 100% coverage, but
> hard to check if the coverage moved from 88% to 85% when running tests.  I
> cannot get 100% coverage since there are some lines that are unreachable
> when the other subsystems are correct.  I thought I saw some setup in lcov
> that allows marking of lines to not be covered, but I have not investigated
> that further.
>
> There were some issues that I had to work out:
> 1. I had to use the google TEST_F so that I could have a class to replace
> the setup and teardown from glib testing.
> 2. I had to create a main() that overrides the default google one, that
> allows the setting g_test_init which is still needed since the qofinstance
> still makes use of the glib error handling.
> 3. I replaced the g_assert functions with the equivalent google test calls.
> 4. I replaced the g_test_message with a local call that does printf.
>
> The I have not added extra coverage.  I wanted to verify that this
> approach is what is desired here, or if this is too to change, and not
> worth your time reviewing.
>
> The commit can be seen here:
> https://github.com/stefan-koch-micro/gnucash/commit/fc5742e12d8007f86929450080750a14bec3ec43#diff-dcd2eece63e17b3ec55c96a3eab8a60c4582884a2d01b47b1c4940c1c0594bf0
> I have not made a pull request as this is a partial implementation. If the
> approach is OK, I will add more/full coverage and then make a merge
> request. (Or even do more of the test-qof set before making the request.)
> _______________________________________________
> gnucash-devel mailing list
> [email protected]
> https://lists.gnucash.org/mailman/listinfo/gnucash-devel
>
>
>
_______________________________________________
gnucash-devel mailing list
[email protected]
https://lists.gnucash.org/mailman/listinfo/gnucash-devel

Reply via email to