Python automated testing-run test cases from the command line with verbosity, pythonverbosity

Source: Internet
Author: User

Python automated testing-run test cases from the command line with verbosity, pythonverbosity

This article describes how to run the test case with verbosity from the command line for python automated testing. The details are as follows:

The instance file recipe3.py is as follows:

class RomanNumeralConverter(object):   def __init__(self, roman_numeral):     self.roman_numeral = roman_numeral     self.digit_map = {"M":1000, "D":500, "C":100, "L":50, "X":10,               "V":5, "I":1}   def convert_to_decimal(self):     val = 0     for char in self.roman_numeral:       val += self.digit_map[char]     return val     import unittest class RomanNumeralConverterTest(unittest.TestCase):        def test_parsing_millenia(self):     value = RomanNumeralConverter("M")     self.assertEquals(1000, value.convert_to_decimal())        def test_parsing_century(self):     '''THIS is a error test case'''     value = RomanNumeralConverter("C")     self.assertEquals(10, value.convert_to_decimal())                if __name__ == "__main__":   suite = unittest.TestLoader().loadTestsFromTestCase(RomanNumeralConverterTest)   unittest.TextTestRunner(verbosity=2).run(suite)

Shows the running result:

This is how the test case fails.

I hope this article will help you with Python programming.


Is it recommended to use python for automated software testing?

Although python contains packages such as testsuite. However, automated testing is not related to programming. It mainly selects suitable test cases and test methods. Related to the business.

The automated testing framework is also easy to set up. You can use python for two weeks. Learning is of little significance.

In addition, there are few domestic automated tests. At the same time, there are fewer python users. I tried to train a few people in this area. It is not easy to master a language. If you master the language well, you will not perform tests.

However, you can take a closer look at the website's automated testing framework. There is a framework for python and ruby. I have tried several python frameworks and I feel that ruby is more powerful.

Teach python Automated Testing

This problem is quite broad. First, we recommend that you use 2.5 for the current version. If you want to learn how to get started by using python script testing, I don't know how to get started. There are many points in automated testing, it includes gui, functions, performance, and other aspects, and different software applications are also applied to different packages, such as automated Web page testing, you can directly use the python script to operate the ie kernel browser for testing. Then we can use the pamie module for testing... for example, for automated gui testing, pil, win32, and other modules may be used for operations...

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.