Simpler cppunit tests, CPPUNIT_TEST_FIXTURE

Miklos Vajna vmiklos at collabora.co.uk
Thu Nov 8 08:13:45 UTC 2018


Hi,

<https://cgit.freedesktop.org/libreoffice/cppunit/commit/?id=48145587c4c2dc4f1e07d83073e136336c81ce79>
adds a macro in cppunit that allows not spelling out the declaration /
definition / registration of a testcase in a testsuite, but you can just
do all of this with a single line of code. If you used googletest in
other projects, this is probably familiar to you.

This is just a macro, so it's easy to "bundle" it in core.git (for both
the system and bundled cppunit case), so we can unconditionally use it
right now.  An example conversion looks like this:

https://cgit.freedesktop.org/libreoffice/core/commit/?id=caec23449a21c0eacbb593330a5b22f8c60d58e8

Hopefully it's obvious how this avoids repetition, also makes it
impossible to get the wrapping ifdefs wrong around the
declaration/definition/registration in case such a condition is
necessary.

Declaring what exact testcase you want to run is still possible by
setting CPPUNIT_TEST_NAME to "testFoo" from
CPPUNIT_TEST_FIXTURE(FooTest, testFoo).

Do anybody see this as a controversial move? If not, I think it would be
good to use this markup in two cases:

- new tests where you don't need to convert anything

- old tests where custom macros are used to do something similar, e.g.
  DECLARE_OOXMLEXPORT_TEST() (those custom macros are hard to understand
  if you don't work on that area, cf. Stephan's conference talk
  recently).

Perhaps an easy hack could be created for the second point, but I would
prefer some feedback before I go further with this.

Thanks,

Miklos
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: Digital signature
URL: <https://lists.freedesktop.org/archives/libreoffice/attachments/20181108/4b4738ab/attachment.sig>


More information about the LibreOffice mailing list