robotframework / JavalibCore

Base for implementing Java test libraries to be used with Robot Framework
Other
42 stars 25 forks source link

Single object of type map passed keyword as argument give emtpy map as result after argument collection #33

Open shan-96 opened 4 years ago

shan-96 commented 4 years ago

Coming from https://github.com/robotframework/JavalibCore/issues/19 and robotframework documentation as java has no support for explicit kwarg variable, a single map passed on to robot keyword without ** must also be considered as kwarg.

In KeywordInvoker.java and ArgumentCollector.java while collecting arguments args is not null with one non empty map but kwargs are null. But after keyword argument collection we receive one empty map which is wrong

Hi-Fi commented 4 years ago

I think there's still some confusion of kwargs in general, because RF own documentation states (implicitly) that single map can't be treated as kwarg from caller side

If a Java keyword accepts kwargs, Robot Framework will automatically pack all arguments in name=value syntax at the end of the keyword call into a Map and pass it to the keyword

According your use case you just want to use argument as type of map, not kwargs.

shan-96 commented 4 years ago

I think there's still some confusion of kwargs in general, because RF own documentation states (implicitly) that single map can't be treated as kwarg from caller side

If a Java keyword accepts kwargs, Robot Framework will automatically pack all arguments in name=value syntax at the end of the keyword call into a Map and pass it to the keyword

According your use case you just want to use argument as type of map, not kwargs.

Correct! I want to use the Map as normal arg but somehow it doesnt get parsed!

Hi-Fi commented 4 years ago

OK, I think now I started to see the issue. Not sure if I have time to check it within this week, but I'll try. Probably it requires new version from both JavalibCore and jrobotremoteserver, but let see.

shan-96 commented 4 years ago

Ok. If you need, you can go through my PR I will be adding few more test cases in it

Hi-Fi commented 4 years ago

Just remembered this, and noticed that there's a test that should check for that (https://github.com/robotframework/JavalibCore/blob/c649b8d629fc2afbc7da00b39bffdc3ced6a8754/src/test/java/org/robotframework/javalib/library/AnnotationLibraryIntegrationTest.java#L127).

So I'm still a bit puzzled of the issue.

Note that this needs annotations to work. With Classpathlibrary approach map is always varargs, and I don't think there's any reason to try to make any logic to try to determine if user wants to use arg or varargs.