nagappan
|
Logging the statusLogging is required to analyze the result of execution. LDTP provides logging using the Python Logger.
Sample LDTP runner xml test.xml
| Code: | <?xml version='1.0' encoding='utf-8'?>
<ldtp>
<logfile>teststatus.xml</logfile>
<category>
<!-- optional tag starts -->
<name>category1</name>
<!-- optional tag ends -->
<group>
<!-- optional tag starts -->
<name>group1</name>
<!-- optional tag ends -->
<script>
<testcase>testing log</testcase>
<name>test.py</name>
</script>
</group>
</category>
</ldtp> |
LDTP script (FAIL) test.py
| Code: | from ldtp import *
launchapp ('gedit')
click ('*-gedit', 'btnFind')
waittillguiexist ('dlgFind')
click ('dlgFind', 'btnClose')
raise LdtpExecutionError ('Hello')
|
from prompt you can execute like:
$ ldtprunner test.xml
On executing the above command, teststatus.xml will be generated and it looks like the following Output XML/b]
| Code: | <ldtp>
<category name="category1">
<group name="group1">
<script name="test.py">
<test name="testing log">
<ERROR>Traceback (most recent call last):
File "/usr/bin/ldtprunner", line 415, in executescript
execfile (scriptname, scriptglobal)
File "test.py", line 6, in <module>
raise LdtpExecutionError ('Hello')
LdtpExecutionError: 'Hello'
</ERROR>
<CAUSE>'Hello'</CAUSE>
<pass>0</pass>
</test>
</script>
<timeinfo start="15:23:03 PM on 01-Jan-2008" elapsed="0:0:5"></timeinfo>
<groupsstatus total="1" pass="0" fail="1"></groupsstatus>
</group>
</category>
<totaltimeinfo start="15:23:03 PM on 01-Jan-2008" elapsed="0:0:5"></totaltimeinfo>
<categorystatus total="1" pass="0" fail="1"></categorystatus>
</ldtp> |
[b]LDTP script (PASS) test.py
| Code: | from ldtp import *
launchapp ('gedit')
click ('*-gedit', 'btnFind')
waittillguiexist ('dlgFind')
click ('dlgFind', 'btnClose')
|
from prompt you can execute like:
$ ldtprunner test.xml
On executing the above command, teststatus.xml will be generated and it looks like the following [b]Output XML/b]
| Code: | <ldtp>
<category name="category1">
<group name="group1">
<script name="test.py">
<test name="testing log">
<pass>1</pass>
</test>
</script>
<timeinfo start="15:34:48 PM on 01-Jan-2008" elapsed="0:0:5"></timeinfo>
<groupsstatus total="1" pass="1" fail="0"></groupsstatus>
</group>
</category>
<totaltimeinfo start="15:34:48 PM on 01-Jan-2008" elapsed="0:0:5"></totaltimeinfo>
<categorystatus total="1" pass="1" fail="0"></categorystatus>
</ldtp> |
|