2

I'm new to RobotFramework and I'm trying to do a simple test. Print an "Hello world" using Log keyword and get a value from a java class (I'm using jybot on Ride):

*** Settings ***
Library           robot.MyTest

*** Test Cases ***
Test1
    Log    Hello World    INFO
    Get Value

*** Keywords ***
Get Value
    Get Value

But when I run it, the test won't pass and it will give me this error:

Starting test: MyTest.Test1
20140817 01:00:15.683 :  INFO : Hello world
20140817 01:00:15.798 :  FAIL : Maximum limit of started keywords exceeded.
Ending test:   MyTest.Test1

I've searched about it but I still have no clue on this.

bsferreira
  • 1,189
  • 5
  • 14
  • 27

2 Answers2

10

Your test calls the keyword Get Value, which calls the keyword Get Value. You've created an infinite recursion. Get Value calls Get Value which calls Get Value which calls Get Value which calls ...

The best solution is the simplest one: don't create a keyword that calls itself. If there is already a keyword with a given name, don't create another one with the same name. While you can make it work having two with the same name, it will make your test cases harder to understand.

If you have another keyword called Get Value and you simply must have two keywords with the same name, you can give the fully qualified name so robot doesn't call the same keyword again. For example, if your Get Value is trying to call the Get Value from robot.myTest, call it like this:

*** Keywords ***
Get Value
    robot.myTest.Get Value
Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
  • If I don't want to create another keyword, you're saying i should only have this: *** Settings *** Library robot.MyTest *** Test Cases *** Test1 Get Value *** Keywords *** – bsferreira Aug 17 '14 at 11:43
  • @Lucas: I'm saying if you're going go create a new keyword, don't give it the same name as an existing keyword. If `robot.myTest` already defines a keyword named `Get Value`, there's no need to also create a keyword in the test case file with the same name. – Bryan Oakley Aug 17 '14 at 12:03
  • Thanks for trying to help. The thing is, I don't want to create another. I just want to use the one on MyTest class, but when I try to use it, ride throws this exception: **FAIL : No keyword with name 'Get Value' found**. That's why I tried to create in Keywords sections. I also get this error: **Importing test library 'robot.MyTest' failed: ImportError: No module named robot** – bsferreira Aug 17 '14 at 13:35
  • 2
    @Lucas: then you have a different problem than the one you asked here. While I successfully answered this question, it sounds like your real problem is that you can't import your library. You should ask about that as a separate question. – Bryan Oakley Aug 17 '14 at 14:21
  • You're right, kudos. I just need to find a way to import a complete jar with all classes.. I'm only able to use keywords if a declare the java class (e.g. Library robot.MyTest \r\n Library robot.MyTest2 \r\n etc). – bsferreira Aug 17 '14 at 20:53
0

The error message could have been better scripted as

"stack overflow due to recursive calling of keyword"

Check and fix the keyword to avoid the recursion.

Sun
  • 1,505
  • 17
  • 25