I have a Python Class which i reference in one suite and is defined in a file. It is instantiated over the Library keyword:
*** Settings ***
Library MyTab.py testfile01.txt Test Procedure WITH NAME ResultFile
MyTab.py:
class MyTab():
def __init__(self, file, Title):
self.tabfile = open(file, 'w')
...
def write_header(self, UEBER: string):
....
self.tabfile.write(...)
def add_zeile(self, zeile: string):
....
self.tabfile.write(...)
In the Robot file i reference this file
Test01
ResultFile.write header Pos., Test , Designation, Serial Number, Text
ResultFile.add zeile aaa,bbb,ccc,ddd
...
ResultFile.add zeile eee,ddd,hhh,ddd
All is working very well
Test01
ResultFile.write header Pos., Test , Designation, Serial Number, Text
ResultFile.add zeile aaa,bbb,ccc,ddd
ResultFile.add zeile eee,ddd,hhh,ddd
ResultFile.add zeile YYY,YYY,YYY,YYY
ResultFile.add zeile ZZZ,ZZZ,ZZZ,ZZZ
Now i have a file (written threw my python class) with the content
aaa,bbb,ccc,ddd
eee,ddd,hhh,ddd
YYY,YYY,YYY,YYY
ZZZ,ZZZ,ZZZ,ZZZ
But with several Test Cases, every time i have a new test case, the class is presumabley instantiated new and i get only the content from the last call of the last test suites:
Test01
ResultFile.write header Pos., Test , Designation, Serial Number, Text
ResultFile.add zeile aaa,bbb,ccc,ddd
...
ResultFile.add zeile eee,ddd,hhh,ddd
Test02
ResultFile.add zeile YYY,YYY,YYY,YYY
...
ResultFile.add zeile ZZZ,ZZZ,ZZZ,ZZZ
The content is the content from the last Test Suite:
YYY,YYY,YYY,YYY
ZZZ,ZZZ,ZZZ,ZZZ
All is working wonderful in one single Test Case.
When i have several TestCases, the Python class is instantiated every time i have a new Test Case. I think i could declare the Library Global or for the Suite, but haven't had any success in doing so, maybe i declare i in the wrong part.
What do i have to do to get the Library (or Variables) stable/consistent over a whole suite with different Test Cases?