Python Unit Test Automation



Download 1,71 Mb.
Pdf ko'rish
bet36/73
Sana31.12.2021
Hajmi1,71 Mb.
#213720
1   ...   32   33   34   35   36   37   38   39   ...   73
Bog'liq
2 5188215245394412341

Listing 3-17.  test_module11.py
import unittest
class TestClass12(unittest.TestCase):
        def test_case01(self):
                """This is a test method..."""
                print(self.id())
                self.fail()
The output of Listing 
3-16
 is as follows:
test_case01 (test_module11.TestClass12)
This is a test method... ... 
test_module11.TestClass12.test_case01
FAIL
======================================================================
FAIL: test_case01 (test_module11.TestClass12)
This is a test method...
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/pi/book/code/chapter03/test/test_module11.py", line 9, in 
test_case01
    self.fail()
AssertionError: None
----------------------------------------------------------------------
Ran 1 test in 0.004s
FAILED (failures=1)
Skipping tests
unittest provides a mechanism for skipping tests, conditionally or unconditionally. 
It uses the following decorators for implementing the skipping mechanism:
•  unittest.skip(reason): Unconditionally skips the decorated 
test. reason should describe why the test is being skipped.
•  unittest.skipIf(condition, reason): Skips the decorated test 
if condition is true.


Chapter 3 

 Unittest
58
•  unittest.skipUnless(condition, reason): Skips the decorated 
test unless condition is true.
•  unittest.expectedFailure(): Marks the test as an expected 
failure. If the test fails when it runs, the test is not counted as a 
failure.
The code in Listing 
3-18
 demonstrates how to skip tests conditionally and 
unconditionally.

Download 1,71 Mb.

Do'stlaringiz bilan baham:
1   ...   32   33   34   35   36   37   38   39   ...   73




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish