log every python function in a class to use robot framework log output format

1,720 views
Skip to first unread message

adaronen

unread,
Dec 3, 2015, 7:31:38 AM12/3/15
to robotframework-users
Hey all,

I'm using robot framework for a year now, and I'm looking for a way to make all my python functions open a new hierarchy in the output log. for example I have this code:
from robot.api import logger
def log_hello(self):
    logger
.console('hello')
def call_log_hello(self):
   
self.log_hello()
I want that by calling the call_log_hello function from my robot script and that the log_hello function will be treated as a robot keyword and the output.log will have it's own
hierarchy for the function scope
Thanks, Ronen

nnc

unread,
Dec 3, 2015, 12:56:43 PM12/3/15
to robotframework-users
use Builtin

Tatu Aalto

unread,
Dec 4, 2015, 1:45:56 AM12/4/15
to ro...@adallom.com, robotframework-users

Ugh

Have you looked at User Guide, Using builtin library [1] chapter? Also reading the extending test libraries [2] chapter is useful reading.

But I am just wondering, why you would like to call function and want the function to be treated as keyword from Robot Framework point of view? Usually, I want the exactly opposite, because I want to control the output and make log easier to read.

-Tatu
Send from my mobile
[1] http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#using-builtin-library
[2] http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#extending-existing-test-libraries

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.

Kevin O.

unread,
Dec 4, 2015, 10:13:57 AM12/4/15
to robotframework-users
from robot.libraries.BuiltIn import BuiltIn

BuiltIn().run_keyword('Log Hello')

adaronen

unread,
Dec 9, 2015, 2:13:33 AM12/9/15
to robotframework-users, ro...@adallom.com
I want all my python functions to appear in the output log, as I understand it, the python function must be a keyword in order to be able to register to the log


On Friday, December 4, 2015 at 8:45:56 AM UTC+2, Tatu Aalto wrote:

Ugh

Have you looked at User Guide, Using builtin library [1] chapter? Also reading the extending test libraries [2] chapter is useful reading.

But I am just wondering, why you would like to call function and want the function to be treated as keyword from Robot Framework point of view? Usually, I want the exactly opposite, because I want to control the output and make log easier to read.

-Tatu
Send from my mobile
[1] http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#using-builtin-library
[2] http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#extending-existing-test-libraries

On 3 Dec 2015 2:31 p.m., "adaronen" <ro...@adallom.com> wrote:
Hey all,

I'm using robot framework for a year now, and I'm looking for a way to make all my python functions open a new hierarchy in the output log. for example I have this code:
from robot.api import logger
def log_hello(self):
    logger
.console('hello')
def call_log_hello(self):
   
self.log_hello()
I want that by calling the call_log_hello function from my robot script and that the log_hello function will be treated as a robot keyword and the output.log will have it's own
hierarchy for the function scope
Thanks, Ronen

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.

adaronen

unread,
Dec 9, 2015, 2:16:14 AM12/9/15
to robotframework-users
this won't work... in the case I'm importing a function from another module I won't be able to call it with Builtin

Tatu Aalto

unread,
Dec 9, 2015, 8:57:28 AM12/9/15
to ronen adallom, robotframework-users

Ugh

Could you explain what is your requirement/need better? Perhaps there are other ways to fulfill your requirement than the way you are currently expressing.

But BuiltIn is the way to go, but as usual there is a catch. Not all functions are keywords in Robot Framework. Also if outer function calls an inner function, it is not possible (as far I know) to execute that inner function as a keyword (if that function is not a keyword already). Reading the chapter 4 [1] from user guide is will explain lot of useful points in this matter.

-Tatu
Send from my mobile

[1] http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#creating-test-libraries

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.

Kevin O.

unread,
Dec 9, 2015, 11:30:10 AM12/9/15
to robotframework-users
One of the purposes of test libraries is to abstract away the complexity of keyword implementations. But you are trying to expose it.
If your library is complex, then I suggest adding some unit tests.

Kevin

Tatu Aalto

unread,
Dec 14, 2015, 1:33:00 AM12/14/15
to Ronen Hoffer, robotframework-users

Ugh

I can understand that it could be a problem, but usually one wants to hide the complex logic. I also have similar structure in place and usually it's enough to perform good logging in required places. What good means is usually very difficult problem to solve. Because there should not be too much of the logging, if all goes well but there should be enough logging to indicate where the failure was and how to solve it.

But what you want, can be done, to some extend, with the BuiltIn library and run* keywords. But I would not take that road, because in my mind it would lead to poor code quality, hard to debug problems and it doesn't solve the problem completely.

-Tatu
Send from my mobile

On 13 Dec 2015 11:47 a.m., "Ronen Hoffer" <ronhof...@microsoft.com> wrote:

I want to allow my team mates to be able to debug their tests flows.

We have a really long integration tests that are based on robot framework keywords for simple logic and python objects and functions for more complex logic.

The testers are used to the robot framework output log and I want to add them the ability to debug the python in the same way.

Reply all
Reply to author
Forward
0 new messages