
Test-Driven Development (TDD) Process
Explore the Test-Driven Development (TDD) process, an Agile software development approach involving writing automated unit tests, assertions, refactoring, and code implementation in iterative cycles. Learn about the benefits and cautionary aspects of TDD to enhance software development practices.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
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 :P
,,, printf, print, system.out.println, print_r ( ) (A B B C C A ) , , !
, ? . . !
What is TDD? Test Driven Development http://en.wikipedia.org/wiki/Test-driven_development It is a Software Development Process Family of Agile Key words Automated unit tests Assertions Refactoring Writing a code
Be careful! TDD is not an omniscience technique! Usually, imported as part of process However, if you decided, please keep it during development
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
Process Diagram Refactoring
Good to Frameworks! JUnit (Java unit test framework) Python unit test module import unittest What relation? Django unit test module from django.utils import unittest A lot of unit testing frameworks http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks xUnit is a general term for unit test frameworks
! What is Agile? What is Unit test? What is Assertion? What is Refactoring? What is Framework?
Agile A group of software development http://en.wikipedia.org/wiki/Agile_software_development http://agilemanifesto.org/ 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
All right.. Let s see examples Bowling Scoring Program (Java with Junit) (Python with Django test)
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
Bowling keyword Game Throw Frame Spare Strike Understandable???
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
Thinking of Tests Start of thinking Test Cases Adding score Getting Score Of a Frame Getting Total score
Write test codes public void testGameStart() { Game g = new Game(); assertEquals(0, g.getScoreOfFrame(0)); assertEquals(0, g.score()); } Understandable??? public void testThrowOnce() { setUp(); game.add(5); assertEquals(5, game.score()); } Any question??? public void testThrowTwice() { setUp(); game.add(5); game.add(6); assertEquals(11, game.score()); }
More test codes public void testThrowWithSpare() { setUp(); game.add(3); game.add(7); game.add(6); game.add(2); assertEquals(16, game.getScoreOfFrame(1)); // 3 + 7 + (6) } Understandable??? public void testThrowWithStrike() { setUp(); game.add(10); game.add(7); game.add(1); assertEquals(18, game.getScoreOfFrame(1)); // 10 + (7+1) } Any question???
Practice Let s see Eclipse We will cover there Quite lots of explanation would be given
Specification Web based Users would have simple Interface , (input) (get) (result) Django 3
Like this! <form action="get.html" method="get"> <div> <input type="text" size="5"> <input type="submit" value="Get!"> </div> </form> <form action="result.html" method="post"> <div> <input type="text" name="s1"> <select name="g1"> <option value="1">A+</option> <option value="2">A0</option> <option value="3">A-</option> </select> </div>
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
Thinking of Tests Right inputs Right formats and values of POST, GET Right Result of GPA
Practice Let s see vim We will cover there It seems to be easy, huh? But, there would be quite a lot of explanation
Category of Tests Authentication Test DB Test HTTP Test Everything can be tested and should be tested
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!
Please Study hard! TDD , framework (1/8) Reference
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
Keep it mind Homework I will check if there are test cases in your mini-project next week Be prepared!
Q&A Thanks Special thanks to Combacsa
Reference http://www.agiledata.org/essays/tdd.html http://www.martinfowler.com/bliki/Xunit.html http://en.wikipedia.org/wiki/Test_automation http://en.wikipedia.org/wiki/XUnit http://en.wikipedia.org/wiki/Test-driven_development https://docs.djangoproject.com/en/dev/topics/testing/ http://www.junit.org/ http://en.wikipedia.org/wiki/Agile_software_development http://agilemanifesto.org/ http://sparcs.org/seminar/attachment/combacsa-20100612-2.pptx