* Updated monotesting.py with more helper functions

* Updated test cases
* Added content to README


svn path=/trunk/qa/; revision=130264
This commit is contained in:
Rusty Howell 2009-03-26 01:19:26 +00:00
Родитель 5f2ab464d7
Коммит 84fee5bbeb
26 изменённых файлов: 144 добавлений и 46 удалений

Просмотреть файл

@ -4,8 +4,8 @@
$ cat creds.py
username=youruser
password=yourpassword
username='youruser'
password='yourpassword'
$ cat defaults.py
@ -20,6 +20,9 @@ xsp1_port = 8081
xsp2_port = 8082
graffiti_port = 8083
logfile = None
debug = False
####################################################################
Setting up the selenium server:
@ -47,3 +50,13 @@ $ ln -s /home/users/linux/selenium-core /usr/share/mono/lib/xsp/tests/selenium-s
This url should resolve properly:
http://<testserver>.mono.lab.novell.com:8080/selenium-server/core/Blank.html
##################################################################
DESIGN PATTERNS
This might be the easiest way to code the pass/fail updating for Testopia
tearDown(self):
self.selenium.stop()
updateTestCase(self.testcaseid,len(self.verificationErrors) == 0) #This method call
self.assertEqual([], self.verificationErrors)

Просмотреть файл

@ -43,19 +43,22 @@ value_args = {'base_url=':'URL of the webserver being tested',
'rc_port=':'Port number that the RC server is using',
'rc_browser=':'Browser that RC server should use',
'showvalues':'Prints the current values',
'help':'Prints this help message'}
'help':'Prints this help message',
'debug':'Prints debug messages (implies --showvalues)',
'logfile=':'Write debug output to this file'}
#----------------------------------------------------------------------
def loadargs():
global base_url,testrunid,xsp1_port,xsp2_port
global rc_server,rc_port,rc_browser
global graffiti_port
global graffiti_port, debug, logfile
longargs = value_args.keys()
shortargs = ''
showvalues = False
opts,args = getopt.getopt(sys.argv[1:],shortargs,longargs)
#print opts
#print opts
#print args
for o,a in opts:
@ -77,16 +80,24 @@ def loadargs():
elif o == '--rc_browser':
rc_browser = a
elif o == '--showvalues':
printValues()
showvalues = True
elif o == '--debug':
debug = True
elif o == '--logfile':
print 'WARNING: --logfile is not yet implemented'
logfile = None
elif o == '--help':
usage()
sys.exit(0)
if showvalues or debug:
printValues()
#----------------------------------------------------------------------
def printValues():
print "Current values:"
print "base_url = %s" % base_url
print "testrunid = %d" % testrunid
print "testrunid = %s" % str(testrunid)
print "\nxsp1_port = %d" % xsp1_port
print "xsp2_port = %d" % xsp2_port
@ -96,6 +107,9 @@ def printValues():
print "rc_port = %d" % rc_port
print "rc_browser = %s\n" % rc_browser
print "debug = %s" % debug
print "logfile = %s\n" % logfile
#----------------------------------------------------------------------
def usage():
print "\nUsage: %s [OPTIONS]\n" % sys.argv[0]
@ -105,6 +119,15 @@ def usage():
print ('--'+ k).ljust(25),v.ljust(50)
print ''
#----------------------------------------------------------------------
def log(msg):
if debug:
print msg
if logfile != None:
# TODO: write message to logfile
pass
#####################################################################
#
# Testopia helper functions
@ -132,12 +155,22 @@ def getTestopia():
#----------------------------------------------------------------------
def getTestRun():
global testrun
log("Getting test run")
if testrunid == None or testrunid == 0:
log("Error: getTestRun(): testrunid == None")
testrun = None
elif testrun == None:
testrun = getTestopia().testrun_get(testrunid)
return testrun
#----------------------------------------------------------------------
def updateTestCase(testcaseid,success):
'''success is a bool'''
if success:
__updateTestCase(testcaseid,"PASSED")
else:
__updateTestCase(testcaseid,"FAILED")
#----------------------------------------------------------------------
def passTestCase(testcaseid):
__updateTestCase(testcaseid,"PASSED")
@ -150,11 +183,14 @@ def failTestCase(testcaseid):
def __updateTestCase(testcaseid,status):
if testcaseid == None:
log("Error: __updateTestCase(): testcaseid == None")
return
if getTestRun() == None:
log("Error: __updateTestCase(): getTestRun() == None")
return
#print "Setting status to %s" % status
log(" Setting testcase #%d status to %s" % (testcaseid,status))
tr = getTestRun()
getTestopia().testcaserun_update_alt(

Просмотреть файл

@ -8,12 +8,12 @@ from monotesting import *
# sub directories
# Add child test suites to test suite
from webservice.alltests import *
#from auth.alltests import *
from auth.alltests import *
from databinding.alltests import *
from handlers.alltests import *
from customcontrols.alltests import *
#from htmlcontrols.alltests import *
#from webcontrols.alltests import *
from htmlcontrols.alltests import *
from webcontrols.alltests import *
from asp_net_framework import *

Просмотреть файл

@ -7,4 +7,4 @@ from serialTest import *
if __name__ == '__main__':
unittest.main()
monotesting_main()

Просмотреть файл

@ -30,4 +30,4 @@ class registerTest(unittest.TestCase):
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
unittest.main()
monotesting_main()

Просмотреть файл

@ -36,4 +36,4 @@ class serialTest(unittest.TestCase):
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
unittest.main()
monotesting_main()

Просмотреть файл

@ -26,4 +26,4 @@ class transferTest(unittest.TestCase):
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
unittest.main()
monotesting_main()

Просмотреть файл

@ -35,6 +35,7 @@ class loginTest(unittest.TestCase):
def tearDown(self):
self.selenium.stop()
updateTestCase(self.testcaseid,len(self.verificationErrors) == 0)
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":

Просмотреть файл

@ -4,5 +4,8 @@ import unittest
from tabcontrolTest import *
from tabcontrol2Test import *
sys.path.append('../..')
from monotesting import *
if __name__ == '__main__':
unittest.main()
monotesting_main()

Просмотреть файл

@ -9,6 +9,7 @@ import unittest, time, re
class tabcontrolTest(unittest.TestCase):
def setUp(self):
self.testcaseid = None
self.verificationErrors = []
self.selenium = selenium(rc_server, rc_port, rc_browser, xsp1_url)
self.selenium.start()
@ -41,7 +42,8 @@ class tabcontrolTest(unittest.TestCase):
def tearDown(self):
self.selenium.stop()
updateTestCase(self.testcaseid,len(self.verificationErrors) == 0)
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
unittest.main()
monotesting_main()

Просмотреть файл

@ -9,6 +9,7 @@ import unittest, time, re
class tabcontrolTest(unittest.TestCase):
def setUp(self):
self.testcaseid = None
self.verificationErrors = []
self.selenium = selenium(rc_server, rc_port, rc_browser, xsp1_url)
self.selenium.start()
@ -31,7 +32,8 @@ class tabcontrolTest(unittest.TestCase):
def tearDown(self):
self.selenium.stop()
updateTestCase(self.testcaseid,len(self.verificationErrors) == 0)
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
unittest.main()
monotesting_main()

Просмотреть файл

@ -6,6 +6,8 @@ from attributeTest import *
from classTest import *
from templateTest import *
sys.path.append('../..')
from monotesting import *
if __name__ == '__main__':
unittest.main()
monotesting_main()

Просмотреть файл

@ -9,6 +9,7 @@ import unittest, time, re
class arrayTest(unittest.TestCase):
def setUp(self):
self.testcaseid = None
self.verificationErrors = []
self.selenium = selenium(rc_server, rc_port, rc_browser, xsp1_url)
self.selenium.start()
@ -33,7 +34,8 @@ class arrayTest(unittest.TestCase):
def tearDown(self):
self.selenium.stop()
updateTestCase(self.testcaseid,len(self.verificationErrors) == 0)
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
unittest.main()
monotesting_main()

Просмотреть файл

@ -9,6 +9,7 @@ import unittest, time, re
class attributeTest(unittest.TestCase):
def setUp(self):
self.testcaseid = None
self.verificationErrors = []
self.selenium = selenium(rc_server, rc_port, rc_browser, xsp1_url)
self.selenium.start()
@ -33,7 +34,8 @@ class attributeTest(unittest.TestCase):
def tearDown(self):
self.selenium.stop()
updateTestCase(self.testcaseid,len(self.verificationErrors) == 0)
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
unittest.main()
monotesting_main()

Просмотреть файл

@ -9,6 +9,7 @@ import unittest, time, re
class classTest(unittest.TestCase):
def setUp(self):
self.testcaseid = None
self.verificationErrors = []
self.selenium = selenium(rc_server, rc_port, rc_browser, xsp1_url)
self.selenium.start()
@ -29,7 +30,8 @@ class classTest(unittest.TestCase):
def tearDown(self):
self.selenium.stop()
updateTestCase(self.testcaseid,len(self.verificationErrors) == 0)
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
unittest.main()
monotesting_main()

Просмотреть файл

@ -9,6 +9,7 @@ import unittest, time, re
class templateTest(unittest.TestCase):
def setUp(self):
self.testcaseid = None
self.verificationErrors = []
self.selenium = selenium(rc_server, rc_port, rc_browser, xsp1_url)
self.selenium.start()
@ -25,7 +26,8 @@ class templateTest(unittest.TestCase):
def tearDown(self):
self.selenium.stop()
updateTestCase(self.testcaseid,len(self.verificationErrors) == 0)
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
unittest.main()
monotesting_main()

Просмотреть файл

@ -8,6 +8,8 @@ from emptyTest import *
from webhandlerTest import *
sys.path.append('../..')
from monotesting import *
if __name__ == '__main__':
unittest.main()
monotesting_main()

Просмотреть файл

@ -9,6 +9,7 @@ import unittest, time, re
class asyncTest(unittest.TestCase):
def setUp(self):
self.testcaseid = None
self.verificationErrors = []
self.selenium = selenium(rc_server, rc_port, rc_browser, xsp1_url)
self.selenium.start()
@ -18,12 +19,16 @@ class asyncTest(unittest.TestCase):
sel.open("/")
sel.click("link=async.ashx")
sel.wait_for_page_to_load("30000")
try: self.failUnless(sel.is_text_present("End request being invoked."))
except AssertionError, e: self.verificationErrors.append(str(e))
try:
self.failUnless(sel.is_text_present("End request being invoked."))
passTestCase(self.testcaseid)
except AssertionError, e:
failTestCase(self.testcaseid)
self.verificationErrors.append(str(e))
def tearDown(self):
self.selenium.stop()
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
unittest.main()
monotesting_main()

Просмотреть файл

@ -9,6 +9,7 @@ import unittest, time, re
class chunkedTest(unittest.TestCase):
def setUp(self):
self.testcaseid = None
self.verificationErrors = []
self.selenium = selenium(rc_server, rc_port, rc_browser, xsp1_url)
self.selenium.start()
@ -18,14 +19,23 @@ class chunkedTest(unittest.TestCase):
sel.open("/")
sel.click("link=chunked.ashx")
sel.wait_for_page_to_load("30000")
try: self.failUnless(sel.is_text_present("ggggggggggggggggg"))
except AssertionError, e: self.verificationErrors.append(str(e))
try: self.failUnless(re.search(r"^[\s\S]*iiiiiiiiiiiii[\s\S]*$", sel.get_text("//html/body")))
except AssertionError, e: self.verificationErrors.append(str(e))
try:
self.failUnless(sel.is_text_present("ggggggggggggggggg"))
passTestCase(self.testcaseid)
except AssertionError, e:
self.verificationErrors.append(str(e))
failTestCase(self.testcaseid)
try:
self.failUnless(re.search(r"^[\s\S]*iiiiiiiiiiiii[\s\S]*$", sel.get_text("//html/body")))
passTestCase(self.testcaseid)
except AssertionError, e:
self.verificationErrors.append(str(e))
failTestCase(self.testcaseid)
def tearDown(self):
self.selenium.stop()
self.assertEqual([], self.verificationErrors)
#self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
unittest.main()
monotesting_main()

Просмотреть файл

@ -9,6 +9,7 @@ import unittest, time, re
class emptyTest(unittest.TestCase):
def setUp(self):
self.testcaseid = None
self.verificationErrors = []
self.selenium = selenium(rc_server, rc_port, rc_browser, xsp1_url)
self.selenium.start()
@ -17,12 +18,16 @@ class emptyTest(unittest.TestCase):
sel = self.selenium
sel.open("/")
sel.click("link=empty.ashx")
try: self.failUnless(sel.is_text_present(""))
except AssertionError, e: self.verificationErrors.append(str(e))
try:
self.failUnless(sel.is_text_present(""))
passTestCase(self.testcaseid)
except AssertionError, e:
self.verificationErrors.append(str(e))
failTestCase(self.testcaseid)
def tearDown(self):
self.selenium.stop()
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
unittest.main()
monotesting_main()

Просмотреть файл

@ -9,6 +9,7 @@ import unittest, time, re
class monodocTest(unittest.TestCase):
def setUp(self):
self.testcaseid = None
self.verificationErrors = []
self.selenium = selenium(rc_server, rc_port, rc_browser, xsp1_url)
self.selenium.start()
@ -23,12 +24,16 @@ class monodocTest(unittest.TestCase):
sel.select_window("name=content")
sel.click("link=System.Collections")
sel.wait_for_page_to_load("30000")
try: self.failUnless(sel.is_text_present("System"))
except AssertionError, e: self.verificationErrors.append(str(e))
try:
self.failUnless(sel.is_text_present("System"))
passTestCase(self.testcaseid)
except AssertionError, e:
self.verificationErrors.append(str(e))
failTestCase(self.testcaseid)
def tearDown(self):
self.selenium.stop()
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
unittest.main()
monotesting_main()

Просмотреть файл

@ -9,6 +9,7 @@ import unittest, time, re
class webhandlerTest(unittest.TestCase):
def setUp(self):
self.testcaseid = None
self.verificationErrors = []
self.selenium = selenium(rc_server, rc_port, rc_browser, xsp1_url)
self.selenium.start()
@ -18,12 +19,16 @@ class webhandlerTest(unittest.TestCase):
sel.open("/")
sel.click("link=webhandler.ashx")
sel.wait_for_page_to_load("30000")
try: self.assertEqual("Hi there!", sel.get_text("//html/body/h1"))
except AssertionError, e: self.verificationErrors.append(str(e))
try:
self.assertEqual("Hi there!", sel.get_text("//html/body/h1"))
passTestCase(self.testcaseid)
except AssertionError, e:
self.verificationErrors.append(str(e))
failTestCase(self.testcaseid)
def tearDown(self):
self.selenium.stop()
self.assertEqual([], self.verificationErrors)
if __name__ == "__main__":
unittest.main()
monotesting_main()

Просмотреть файл

@ -3,4 +3,4 @@ import unittest
if __name__ == '__main__':
unittest.main()
monotesting_main()

Просмотреть файл

@ -2,4 +2,4 @@
import unittest
if __name__ == '__main__':
unittest.main()
monotesting_main()

Просмотреть файл

@ -43,4 +43,4 @@ class addTest(unittest.TestCase):
if __name__ == "__main__":
monotesting_main()
#unittest.main()
#monotesting_main()

Просмотреть файл

@ -7,6 +7,5 @@ from echoTest import *
sys.path.append('../..')
from monotesting import *
if __name__ == '__main__':
monotesting_main()