Thursday, June 24, 2010

Python Birim Testleri

Birim testleri icin unittest modulu kullanilabilir. Ornek kod:
import unittest

class TestBizimClass(unittest.TestCase):

def test_metot1(self):
...
self.assertFalse ( .. )

def test_metot2(self):
...
self.assertFalse ( .. )

if __name__ == '__main__':
unittest.main()
Bu script isletilince unittest.main() cagrisi her iki test metotunu otomatik olarak cagirip, sonuclari toplar, ve Java dunyasinda JUnit, TestNG'ye benzeyen sonuclari ekranda gosterir.

No comments: