Python Unit Test Automation



Download 1,71 Mb.
Pdf ko'rish
bet29/73
Sana31.12.2021
Hajmi1,71 Mb.
#213720
1   ...   25   26   27   28   29   30   31   32   ...   73
Bog'liq
2 5188215245394412341

Figure 3-1.  Snapshot of the test subdirectory in the chapter03 directory


Chapter 3 

 Unittest
47
The following is the output:
test_case01 (test.test_module04.TestClass04) ...
Classname : TestClass04
Running Test Method : test_case01
ok
test_case01 (test.test_module04.TestClass05) ...
Classname : TestClass05
Running Test Method : test_case01
ok
----------------------------------------------------------------------
Ran 2 tests in 0.090s
OK
Run a test class in the test module with the following command:
python3 -m unittest -v test.test_module04.TestClass04
The output is as follows:
test_case01 (test.test_module04.TestClass04) ...
Classname : TestClass04
Running Test Method : test_case01
ok
----------------------------------------------------------------------
Ran 1 test in 0.078s
OK
Run a test case from a test module as follows:
python3 -m unittest -v 
test.test_module04.TestClass04.test_case01
The output is as follows:
test_case01 (test.test_module04.TestClass04) ...
Classname : TestClass04
Running Test Method : test_case01
ok
----------------------------------------------------------------------
Ran 1 test in 0.079s
OK


Chapter 3 

 Unittest
48
Organizing the Code
Let’s look at the ways you can organize the test code and dev. We’re now moving toward 
real-life project scenarios for using unittest. Up until now, the tests (the testing code) 
and the code to be tested (the development code) were in the same module. Usually in 
the real-life projects, the development code and the test code are kept in different files.
Placing the Development and Test Code in a Single Directory
Here, you will organize the dev and test code in a single directory. In the test directory, 
create a module called test_me.py and add the code in Listing 
3-10
 to it.

Download 1,71 Mb.

Do'stlaringiz bilan baham:
1   ...   25   26   27   28   29   30   31   32   ...   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