Re: [GNC-dev] [GNC] Unit Tests

john <[email protected]>
Newsgroups gmane.comp.gnome.apps.gnucash.devel
Message-ID <[email protected]>

> On Aug 11, 2022, at 4:56 AM, Robert Simmons <[email protected]> wrote:
> 
> Looking at the code repo I see a directory of unit tests, but it doesn't
> look like it has actual unit tests. Do you all do continuous integration
> somewhere and have unit tests? When a software defect is identified and
> fixed, do you create a unit test based on the fix?

If you found only one directory of tests you didn't look very hard:
$ find * -name "*test*" -type d | wc -l
      25

The tests are mixture of unit tests, fuzzers, and integration tests. You'll notice that there are a lot more in the libgnucash/ core than in the UI-centric gnucash/; that's in large part because the MVC violations we discussed a couple of days ago make it difficult to write tests. That's actually part of a broader problem, that the code isn't well separated for responsibilities so meaningful unit tests aren't always possible.

There's a build target "check" to build and run all of the tests. We try to keep the dependencies lined up so that building all isn't a prerequisite but that occasionally gets out of whack so I generally use `ninja && ninja check` to make sure.

CI is performed via Github actions, see https://github.com/Gnucash/gnucash/tree/maint/.github/workflows.

Contrary to Derek's claim I'm afraid that none of us are sufficiently self-disciplined enough to reliably add a test when we fix a bug. It does happen from time to time, but tests are more often added when refactoring or rewriting than when bug fixing.

Regards,
John Ralls
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.