[ptt-users] setup/run/teardown: context different for each even at
lowes tlevel?
Dominique de Waleffe
dominique.dewaleffe at denali.be
Thu Sep 13 06:11:11 PDT 2007
In our work on running selenium scripts in TM, I came up with the
following issue:
I want to write scenario that does something in my application GUI as
preparation (login, get to the correct page), then do something, which
is the core thing I want to test, and finally logout.
So I have a testclass that is as follows:
class HTMLTest:
def __init__(self):
self.selenium = SeleniumHTMLUnit();
self.selenium.setLoggerLevel(Level.INFO)
# Set a base URL for open() if all your URLs are relative
#self.selenium.setBaseUrl("http://baseUrl");
def setUp(self):
self.selenium.open("http://cullen.internal.denali.be/backoffice/WebObjects/CIBackOffice.woa/wa/DirectAction/default");
self.selenium.assertEquals("CIApplication --TEST-- (backoffice
1.1.5_2)", self.selenium.getTitle());
self.selenium.type("//input[@name='login']", "user");
self.selenium.type("//input[@name='password']", "password");
self.selenium.click("//img[@alt='Login']");
self.selenium.waitForPageToLoad("30000");
self.selenium.assertEquals("AuthorTodoList --TEST-- (backoffice
1.1.5_2)", self.selenium.getTitle());
def test(self):
self.selenium.click("//a[@href=
'/backoffice/WebObjects/CIBackOffice.woa/wa/CIBODA/openDocumentDashboard?currentDocument=84&ci=2337680']");
self.selenium.waitForPageToLoad("30000");
self.selenium.assertEquals("DocumentDashboard --TEST-- (backoffice
1.1.5_2)", self.selenium.getTitle());
self.selenium.click("//a[contains(@onclick,\".0.16.5.57.1.0.0.1.3','PreviewHtml'\")]");
self.selenium.waitForPopUp("PreviewHtml", "30000");
self.selenium.selectWindow("");
self.selenium.click("//a[@href='/backoffice/WebObjects/CIBackOffice.woa/wa/CIBODA/openAuthorTodoList?ci=63215']");
self.selenium.waitForPageToLoad("30000");
self.selenium.assertEquals("AuthorTodoList --TEST-- (backoffice
1.1.5_2)", self.selenium.getTitle());
def tearDown(self):
self.selenium.click("//a[@href='/backoffice/WebObjects/CIBackOffice.woa/wa/DirectAction/logout']");
self.selenium.waitForPageToLoad("30000");
self.selenium.assertEquals("CIApplication --TEST-- (backoffice
1.1.5_2)", self.selenium.getTitle());
Of course this works when the same instance of the class is used to do
all of setup/test/teardown.
This does not appear to be the case when specifying setup/run/teardown
as below. And indeed, that is what one understand from the TM5
specification document Frank mentionned yesterday.
<usecases>
<usecase name="Document preview">
<sequence name="Document preview" proportion="100">
<test>
<setup module="docpreview" name="test" testclass="HTMLTest"
method="setUp" langtype="jython"/>
<run module="docpreview"
name="Doc preview"
testclass="HTMLTest" method="test" langtype="jython"/>
<teardown module="docpreview" name="test"
testclass="HTMLTest"
method="tearDown" langtype="jython"/>
</test>
</sequence>
</usecase>
</usecases>
If I "test" my script with:
t=HTMLTest()
t.setUp()
for i in [1,2,3]:
print "Running test %d"%(i)
t.test()
t.tearDown()
it works as I expect, of course.
I think the same issue would come up if one would want to manually write
a script with the same structure, login/create a session context as
setup, run some practical actions in this context, and finally logout.
Is there a way to do this at the moment that would allow me to exclude
from the measurement all the setup/teardown time?
Could we imagine that if all of the attributes of <setup><run><teardown>
are the same except for method, only one instance of the test class is
created per thread?
Ideas? Suggestions?
D.
--
Dominique de Waleffe
Technical director
Denali S.A., "Bridging the gap between Business and IT"
Rue de Clairvaux 8, B-1348 Louvain-la-Neuve, Belgium
Office: +32 10 43 99 51 Fax: +32 10 43 99 52
http://www.denali.be
Legal notice: this message and its attachments may contain
confidential and/or privileged information. If you are not the
addressee or authorized to receive this for the addressee, you must
not use, copy, disclose or take any action based on this message or
any information herein. If you have received this message by mistake,
please advise the sender immediately by return e-mail and delete this
message from your system. Thank you for your cooperation.
More information about the Users
mailing list