Python Unit Test Automation



Download 1,71 Mb.
Pdf ko'rish
bet23/73
Sana31.12.2021
Hajmi1,71 Mb.
#213720
1   ...   19   20   21   22   23   24   25   26   ...   73
Bog'liq
2 5188215245394412341

Listing 3-4.  test_module04.py
import unittest
import inspect
class TestClass04(unittest.TestCase):
        def test_case01(self):
                print("\nClassname : " + self.__class__.__name__)
                print("Running Test Method : " + inspect.stack()[0][3])
class TestClass05(unittest.TestCase):
        def test_case01(self):
                print("\nClassname : " + self.__class__.__name__)
                print("Running Test Method : " + inspect.stack()[0][3])
if __name__ == '__main__':
        unittest.main(verbosity=2)
The following is the output after running the code in Listing 
3-4
:
test_case01 (__main__.TestClass04) ...
Classname : TestClass04
Running Test Method : test_case01
ok
test_case01 (__main__.TestClass05) ...
Classname : TestClass05
Running Test Method : test_case01
ok
----------------------------------------------------------------------
Ran 2 tests in 0.080s
OK
All the test classes are executed one by one in alphabetical order.
Test Fixtures
To put it simply, test fixtures are the set of steps performed before and after the tests. 
In unittest, these are implemented as methods of the TestCase class and can be 
overridden for your purposes. An example of custom test fixtures in unittest is shown in 
Listing 
3-5
,


Chapter 3 

 Unittest
38

Download 1,71 Mb.

Do'stlaringiz bilan baham:
1   ...   19   20   21   22   23   24   25   26   ...   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