Presentation is loading. Please wait.

Presentation is loading. Please wait.

TDD elaborate 2011-06-10. 들어가기 전에 … This is not a whole story of TDD. This is not a whole story of developing Actually, there is no neat end of developing.

Similar presentations


Presentation on theme: "TDD elaborate 2011-06-10. 들어가기 전에 … This is not a whole story of TDD. This is not a whole story of developing Actually, there is no neat end of developing."— Presentation transcript:

1 TDD elaborate

2 들어가기 전에 … This is not a whole story of TDD. This is not a whole story of developing Actually, there is no neat end of developing :P

3 필요성 보통 개발을 한다면,,, – 우선 중요한 기능을 다 짜보고 – 간단하게 실행해보고 – 예외 케이스들에 대한 처리 생각해보고 – 버그가 있으면 고친다 printf, print, system.out.println, print_r …… 오랜 시간 동안 스스로 자아성찰을 하게 된다 ( 나는 왜 코드를 이렇게 짰을까 ……) 문제가 어디가 있는지 찾기 어렵다 고친 다음 혹시 부작용이 있지는 않을까 걱정을 한다 (A 를 고치면 B 가 안되고 B 를 고치면 C 가 안되고 C 를 고치면 A 가 안되고 …) 즉, 어디까지 보장된 실행을 하는지 가늠하기 쉽지 않다 알 수 없는 기능이 만들어 지거나, 코드가 산으로 바다로 우주로 우주 밖으로 !

4 이런 거 싫다 자기를 탓하게 되고 성취감이 떨어지더라 기능 구현 보다는 개발 시간에 집착한다 중간에 잘 하고 있는지 알기 어렵다 필요 이상의 구현을 하고 있다 결론 : 생각이 많아진다

5 그렇다면, 개발 방법을 다르게 할 수는 없을까 ? 결국 사용하는 것 사용자. 그렇다면 오히려 개발을 주도하는 것은 개발자의 생각이 아 니고 사용자의 사용 방식이 아닐까 – 틀린 말은 아닌 것 같다. 그래 그럼 새로운 개 발 방법을 익히자 !

6 What is TDD? Test Driven Development – It is a Software Development Process – Family of Agile Key words – Automated unit tests – Assertions – Refactoring – Writing a code

7 Be careful! TDD is not an omniscience technique! – Usually, imported as part of process However, if you decided, please keep it during development

8 TDD Process A Process cycle is composed in 4-5 stages – Adding a test – Running a test and check – Writing code – Testing again – Refactoring the code

9 Process Diagram Refactoring

10 좀 더 쉽게 고객 ( 실질 사용자 ) 와 함께 TODO List 를 만든다 – Backlog 를 만든다는 말을 여기서 쓸 거다 나에게 적당한 일을 고른다 TDD 과정을 타면서 열심히 개발을 한다 다 되었으면 저장소에 반영하고 Review 를 받는다 위 3 과정을 TODO List 가 빌 때까지 반복한다 프로그램 개발이 끝났다

11 Good to Frameworks! JUnit (Java unit test framework) Python unit test module – import unittest Django unit test module – from django.utils import unittest A lot of unit testing frameworks – xUnit is a general term for unit test frameworks What relation?

12 잠깐 ! What is Agile? What is Unit test? What is Assertion? What is Refactoring? What is Framework?

13 Agile A group of software development – – Break tasks into Short term work Cross function, self organizing – 모두가 다같이 같은 위치에서 개발을 Face to Face communication Customer Representatives Each routine should make working software For a short term project – not a 10 year project, over 50 people project – Matched to the current trend of software development

14 All right.. Let’s see examples – Bowling Scoring Program (Java with Junit) – 학점을 계산합시다 (Python with Django test)

15 Bowling Score Do you like bowling? Have you ever have a question about how bowling score is graded? – I didn’t know until this seminar…

16 Bowling keyword Frame Game Throw Understandable??? Spare Strike

17 Start of thinking What can happen in Bowling Game? When a ball is thrown – add knock downed pins Want to know score of a frame Want to total score of a current game

18 Thinking of Tests Start of thinking Test Cases – Adding score – Getting Score Of a Frame – Getting Total score

19 Write test codes public void testGameStart() { Game g = new Game(); assertEquals(0, g.getScoreOfFrame(0)); assertEquals(0, g.score()); } public void testThrowOnce() { setUp(); game.add(5); assertEquals(5, game.score()); } Understandable??? public void testThrowTwice() { setUp(); game.add(5); game.add(6); assertEquals(11, game.score()); } Any question???

20 More test codes public void testThrowWithSpare() { setUp(); game.add(3); game.add(7); game.add(6); game.add(2); assertEquals(16, game.getScoreOfFrame(1)); // (6) } public void testThrowWithStrike() { setUp(); game.add(10); game.add(7); game.add(1); assertEquals(18, game.getScoreOfFrame(1)); // 10 + (7+1) } Understandable??? Any question???

21 Practice Let’s see Eclipse We will cover there – Quite lots of explanation would be given

22 학점을 계산합시다 괜찮아 보이는 스토리를 못 짜겠다 ( 미안 ) 규칙 설명 : – Sigma ( 학점 * 점수 ) / Sigma( 학점 )

23 Specification Web based 학점 계산하기 – Users would have simple Interface 과목수를 받고, (input) 과목과 점수를 입력한 다음 (get) 평점을 내준다 (result) – Django 를 쓴다 – 모든 과목의 학점은 3 학점이라 치자

24 Like this! A+ A0 A- …… ……

25 Start Django You already know – django-admin startproject gpa – django-admin startapp input – django-admin startapp get – django-admin startapp result – I know it is redundant work

26 Thinking of Tests Right inputs Right formats and values of POST, GET Right Result of GPA

27 Practice Let’s see vim We will cover there It seems to be easy, huh? – But, there would be quite a lot of explanation

28 This not end!!!

29 Category of Tests Authentication Test DB Test HTTP Test …… Everything can be tested and should be tested

30 Be Careful again Don’t be afraid of Failing Tests! – Fail is mother of pass?!?! Be thoughtful when you writing a Test Don’t think whole at once Don’t make testing lead you, you must lead the tests!

31 Please Study hard! 여러분 것이 지금까지 본건 TDD 의 극히 일부분, framework 이 제공해 주는 것의 반의반의반 (1/8) 도 안 썼다 반드시 각각에 대한 문서를 읽어보자 – Reference 는 끝 페이지

32 It Looks Hard No, it’s not that hard I just make it verbose to show you – This seminar is not that practical Always, first time is hard – More trials, more easy work

33 Keep it mind Homework – I will check if there are test cases in your mini-project next week – Be prepared!

34 Q&A Thanks – Special thanks to Combacsa

35 Reference https://docs.djangoproject.com/en/dev/topics/testing/


Download ppt "TDD elaborate 2011-06-10. 들어가기 전에 … This is not a whole story of TDD. This is not a whole story of developing Actually, there is no neat end of developing."

Similar presentations


Ads by Google