Analysis of python automated test instances and python automated instances

Source: Internet
Author: User

Analysis of python automated test instances and python automated instances

This article describes the python automated testing process and shares it with you for your reference.

The Code is as follows:

import unittest  ######################################################################## class RomanNumeralConverter(object):   """converter the Roman Number"""    #----------------------------------------------------------------------   def __init__(self, roman_numeral):     """Constructor"""     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    ######################################################################## class RomanNumeralConverterTest(unittest.TestCase):   """test class"""   def test_parsing_millenia(self):     value = RomanNumeralConverter("M")     self.assertEquals(1000, value.convert_to_decimal())    if __name__ == "__main__":   unittest.main()    

The program running effect is as follows:

.----------------------------------------------------------------------Ran 1 test in 0.000sOK 

Note the following three points:

1. import unittest
2. The test class must inherit unittest. Testcase.
3. Call unittest. main () in main ()

Note that the test class also starts with test.

I hope this article will help you with Python programming.


I am a beginner in Python and want to develop an automated mobile phone test script. I want to know a few questions.

1. Can Python be automatically tested on mobile phones? Yes.
2. Which tutorial will be better if you want to learn? First, learn automated testing, then learn python, and then learn it with instances. For more information, see wenku.baidu.com/...1.html.
3. What are the main modules to be learned?
In the world of Python, there is an open-source framework Splinter that can simulate the behavior of browsers very well (in a sense, it can also be said that it is a human access click behavior ). Splinter provides a variety of APIs to obtain page information to determine the results of the current behavior

4. if you understand this line, I will add additional points .. Multiple
Learn more about all aspects of testing. python is just a tool. The theoretical knowledge of testing is very important.

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.

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.