creating test suites

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rdps
    New Member
    • Nov 2006
    • 13

    creating test suites

    I am a newbie and that says it all about posting a basic doubt. I still hope someone helps me out .

    I am unit testing some modules. My test module is in diff file than the modules
    to be tested. My code is something like this :

    <PRE>

    class xyz(unittest.Te stCase):

    def testAbc():
    .....
    def testPqr():
    .....
    def testKlm():
    .....

    def makeTestSuite() :

    suite = unittest.TestSu ite()
    suite.addTest(x yz("testAbc"))
    suite.addTest(x yz("testPqr"))
    return suite

    if __name__ == "__main__":
    unittest.main()

    </PRE>
    But, though i am adding only tow test cases in the test suite, all the 3 test cases are running. I cannot figure out the reson. Could someone please help me?

    Regards,
    rdps
  • bartonc
    Recognized Expert Expert
    • Sep 2006
    • 6478

    #2
    Originally posted by rdps
    I am a newbie and that says it all about posting a basic doubt. I still hope someone helps me out .

    I am unit testing some modules. My test module is in diff file than the modules
    to be tested. My code is something like this :

    <PRE>

    class xyz(unittest.Te stCase):

    def testAbc():
    .....
    def testPqr():
    .....
    def testKlm():
    .....

    def makeTestSuite() :

    suite = unittest.TestSu ite()
    suite.addTest(x yz("testAbc"))
    suite.addTest(x yz("testPqr"))
    return suite

    if __name__ == "__main__":
    unittest.main()

    </PRE>
    But, though i am adding only tow test cases in the test suite, all the 3 test cases are running. I cannot figure out the reson. Could someone please help me?

    Regards,
    rdps
    Great question! I'll do some research and get back to you. In the meanwhile, please read the posting guidelines located in the panel on the right as you post or the sticky (first post) on this forum to learn how to use code tags around code in your post. It helps us help you. Thanks,
    Barton (PFM)

    Comment

    • fuffens
      New Member
      • Oct 2006
      • 38

      #3
      Try to use
      Code:
      unittest.TextTestRunner(verbosity=2).run(suite)
      instead of
      Code:
      unittest.main()
      to see if it makes any difference.

      BR
      /Fredrik

      Comment

      • rdps
        New Member
        • Nov 2006
        • 13

        #4
        Thanks for the replies...but the solution doesnt seem to work for me. All the test cases run, evn though i want to run only 2 of the three test cases.

        Currently i am using Eclipse IDE for running the tests but in future i plan to run the test suites through command line. Any pointers regarding how to run the test suite from command line?

        Comment

        Working...