Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

passing Dictionary to Keyword with List argument creates ClassCastException #34

Open
hleskien opened this issue Feb 5, 2020 · 2 comments

Comments

@hleskien
Copy link

hleskien commented Feb 5, 2020

Hi,

tested with Javalib-Core 2.0.3:

Java-Library:

    @RobotKeyword("Fügt eine neue Zeile mit den Werten der Liste ``values`` hinzu und gibt ihre y-Koordinate zurück.\r\n" +
            "\r\n" +
            "Beispiel:\r\n" +
            "| @{row}= | Create List | 1 | 2 | 3 |\r\n" +
            "| ${y}= | Add Row | ${row} |")
    @ArgumentNames({"values"})
    public int addRow(List<Object> values) {
        [...]
    }

Robot-Test:

    &{dict}=    Create Dictionary
    Add Row    ${dict}

Result:

java.lang.RuntimeException: 
	at org.robotframework.javalib.reflection.KeywordInvoker.invoke(KeywordInvoker.java:65)
	at org.robotframework.javalib.beans.annotation.AnnotationKeywordExtractor$1.execute(AnnotationKeywordExtractor.java:66)
	at org.robotframework.javalib.library.KeywordFactoryBasedLibrary.runKeyword(KeywordFactoryBasedLibrary.java:40)
	at org.robotframework.javalib.library.AnnotationLibrary.runKeyword(AnnotationLibrary.java:129)
	at robot.libraries.BuiltIn$py.run_keyword$105(C:\Users\hifi\git\robotframework\build\Lib\robot\libraries\BuiltIn.py:1614)
	at robot.libraries.BuiltIn$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\libraries\BuiltIn.py)
	at robot.libraries.BuiltIn$py.run_keyword_and_expect_error$121(C:\Users\hifi\git\robotframework\build\Lib\robot\libraries\BuiltIn.py:1909)
	at robot.libraries.BuiltIn$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\libraries\BuiltIn.py)
	at robot.model.testcase$py.visit$7(C:\Users\hifi\git\robotframework\build\Lib\robot\model\testcase.py:74)
	at robot.model.testcase$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\model\testcase.py)
	at robot.model.itemlist$py.visit$11(C:\Users\hifi\git\robotframework\build\Lib\robot\model\itemlist.py:71)
	at robot.model.itemlist$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\model\itemlist.py)
	at robot.model.visitor$py.visit_suite$2(C:\Users\hifi\git\robotframework\build\Lib\robot\model\visitor.py:88)
	at robot.model.visitor$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\model\visitor.py)
	at robot.model.testsuite$py.visit$19(C:\Users\hifi\git\robotframework\build\Lib\robot\model\testsuite.py:168)
	at robot.model.testsuite$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\model\testsuite.py)
	at robot.model.itemlist$py.visit$11(C:\Users\hifi\git\robotframework\build\Lib\robot\model\itemlist.py:71)
	at robot.model.itemlist$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\model\itemlist.py)
	at robot.model.visitor$py.visit_suite$2(C:\Users\hifi\git\robotframework\build\Lib\robot\model\visitor.py:88)
	at robot.model.visitor$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\model\visitor.py)
	at robot.model.testsuite$py.visit$19(C:\Users\hifi\git\robotframework\build\Lib\robot\model\testsuite.py:168)
	at robot.model.testsuite$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\model\testsuite.py)
	at robot.run$py.main$3(C:\Users\hifi\git\robotframework\build\Lib\robot\run.py:448)
	at robot.run$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\run.py)
	at robot.utils.application$py._execute$10(C:\Users\hifi\git\robotframework\build\Lib\robot\utils\application.py:94)
	at robot.utils.application$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\utils\application.py)
	at robot.utils.application$py.execute_cli$5(C:\Users\hifi\git\robotframework\build\Lib\robot\utils\application.py:49)
	at robot.utils.application$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\utils\application.py)
	at robot.run$py.run_cli$7(C:\Users\hifi\git\robotframework\build\Lib\robot\run.py:488)
	at robot.run$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\run.py)
	at robot.jarrunner$py._run$3(C:\Users\hifi\git\robotframework\build\Lib\robot\jarrunner.py:64)
	at robot.jarrunner$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\jarrunner.py)
	at robot.jarrunner$py.run$2(C:\Users\hifi\git\robotframework\build\Lib\robot\jarrunner.py:57)
	at robot.jarrunner$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\jarrunner.py)
	at org.robotframework.RobotRunner.run(RobotRunner.java:74)
	at org.robotframework.RobotFramework.run(RobotFramework.java:61)
	at org.robotframework.mavenplugin.AcceptanceTestMojo.executeRobot(AcceptanceTestMojo.java:73)
	at org.robotframework.mavenplugin.AcceptanceTestMojo.subclassExecute(AcceptanceTestMojo.java:68)
	at org.robotframework.mavenplugin.AbstractMojoWithLoadedClasspath.execute(AbstractMojoWithLoadedClasspath.java:53)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
Caused by: java.lang.IllegalArgumentException: java.lang.ClassCastException@61625dd6
	at org.robotframework.javalib.reflection.KeywordInvoker.invoke(KeywordInvoker.java:63)
	... 254 more

I would expect a robot error message which says that one has used the wrong argument type.

Thank you and kind regards

Holger

@hleskien
Copy link
Author

I tried to reproduce this for further investigation and got a slightly different error:

java.lang.IllegalArgumentException: argument type mismatch

I don't know why it is different this time but I checked that I tested with Javalib-Core 2.0.3. Anyways, "argument type mismatch" is better than ClassCastException, but still not a robot AttributeError.

java.lang.RuntimeException: 
	at org.robotframework.javalib.reflection.KeywordInvoker.invoke(KeywordInvoker.java:65)
	at org.robotframework.javalib.beans.annotation.AnnotationKeywordExtractor$1.execute(AnnotationKeywordExtractor.java:66)
	at org.robotframework.javalib.library.KeywordFactoryBasedLibrary.runKeyword(KeywordFactoryBasedLibrary.java:40)
	at org.robotframework.javalib.library.AnnotationLibrary.runKeyword(AnnotationLibrary.java:129)
	at robot.libraries.BuiltIn$py.run_keyword$105(C:\Users\hifi\git\robotframework\build\Lib\robot\libraries\BuiltIn.py:1614)
	at robot.libraries.BuiltIn$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\libraries\BuiltIn.py)
	at robot.libraries.BuiltIn$py.run_keyword_and_expect_error$121(C:\Users\hifi\git\robotframework\build\Lib\robot\libraries\BuiltIn.py:1909)
	at robot.libraries.BuiltIn$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\libraries\BuiltIn.py)
	at robot.model.testcase$py.visit$7(C:\Users\hifi\git\robotframework\build\Lib\robot\model\testcase.py:74)
	at robot.model.testcase$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\model\testcase.py)
	at robot.model.itemlist$py.visit$11(C:\Users\hifi\git\robotframework\build\Lib\robot\model\itemlist.py:71)
	at robot.model.itemlist$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\model\itemlist.py)
	at robot.model.visitor$py.visit_suite$2(C:\Users\hifi\git\robotframework\build\Lib\robot\model\visitor.py:88)
	at robot.model.visitor$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\model\visitor.py)
	at robot.model.testsuite$py.visit$19(C:\Users\hifi\git\robotframework\build\Lib\robot\model\testsuite.py:168)
	at robot.model.testsuite$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\model\testsuite.py)
	at robot.model.itemlist$py.visit$11(C:\Users\hifi\git\robotframework\build\Lib\robot\model\itemlist.py:71)
	at robot.model.itemlist$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\model\itemlist.py)
	at robot.model.visitor$py.visit_suite$2(C:\Users\hifi\git\robotframework\build\Lib\robot\model\visitor.py:88)
	at robot.model.visitor$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\model\visitor.py)
	at robot.model.testsuite$py.visit$19(C:\Users\hifi\git\robotframework\build\Lib\robot\model\testsuite.py:168)
	at robot.model.testsuite$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\model\testsuite.py)
	at robot.run$py.main$3(C:\Users\hifi\git\robotframework\build\Lib\robot\run.py:448)
	at robot.run$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\run.py)
	at robot.utils.application$py._execute$10(C:\Users\hifi\git\robotframework\build\Lib\robot\utils\application.py:94)
	at robot.utils.application$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\utils\application.py)
	at robot.utils.application$py.execute_cli$5(C:\Users\hifi\git\robotframework\build\Lib\robot\utils\application.py:49)
	at robot.utils.application$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\utils\application.py)
	at robot.run$py.run_cli$7(C:\Users\hifi\git\robotframework\build\Lib\robot\run.py:488)
	at robot.run$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\run.py)
	at robot.jarrunner$py._run$3(C:\Users\hifi\git\robotframework\build\Lib\robot\jarrunner.py:64)
	at robot.jarrunner$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\jarrunner.py)
	at robot.jarrunner$py.run$2(C:\Users\hifi\git\robotframework\build\Lib\robot\jarrunner.py:57)
	at robot.jarrunner$py.call_function(C:\Users\hifi\git\robotframework\build\Lib\robot\jarrunner.py)
	at org.robotframework.RobotRunner.run(RobotRunner.java:74)
	at org.robotframework.RobotFramework.run(RobotFramework.java:61)
	at org.robotframework.mavenplugin.AcceptanceTestMojo.executeRobot(AcceptanceTestMojo.java:73)
	at org.robotframework.mavenplugin.AcceptanceTestMojo.subclassExecute(AcceptanceTestMojo.java:68)
	at org.robotframework.mavenplugin.AbstractMojoWithLoadedClasspath.execute(AbstractMojoWithLoadedClasspath.java:53)
	at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
	at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
	at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
	at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
	at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
	at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
	at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
	at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
	at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
	at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
Caused by: java.lang.IllegalArgumentException: argument type mismatch
	at org.robotframework.javalib.reflection.KeywordInvoker.invoke(KeywordInvoker.java:63)
	... 255 more

@hleskien
Copy link
Author

*** Settings ***
Library    Collections
Suite Setup    Set Log Level    TRACE

*** Test Cases ***
Attribute Error Demo
    &{dict}=    Create Dictionary    a    1    b    2    c    3
    Append To List    ${dict}    d    4
==============================================================================
Attribute Error Demo                                                  | FAIL |
AttributeError: append
------------------------------------------------------------------------------

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant