Defensive programming for unit-test result publising.
Make it slightly more robust, since there have been problems with this in the past aparently (see github.com/ations/runner/1722). Manual rewrite of earlier pull-request Cura/pull/13497
Co-authored-by: 0r31 <orel@dagoma.fr>