Python Unit Test Automation



Download 1,71 Mb.
Pdf ko'rish
bet52/73
Sana31.12.2021
Hajmi1,71 Mb.
#213720
1   ...   48   49   50   51   52   53   54   55   ...   73
Bog'liq
2 5188215245394412341

Listing 4-10.  test_module10.py
from nose.tools import timed
import time
@timed(.1)
def test_case01():
    time.sleep(.2)
This test fails, as it takes more time to finish the execution of the test than is allotted 
in the @timed() decorator. The output of execution is as follows:
In setUpPackage()...
test.test_module08.test_case01 ... FAIL
In tearDownPackage()...


Chapter 4 

 nose and nose2
80
======================================================================
FAIL: test.test_module08.test_case01
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/nose/case.py", line 198, in 
runTest
    self.test(*self.arg)
  File "/usr/local/lib/python3.4/dist-packages/nose/tools/nontrivial.py", 
line 100, in newfunc
    raise TimeExpired("Time limit (%s) exceeded" % limit)
nose.tools.nontrivial.TimeExpired: Time limit (0.1) exceeded
----------------------------------------------------------------------
Ran 1 test in 0.211s
FAILED (failures=1)
It is the collection or group of related tests that can be executed or scheduled to be 
executed together.
Report Generation
Let’s look at the various ways to generate comprehensible reports using nose.
Creating an XML Report
nose has a built-in feature for generating XML reports. These are xUnit-style formatted 
reports. You have to use --with-xunit for generating the report. The report is generated 
in the current working directory.
Run the following command in the test directory:
nosetests test_module01.py -vs --with-xunit
The output will be as follows:
In setUpPackage()...
test.test_module01.test_case01 ... ok
In tearDownPackage()...
----------------------------------------------------------------------
XML: /home/pi/book/code/chapter04/test/nosetests.xml
----------------------------------------------------------------------
Ran 1 test in 0.009s
OK


Chapter 4 

 nose and nose2
81
The generated XML file is shown in Listing 
4-11
.

Download 1,71 Mb.

Do'stlaringiz bilan baham:
1   ...   48   49   50   51   52   53   54   55   ...   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