How to create xml report using xmltestrunner for test suite
How to create xml report using xmltestrunner for test suite.
Please help
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- SikuliX Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Harry
- Solved:
- Last query:
- Last reply:
Revision history for this message
![]() |
#2 |
this is my code.Let me know if i m doing something wrong
From this case blank xml page is getting generated
Please help
*******
import unittest
import xmlrunner
import comres
from launchemulator import *
from phonevalidation import *
from invalidcode import *
from callme import *
class xmlreport(
def open_the_
try:
emuobj = launchemulator()
except:
raise
def phone_number_
try:
phnobj = phonevalidation()
except:
raise
def putting_
try:
invobj = invalidcode()
except:
def getting_
try:
callobj = callme()
except:
raise
def suite():
suite.
suite.
suite.
suite.
return suite
suite = suite()
if __name_
try:
except SystemExit,inst:
if inst.args[0] is True:
raise
timestamp = time.strftime(
rname = 'Test_Report_
my_dir="path"
suite = unittest.
result = xmlrunner.
result.run(suite)
Revision history for this message
![]() |
#3 |
# some code above --- ok
def suite():
suite.
suite.
suite.
suite.
return suite
suite = suite()
timestamp = time.strftime(
rname = 'Test_Report_
my_dir="path"
result = xmlrunner.
Revision history for this message
![]() |
#4 |
I copied the code.
Now the error is getting as "AttributeError ( 'function' object has no attribute 'addTest' )"
Revision history for this message
![]() |
#5 |
uups, overseen.
# code before ok
def createSuite():
suite = unittest.
suite.
suite.
suite.
suite.
return suite
suite = createSuite()
# code after ok
Revision history for this message
![]() |
#6 |
The code ran successfully but blank xml report got generated in the given path.
Like html report, i want to generate xml report for all the suite as in the below image.
http://
I am able to generate html report for the following suites:
suite.
suite.
suite.
suite.
Please help me on this
Revision history for this message
![]() |
#7 |
I have written the following script But blank xml file is getting generated in the specified path.
Please tell me if anything is wrong in the code.
import unittest
from xmlrunner import *
import comres
from launchemulator import *
from phonevalidation import *
from invalidcode import *
from callme import *
class xmlreport(
def open_the_
try:
emuobj = launchemulator()
except:
raise
def phone_number_
try:
phnobj = phonevalidation()
except:
raise
def putting_
try:
invobj = invalidcode()
except:
def getting_
try:
callobj = callme()
except:
raise
def createSuite():
suite = unittest.
suite.
suite.
suite.
suite.
return suite
if __name_
suite = unittest.
timestamp = time.strftime(
rname = 'Test_Report_
my_dir=
suite = createSuite()
result = XMLTestRunner(
result.run(suite)
Revision history for this message
![]() |
#8 |
if __name_
suite = unittest.
do not use this with SikuliX
Revision history for this message
![]() |
#9 |
what version of XMLTestRunner are you using?
(look into the .py file)
Revision history for this message
![]() |
#10 |
this worked for me:
import unittest
import XMLTestRunner
class myTest(
def test1(self):
assert True
suite = unittest.
XMLTestRunner.
# content of testOut.txt
<testsuite errors="0" failures="0" name="unittest.
<testcase classname=
<system-
<system-
</testsuite>
Revision history for this message
![]() |
#11 |
Thanks Raiman , it worked for me as well. I didn't changed any code.
The only concern was the xml report was not viewable on Safari browser. I was able to see the blank page.
Any reason why it's happening.
Revision history for this message
![]() |
#12 |
I put the above XML into a test.xml and when opening with Safari, it shows the content of the file correctly as XML tree.
Revision history for this message
![]() |
#13 |
My by default browser was safari for xml file.But when o tried to open using firefox , it shows the content of the file correctly as XML tree.