There is a customized RF library written in Python:
class ALibrary:
def __init__(self, name):
self._name = name
def get_name(self):
print "*WARN*" + self._name
Import this library within settings
*** Settings ***
Library lib/ALibrary.py LaoWang
by default, it creates new instances of test libraries for every test case.
My understanding is that __init__(self, name) gets invoked at the beginning of every test case, for example:
*** Test Cases ***
Test Case 1
get name
Test Case 2
get name
Robotframework should create one instance for Test Case 1 and another instance for Test Case 2, however, my __init__(self, name) required an argument, how do I pass this argument within the *** Test Cases ***?
Did a test:
$ python -m robot test.1.robot
==============================================================================
Test.1
==============================================================================
[ WARN ] LaoWang
Case 1 | PASS |
------------------------------------------------------------------------------
[ WARN ] LaoWang
Case 2 | PASS |
------------------------------------------------------------------------------
Test.1 | PASS |
2 critical tests, 2 passed, 0 failed
2 tests total, 2 passed, 0 failed
Both cases shown LaoWang, does that mean RF didn't create new instance in different test cases?