This article describes how to run the test case withverbosity from the command line in python automated testing. it is a classic automated testing example, for more information about how to run the test case with verbosity in the Command Line for python automation testing, see the example in this article. 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.