Re: Abridged summary of robotframework-users@googlegroups.com - 1 update in 1 topic

29 views
Skip to first unread message

Blaine Meyer

unread,
Nov 10, 2022, 6:57:20 PM11/10/22
to robotframe...@googlegroups.com
I will assume you want for call a Python class method so this worked for me....

Python class definition I used...


class MyLibrary:

    def __init__(self):
        pass

    def my_method(self):
        print("my_method was called...")
        return "hello"

       
Robot code...

*** Settings ***

Library    c:/gitprojects/lev3automation/scripts/MyLibrary.py

Test Setup      my method

*** Test Cases ***

Test Method Call

    [Tags]  methodcall

    Log To Console  Test method call....

   
You can see in the Robot log that the Python method was call during Test Setup...
 
image.png

Blaine Meyer

unread,
Nov 10, 2022, 6:57:20 PM11/10/22
to robotframe...@googlegroups.com
I will assume you want to call a Python method so this worked for me.....

Python class...


On Wed, Nov 9, 2022 at 5:34 PM <robotframe...@googlegroups.com> wrote:
Aparna Joshi <aparna....@gmail.com>: Nov 09 09:28AM -0800

Hi,
I'm using Robot 3.2, want to set a method in test library as Test setup
/teardown.
 
I do not want to create a KW and call the test library method in resource
file and add that as teardown ...more
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to robotframework-u...@googlegroups.com.

Aparna Joshi

unread,
Nov 14, 2022, 5:50:46 AM11/14/22
to robotframework-users
Thank you for the response.

However, I do not want to import the python library in Keyword/robot file.

Let me explain with an example:

class Myclass:
       def my_teardown_method(self):
               BuiltIn().run_keyword(method1)
               BuiltIn().run_keyword(method2)


----------------------------------------------------------------
testcase
*** Settings ***

Library    c:/gitprojects/lev3automation/scripts/Myclass.py

Test TearDown    
my_teardown_method


*** Test Cases ***

Test Method Call

    [Tags]  methodcall

    Log To Console  Test method call....


-----------------------------------------------

When I do as above, in case if these is any error while executing method1, I'm doing raise Assert. and is not executing method2. which is correct.
However, I want to set the teardown property to this method. So that even if method1 fails, it will continue to execute method2.

I have also tried using continue on failure, But this does not solve my purpose, As I want to see in the log, if any failure occured during teardown has be marked as RED/failed. and next method should execute.

Thank you,
Aparna
Reply all
Reply to author
Forward
0 new messages