Re: [hackers] A very unconventional unit testing library

From: Mattias Andrée <maandree_AT_kth.se>
Date: Wed, 11 Aug 2021 14:35:00 +0200

Hi Thomas,

On Wed, 11 Aug 2021 13:42:25 +0200
Thomas Oltmann <thomas.oltmann.hhg_AT_gmail.com> wrote:

> Hi Andrée,
>
> Am Mi., 11. Aug. 2021 um 13:12 Uhr schrieb Mattias Andrée <maandree_AT_kth.se>:
> > This looks like a very neat test framework. I would however like
> > the file name to be printed in addition to line number as the
> > test can cover multiple files: the file with the tests and files
> > with utilities functions, or replacement for standard functions,
> > that the tests use.
>
> Thus far, my tests were simply pushing their filenames onto the hierarchy,
> which was good enough for my purposes.

That's a very good solution, I didn't think of that possibility.

> But you're right, it would be more flexible to always have the
> filename be part the error message.
>
> On a related note, I'm also not quite satisfied with the way dh_cuts
> is currently recovering from failures.
> Right now, after a failed assert, it will just keep going, reporting
> all further errors.
> This is sometimes useful, but when you're running tests in a loop, it
> can potentially result in a lot of messages.
> I think it might be best if I change it so that dh_cuts automatically
> aborts if any asserts fail.

Yes, you definitely want to abort as tests can assume that previous
tests were successful, and you don't want too much noise if it fails
in a large loop.

You could let the user choose what code to execute on failure, with
`exit(1);` as the default. This would let user perform a long jump to
the next test that doesn't depend on the failed code, or even do noting
and just carry on.

> You can still recover from the abort and keep going by encapsulating
> the test in a dh_branch() macro,
> so this shouldn't pose much of an issue.
>
> Best regards,
> Thomas
>

Regards,
Mattias Andrée
Received on Wed Aug 11 2021 - 14:35:00 CEST

This archive was generated by hypermail 2.3.0 : Wed Aug 11 2021 - 15:24:34 CEST