RED icon indicating copy to clipboard operation
RED copied to clipboard

Interpret "Set Library Search Order" keyword during compilation time

Open caioat opened this issue 7 years ago • 10 comments
trafficstars

I have tried a scenario where the keyword "Set Library Search Order" is called on the Suite Setup, to select some keywords related to a custom database library instead of the DatabaseLibrary without an explicit reference.

The test work as intended, but since eclipse does not interpret this scenario during compilation time, it shows some errors due ambiguous keyword between these two libraries.

I believe that a validation could be included on file TestCaseTableValidator.java, so the eclipse would take this keyword (and even others/any keywords) in consideration during compilation, but I'm not sure how viable this is since I just took a quick look at the code.

caioat avatar Apr 02 '18 17:04 caioat

Hi,

I've commented on very similar topic just recently: https://github.com/nokia/RED/issues/195#issuecomment-375589938 regarding dynamically created variables. This is very similar because it requires us to analyze runtime based on code which in general is not possible.

Furthermore this is not only a matter of validation because search order has to be used when e.g. user Ctrl+clicks on a keyword in order to go to definition. This would hit the performance too a little bit.

We were talking within the team a week or two ago that library search order can be changed dynamically, but we agreed that so far no one was asking us about this so we concluded that probably this feature is very rarely used.

What we could possibly do is to provide a preference in RED where the order can be defined and RED would search for definitions accordingly.

As a side note: do you want to have libraries names clash anyway or do you have to?

michalanglart avatar Apr 02 '18 19:04 michalanglart

This scenario happened when I tried to use RED on the company I work, and unfortunately I have to.

There are quite a lot of legacy/old tests that uses the DatabaseLibrary directly, but for some reason at some point a custom database library was implemented, which caused the ambiguity on these older tests. So, to avoid having all the tests retouched to use the new library, they added the "Set Library Search Order" on these tests Suite Setup.

I'm not very fond of this approach, but unfortunately can't do much about it...

About the preference to define the library order search, I believe it is a awesome solution, since it does not hit performance and solves the issue regarding any library used.

caioat avatar Apr 06 '18 18:04 caioat

Legacy stuff - that's what I thought actually when thinking about actual use cases for altering searching order.

The preference has a drawback: it would be applied globally in all the files in your project while theoretically different suites may have different search order applied.

However if global setting is fine we would be more than happy to provide it instead of much complex code analisys.

michalanglart avatar Apr 06 '18 18:04 michalanglart

I agree with the drawback, but I believe that the global setting will work just fine.

Thanks! :+1:

caioat avatar Apr 06 '18 18:04 caioat

Hello, I do have the same scenario on my company (Ericsson), which we also has a custom library (customDB) that was implemented to be more robust than DatabaseLibrary, CustomDB imports DatabaseLibrary so it also imports all functions from it leading to duplicate keyword reference during test execution.

From a first moment we started to use a prefix of the library to avoid situations mentioned on this discussion but we realized that adding Set Library Search Order would be a even more cleaver way and less polluted the code would be, less effort to maintain, so we started using that.

Now testing RED to become a substitute of the RIDE since it is not compatible with Python 3, once it is on our plan to migrate from P2 to P3, we have notice this error.

I would submit a new ticket if I haven't found this one.

so, +1 to implement this change/fix in a future update.

Thanks!

ghost avatar Aug 08 '18 18:08 ghost

Hi,

no progress so far have been made with this issue. I remember however that I found some problem when I was thinking more about "global setting solution" back in April, but now I don't remember what was that problem. Maybe need to go through my notes.

Anyway we'll keep you updated once we start investigating/implementing it.

michalanglart avatar Aug 09 '18 06:08 michalanglart

Hi everyone,

Glad to know there are more people who think this behaviour would be desired. Meanwhile, is there any way we can disable the specific "Ambiguous keyword" error message without disabling the remaining runtime errors?

Thanks!

direde avatar Sep 14 '18 13:09 direde

Hi,

no it's not possible. There was an idea to make it possible to suppress some validation markers locally for certain lines in file but so far we've only discussed this feature.

michalanglart avatar Sep 14 '18 14:09 michalanglart

Hello,

To add another use case, we would like to use the same resource files to run web application tests either via SeleniumLibrary or with AppiumLibrary. We can't have both libraries in the settings without seeing thousands of "Ambiguous keyword" errors.

Being able to suppress these errors would make it so we don't have to duplicate a majority of our tests that don't require mobile specific keywords.

carllp avatar Mar 06 '19 10:03 carllp

Starting in 0.9.0 it is possible to change the severity of ambigous keyword error via: Preferences -> Robot Framework -> Errors/Warnings -> Runtime -> Ambigous keyword call.

michalanglart avatar Nov 28 '19 14:11 michalanglart