Mikstura it2013

274 views

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
274
On SlideShare
0
From Embeds
0
Number of Embeds
22
Actions
Shares
0
Downloads
5
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Mikstura it2013

  1. 1. Niepraktycznie i nieskładnieo Test Driven Development Adam Przybyła <adam@ertel.com.pl> (Creative Commons cc-by-nd) Mikstura 2 Lateral Thinking - Rybnik 2013
  2. 2. Cykl życia
  3. 3. [root@synergia TDD_ANTLR]# cat test_mikstura.py#! /usr/bin/pythonimport unittestclass test_moj(unittest.TestCase): def test_test(self): self.assertTrue(False)if __name__ == __main__: unittest.main()[root@synergia TDD_ANTLR]#
  4. 4. [root@synergia TDD_ANTLR]# ./test_mikstura.pyF======================================================================FAIL: test_test (__main__.test_moj)----------------------------------------------------------------------Traceback (most recent call last): File "./test_mikstura.py", line 6, in test_test self.assertTrue(False)AssertionError----------------------------------------------------------------------Ran 1 test in 0.000sFAILED (failures=1)[root@synergia TDD_ANTLR]#
  5. 5. [root@synergia TDD_ANTLR]# cat test_mikstura.py#! /usr/bin/pythonimport unittestclass test_moj(unittest.TestCase): def test_test(self): self.assertTrue(True)if __name__ == __main__: unittest.main()[root@synergia TDD_ANTLR]#
  6. 6. [root@synergia TDD_ANTLR]# ./test_mikstura.py.----------------------------------------------------------------------Ran 1 test in 0.000sOK[root@synergia TDD_ANTLR]#
  7. 7. #!/usr/bin/pythonimport unittestimport antlr3from CSVLexer import CSVLexerfrom CSVParser import CSVParserclass test_csv(unittest.TestCase): def setUp(self): pass def test_test(self): self.assertTrue(True) def test_lf(self): parser=parserek("n") wynik=parser.line() self.assertFalse(wynik) def test_crlf(self): parser=parserek("rn") wynik=parser.line() self.assertFalse(wynik) #@unittest.skip("omijam test") def test_red(self): parser=parserek("red") wynik=parser.pole() self.assertEqual(wynik,"red")
  8. 8. grammar CSV;Options { language=Python; }@header {def test1(s): print "test"}line returns [wynik]scope { wynik2 }@init { wynik =[]; $line::wynik2=[]; }: ( (NEWLINE) => NEWLINE | ( p1=pole {wynik.append(p1) } ( COMMA p1=pole {wynik.append(p1) } )* NEWLINE ) ){ wynik=$line::wynik2};COMMA : ( * , *) ;pole returns [wynik1]@init {wynik1=""try: wyn=$line::wynik2except IndexError: wyn=[]} : ( p=ZNAWIASEM { wynik1 = $p.text;} | p=BEZNAWIASU { wynik1 = $p.text;} | //nic ) {wyn.append(wynik1)};NEWLINE : r? n;ZNAWIASEM : (" ( options {greedy=false;}: . )+ ")+ {txt = self.getText().strip(").replace("",");self.setText(txt)};BEZNAWIASU : ~(r | n | , | | ")+;
  9. 9. #! /usr/bin/python# -*- coding: UTF-8 -*-import unittestfrom analizator import *from pobieracz import *from TDDczysciciel import Lexerimport pobieracz,analizator,warstwa_leksykalna,codecs,TDDczyscicielclass testy_pobierania(unittest.TestCase): def setUp(self): pass def test_dziala(self): self.assertTrue(True) def test_nazwy(self): self.assertTrue(nazwa_ma_ip("dns.ertel.com.pl")) def test_zlej_nazwy(self): self.assertFalse(nazwa_ma_ip("dns-45.ertel.com.pl")) def test_pinga_dziala(self): self.assertTrue(nazwa_odp_na_ping(127.0.0.1)) def test_pinga_niedziala(self): self.assertFalse(nazwa_odp_na_ping(224.0.0.0))
  10. 10. Lateral Thinking● Wikinomia● Wikipedia● Wolna kultura● Falsyfikacja jako metoda naukowa i metoda testów
  11. 11. Pytania/pomysły?

×