Scope of external resources

163 views
Skip to first unread message

Andreas Brain

unread,
Jan 16, 2012, 1:09:03 PM1/16/12
to robotframework-users
Hi,

we have split our tests into several projects. The test suites only
contain test cases, the keywords are stored in a separate txt file,
that gets imported as external resource. We have three classes of
keywordlibraries, which have a specific hierarchy for high
reusability.
But it seems, that once you imported such library file, it will be
available in all other test suites or libraries, that didn't even
import it. This leads to the problem, that you define a keyword that
is unique in your project, but when there is a keyword with the same
name in another project, RF doesn't know which to use.
Is there a reason to keep it that way?

P.S.: I assume, with the current implementation it is impossible to
build cyclic dependencies, because every given file gets imported,
unless it already has been imported before. Am I right?

Thanks,
Andreas

Pekka Klärck

unread,
Jan 17, 2012, 4:39:41 PM1/17/12
to andrea...@googlemail.com, robotframework-users
2012/1/16 Andreas Brain <andrea...@googlemail.com>:

> Hi,
>
> we have split our tests into several projects. The test suites only
> contain test cases, the keywords are stored in a separate txt file,
> that gets imported as external resource. We have three classes of
> keywordlibraries, which have a specific hierarchy for high
> reusability.
> But it seems, that once you imported such library file, it will be
> available in all other test suites or libraries, that didn't even
> import it

Do you import the library in a resource file? If yes, then it is
available for all test suites that import that resource file either
directly or via another resource file. If you import a library in a
certain test suite, the keywords they implement should not leak to
other suites. If that happens it is a bug.

> P.S.: I assume, with the current implementation it is impossible to
> build cyclic dependencies, because every given file gets imported,
> unless it already has been imported before. Am I right?

Yes, cyclic imports should be prevented.

Cheers,
.peke
--
Agile Tester/Developer/Consultant :: http://eliga.fi
Lead Developer of Robot Framework :: http://robotframework.org

Andreas Brain

unread,
Jan 18, 2012, 8:54:41 AM1/18/12
to robotframework-users

> Do you import the library in a resource file? If yes, then it is
> available for all test suites that import that resource file either
> directly or via another resource file. If you import a library in a
> certain test suite, the keywords they implement should not leak to
> other suites. If that happens it is a bug.

Yes, we are using resource files for that.
And as far as I can see, the keywords don't leak to other suites.

But:
See this image: http://www.abrain.de/upload/RF_import_problem.png

The test suite imports two resouce files, "Resource 1" and "Resource
2"
In the keyword "Do something", the keyword "Click Button" is available
from both resource files (1a and 2a), although the resource file 1 (in
which the keyword "Do something" lives) only imported one of them
(1a).

Pekka Klärck

unread,
Jan 18, 2012, 3:11:15 PM1/18/12
to andrea...@googlemail.com, robotframework-users
2012/1/18 Andreas Brain <andrea...@googlemail.com>:

This is a limitation of Robot's import system. All imports are global
within a suite so all resources and libraries imported by your
resource 2 are visible also for resource 1. This is pretty annoying
and can be considered a bug -- feel free to submit an issue about this
with your image attached.

We are planning to refactor and cleanup importing logic and related
namespaces at some point but not yet in RF 2.7. I would like to fix
also this problem as part of the refactoring, but changes like this
are somewhat problematic as they change the execution logic in
backwards-incompatible manner. Probably this functionality can be
first deprecated somehow, but that makes implementing this a little
more complicated.

JaYa

unread,
May 27, 2016, 6:30:50 AM5/27/16
to robotframework-users, andrea...@googlemail.com
Hello,

I am also facing same issue what 'Andreas Brain' told,  is it resolved now??






One more thing i am facing here is,

When we import the resources those are getting listed in 'External Resource' folder.
When i do any changes in original file say 'resource1'  those are not getting updated in in resource file listed 'resource1' listed under 'External Resource'.

And when i execute the test cases that time they are referring to file listed under 'External Resource' folder not the original one whats why my changes are not coming into picture.

Please let me know what and how exactly the 'External Resource' works and how can i overcome above problem. 
Reply all
Reply to author
Forward
0 new messages