[Development] Supporting helper functions in auto tests by providing throwing Qt Test macros

Robin Burchell robin.burchell at crimson.no
Wed Apr 3 12:53:19 CEST 2019


On Tue, Apr 2, 2019, at 5:17 PM, Mitch Curtis wrote:
> Quoting the commit message here:
> 
>     WIP: Add _THROW variants to testlib macros
> 
>     This allows using Qt Test macros in helper functions, avoiding the need
>     to write a lot of boilerplate code as seen with alternative approaches.

Allowing other functions to terminate a test would be great, but I wonder if it's worth considering changing the "regular" macros to terminate tests through an exception it throws internally, thus avoiding the need to introduce a new set of macros.

You could of course introduce a new macro specifically to throw (and I think that would be a good idea to automatically gather __FILE__ and __LINE__ in a non-messy way), but this way one could just use the regular macros we already know and love in new ways.

It would mean that tests would need to support exceptions unconditionally, but since it's "just" test code, perhaps this isn't that big a problem.

-- 
  Robin Burchell
  robin at crimson.no



More information about the Development mailing list