Error When Creating Unit Tests in Full Mode

I’m trying to write some unit tests for a LibreOffice VBA script using the instructions here:

https://help.libreoffice.org/latest/ug/text/sbasic/shared/03/sf_unittest.html

Tests in Simple Mode work fine. However, when I try to run tests in Full Mode, I receive the following error:

Library: ScriptForge
Service: SF_Services
Method: CreateScriptService
Arguments: Service, arg0[, arg1] …
The requested library could not be located.
The UnitTest service has not been initialized.
Library name : << Tests >>
THE EXECUTION IS CANCELLED.
Do you want to receive more information about the ‘CreateScriptService’ method? (Yes/No)

You can see the full popup here.

As far as I can tell, I’m following the instructions on the website to the letter:

I’d like to set up a Full Mode of tests rather than using Simple Mode. Any thoughts on what I might be doing wrong? I welcome any insight the community can provide. Thanks!

Cross posted on Reddit

If you cross post, as a courtesy please let us know that you have done so, otherwise it leads to several discussions and a waste of time because several identical answers may be posted by different users.

a would-be-nice-to-have :innocent:

you may then try a third cross post : Development/Mailing List - The Document Foundation Wiki

[and courteously update all of them if you get an answer :wink: ]

Perhaps suggest at Site Feedback?

The example from the help file presumes that the testing code is located in the Standard and Tests libraries of the current document. Read the text there carefully.

Remove the mention of ThisComponent in line 5 (keeping the commas). There is a chance that it will work as requested (not tested by me). Otherwise store the code in a document.

Ah, okay, that did it.

CreateScriptService("UnitTest", , "Tests")

I didn’t realize the difference between global macros (My Macros and Dialogs) and those attached to a specific document. I frequently use ThisComponent in the global macros, and it just refers to whatever document I have open at the time. However, since the tests are not being run in the context of a specific document, I can appreciate why ThisComponent wouldn’t work.

Thank you for your help!