Hello,
I am currrently trying to get a teststand (system tests for an embedded device) going with the following premise in mind:
I have multiple suites to group tests and they are organized hierachically…
- Base-Testand > folder with init.robot
-
- Suite #1 > folder with init.robot
-
- Suite #2 > folder with init.robot
-
- Suite #3 > folder with init.robot
-
-
- Suite #31 > folder with init.robot
-
-
-
-
- Testfile #311 > file with a test suite (mostly containing one testcase)
-
-
Any test running from any level , for example #311 needs certain devices (power supplies, etc.) and those devices shall only be present (imported) once across the complete execution with a specific name (there can be multiple devices of the same type, each with an individual name and individual parameters for things like COM-port, etc…)…
I achieve such representation of multiple devices of the same type (und therefore the same library) as follows:
- Library devtype1/devtype1.py port=COM20 baudrate=${9600} AS devtype1_instanceA
- Library devtype1/devtype1.py port=COM20 baudrate=${9600} AS devtype1_instanceB
The library devtype1/devtype1.py contains a single class with “ROBOT_LIBRARY_SCOPE = ‘GLOBAL’” in the class (acc. Robot Framework User Guide)…
The init.robot in folder “Base-Testand” uses a resource file, which performs these “library instanciations” as well as provides keywords for setup and teardown, which are called directly in that init.robot file (on level Base-Teststand).
so far, so good…
Now, for these instances to be available, either during development in VSCode as well as at runtime for just calling keywords from “devtype1_instanceA” oder “devtype1_instanceB”, I additionally need to load the resource file within the test file as I have already done in the init.robot at Base-Testand level.
This is what does not make sense currently for me, since those “instances” named “devtype1_instanceA” and “devtype1_instanceB” have scope=global set by the python lib…
Why is this second load of the resource file in the lower-level testfile necessary when the library is set to scope=global…?
Thanks !
Cheers
Niels Göran
===
P.S.:
I checked if this import of the two instances is actually running correctly…
It appears as this mostly the case… with some interesting observations…
it also works as expected…
Somehow the SCOPE and VERSION assignments are interpreted as keywords even in the BuiltIn lib… this happens at the first import (following are from cache, and do not show this message)
00:31:21.207 In library ‘BuiltIn’: Adding keyword ‘ROBOT_LIBRARY_SCOPE’ failed: Not a method or function.
00:31:21.208 In library ‘BuiltIn’: Adding keyword ‘ROBOT_LIBRARY_VERSION’ failed: Not a method or function.
At the end of this import, the BuiltIn lib seems to imported correctly, and got assigned the scope== GLOBAL
00:31:21.233 Imported library ‘BuiltIn’ with arguments [ - ] (version 7.2, class type, GLOBAL scope, 107 keywords).
Furthermore, the first suite below “Base-Teststand”, named “Suite #1”, the Builtin lib is imported again, but this time from cache…
00:31:21.238 Found library ‘BuiltIn’ with arguments [ - ] from cache.
On the level, where I load the resource file (which in turn imports the library with a specific name), the library is loaded correctly as GLOBAL (but also showing the issue with “SCOPE and VERSION assignments being interpreted as keywords”):
00:31:21.244 Imported resource file ‘base-testStand.resource’ (4 keywords).
00:31:21.254 Imported library class ‘example’ from ‘example.py’.
00:31:21.269 Imported library ‘example.py’ with arguments [ port=COM20 | baudrate=9600 ] (version 0.1.0, class type, GLOBAL scope, 10 keywords).
00:31:21.269 Imported library ‘example.py’ with name ‘devtype1_instanceA’.
Still makes sense to me, since the library was imported with specific values for the constructor (as specified and scope global…
Not sure, why the name only shows up in the second line…
Within the debug messages for the test file “Testfile #311” itself, I found:
00:48:04.878 Found resource file ‘base-testStand.resource’ from cache.
00:48:04.881 Imported library class ‘example’ from ‘example.py’.
00:48:04.883 Found library ‘example.py’ with arguments [ port=COM20 | baudrate=9600 ] from cache
00:48:04.884 Imported library ‘example.py’ with name ‘devtype1_instanceA’.
Only difference being the “from cache”…