How to use TestResult Class

B

bala

Hi,
Question in UnitTest Module

Iam having a TestCase.....Iam able to run that test case..If i want to see the Result..I have to use TestResult Class Right..I don't know how to use the class to print the Result

I need Example Code for TestResult class in unittest module..


Here is the Test Case
--------------------------------

import unittest
import ModNumCal




class NumTestCase(unittest.TestCase):
def testaddNumber(self):
self.assertEqual(ModNumCal.addNumber(0,1),1)
def testdivNumber(self):
self.assertEqual(ModNumCal.divNumber(10,2),3,"It is Equal")
def testdivNumber(self):
self.assertEqual(ModNumCal.divNumber(10,2),5,"It is Equal")


testCaseSuite = unittest.TestSuite()
testCaseSuite.addTest(NumTestCase("testaddNumber"))
testCaseSuite.addTest(NumTestCase("testdivNumber"))


runner = unittest.TextTestRunner()
runner.run(testCaseSuite)


ModNumCal.py
-----------------------

def addNumber(a=None,b=None):
c = a + b
return c

def divNumber(d=None,e=None):
f = d/e
return f

def multiplyNumber(g=None,h=None):
i = g * h
return i


After Run this TestCase it prints like this

...
----------------------------------------------------------------------
Ran 2 tests in 0.000s

OK


Note: I want to Print the Result...Kindly Give Some Example

Regards
Bala
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top