TDD,BDD and Unit Testing in Ruby

Slides:



Advertisements
Similar presentations
Extreme Programming Alexander Kanavin Lappeenranta University of Technology.
Advertisements

What is Unit Testing? How TDD Works? Tsvyatko Konov Telerik Corporation
Test-Driven Development and Refactoring CPSC 315 – Programming Studio.
Test-Driven Development and Refactoring Project 3 Lecture 1 CPSC 315 – Programming Studio Fall 2009.
Agile Methods and Extreme Programming CSSE 376, Software Quality Assurance Rose-Hulman Institute of Technology March 23, 2007.
23-Jun-15 Unit Testing in Ruby. Programming methodologies The grim facts: The majority of large programming projects fail Projects that succeed are usually.
Computer Engineering 203 R Smith Agile Development 1/ Agile Methods What are Agile Methods? – Extreme Programming is the best known example – SCRUM.
Unit testing C# classes “If it isn’t tested it doesn’t work” Unit testing C# classes1.
Automated Testing Nathan Weiss April 23, Overview History of Testing Advantages to Automated Testing Types of Automated Testing Automated Testing.
Introduction to Agile Methodologies and Concepts Roy Osherove Principal, Team Agile Blog : ISerializable.com.
Test-Driven Development “Test first, develop later!” –OCUnit.
Living Requirements using Behavior Driven Development
Test Driven Development Derived from Dr. Fawcett’s notes Phil Pratt-Szeliga Fall 2009.
Test-Driven Development Gary Brown Building better software one test at a time.
TEST-DRIVEN DEVELOPMENT AND MVP Cory Foy and Michael Russo.
Test Driven Development TDD. Testing ”Testing can never demonstrate the absence of errors in software, only their presence” Edsger W. Dijkstra (but it.
Test Driven Development An approach to writing better code Jimmy Zimmerman Intel Corporation.
AgileCamp Presents: Agile Software Development. Good luck in your presentation! This slide deck has been shared by AgileCamp Kit under the Creative Commons.
1 Design and Integration: Part 1 Nuggets about Design vs Project Management.
Lecture 6 Software Testing and jUnit CS140 Dick Steflik.
Behaviour Driven Development with Cucumber for Java.
Introduction to Unit Testing Jun-Ru Chang 2012/05/03.
Extreme Programming: Introduced Matthew Heusser Excelon Development – xndev.com - Presented to CS 611 at GVSU, 4/6/2005.
Agile and XP Development Dan Fleck 2008 Dan Fleck 2008.
CS 360 Lecture 3.  The software process is a structured set of activities required to develop a software system.  Fundamental Assumption:  Good software.
Testing in Extreme Programming
Coming up: What is Agile? XP Development Dan Fleck 2010 Dan Fleck 2010.
© ALEXANDRE CUVA  VERSION 2.00 Test Driven Design.
October, 2006 © Copyright 2006, Larry A. Beaty. Copying and distribution of this document is permitted in any medium, provided this notice is preserved.
Future Media  BBC MMXI TDD at the BBC David Craddock, Jack Palfrey and Tom Canter.
Sofia Bulgaria Summer School IST eXPERT: Best Practice on e-Project Development 30 June - 2 July 2003 eXtreme programming.
A Practical Guide To Unit Testing John E. Boal TestDrivenDeveloper.com.
A tool for test-driven development
AP-1 4. Agile Processes. AP-2 Agile Processes Focus on creating a working system Different attitude on measuring progress XP Scrum.
Test-Driven Development Eduard Miric ă. The problem.
Lecture 4 – XP and Agile 17/9/15. Plan-driven and agile development Plan-driven development A plan-driven approach to software engineering is based around.
Scalatest. 2 Test-Driven Development (TDD) TDD is a technique in which you write the tests before you write the code you want to test This seems backward,
Test Driven Development Daniel Brown dxb17u. Introduction Originates from Extreme Programming (XP) Proposed by Kent Beck in Test Driven Development.
WATERFALL DEVELOPMENT MODEL. Waterfall model is LINEAR development lifecycle. This means each phase must be completed before moving onto the next!!! WHAT.
1 Presentation Title Test-driven development (TDD) Overview David Wu.
HOW AND WHY TO LOVE CUCUMBER By Dana Scheider. Is This Your Programming Experience?
Copyright 2002 by RoleModel Software, Inc. Extreme Programming: So What? Roy W. Miller RoleModel Software, Inc.
Phoenix Scrum User Group Simplifying Scrum Online May 21 st 2009.
The Last Lecture CS 5010 Program Design Paradigms "Bootcamp" Lesson © Mitchell Wand, This work is licensed under a Creative Commons Attribution-NonCommercial.
Software Development Process CS 360 Lecture 3. Software Process The software process is a structured set of activities required to develop a software.
Test Driven Development Introduction Issued date: 8/29/2007 Author: Nguyen Phuc Hai.
CS223: Software Engineering Lecture 18: The XP. Recap Introduction to Agile Methodology Customer centric approach Issues of Agile methodology Where to.
Unit testing with NUnit Anne Lam & Chris James CMPS 4113 – Software Engineering April 15, 2015.
Software Engineering Lecture 11 Software Testing Presenter: Josef Hallberg 1.
Software Development. The Software Life Cycle Encompasses all activities from initial analysis until obsolescence Analysis of problem or request Analysis.
Coming up: What is Agile? XP Development Dan Fleck 2010 Dan Fleck 2010.
TDD Unit tests from a slightly different point of view Katie Dwyer.
CS223: Software Engineering
Software Development.
Unit Testing - solid fundamentals
Agile Software Development II
Smalltalk Testing - SUnit
Test Driven Development 1 November Agenda  What is TDD ?  Steps to start  Refactoring  TDD terminology  Benefits  JUnit  Mocktio  Continuous.
CS 5010 Program Design Paradigms "Bootcamp" Lesson 12.1
Extreme Programming.
Unit testing C# classes
History, Characteristics and Frameworks
Agile and XP Development
Test-driven development (TDD)
Testing and Test-Driven Development CSC 4700 Software Engineering
Agile and XP Development
Chapter 3 – Agile Software Development
Coming up: What is Agile?
You’ll get better code in less time (If you do it for a while)
Refactoring Low Level/High Level.
Presentation transcript:

TDD,BDD and Unit Testing in Ruby

A Test Driven Life Approach  Expect Something big  Expect many smaller things as part of it

A Test Driven Life Approach  Acceptance Test  Fill in the gaps with Specs, Unit and Integration Testing

 Engineering methodologies (waterfall for example..)  Agile (flexible & lightwheight) Methodologies  eXtreme Programming  Test Driven Development Team Agile - All rights reserved Putting TDD in Context

What is a ‘Unit’?

Unit Of Work Production Code Unit Of Work Production Code Unit Of Work Return Value/Exceptio n Noticeable State Change 3 rd Party call Public API Test

Production Code Unit Of Work Production Code Unit Of Work Return Value/Exceptio n Public API Assert Test

Production Code Unit Of Work Production Code Unit Of Work Noticeable State Change Test Public API Assert

Noticeable System Behavior Change  Noticeable by a user of the public API,  at the same level of the entry point that made the change.  ACT and ASSERT on the same level of APIs.

Production Code Unit Of Work Production Code Unit Of Work 3 rd Party call Test Public API Assert 3 rd Party Unit Of Work

Production Code Unit Of Work Production Code Unit Of Work 3 rd Party call Test Public API Assert 3 rd Party Unit Of Work Mock

 Easier to find bugs  Easier to maintain  Easier to understand  Easier to Develop Team Agile - All rights reserved Unit Testing makes your developer lives easier

 Not structured  Not Repeatable  Not on all your code  Not easy to do as it should be  A framework is missing Team Agile - All rights reserved All devs have already done Unit testing

 Original was for SmallTalk  Kent Beck and Erich Gamma  Ported to Various languages and platforms  JUnit, CppUnit, DUnit, VBUnit, RUnit, PyUnit, Sunit, HtmlUnit, …  Good list at  Standard test architecture  Introducing RSpec Team Agile - All rights reserved The xUnit Frameworks

Frameworks  Test-Unit  Minitest  RSpec

Acceptance Frameworks  Cucumber  Steak  Turnip

Demo

 Make it Fail  No code without a failing test  Make it Work  As simply as possible  Make it Better  Refactor Team Agile - All rights reserved Test-Driven Development

Demo

String Calculator Osherove.com/kata

Demo String Calc

Simplicity Team Agile - All rights reserved

Simplicity take 2  As many assumptions as you can  Then debunk them one by one

Example  The input will always be empty  - wrong, if I send in a …  The input will always be one number if it is not empty  - wrong, if I send in …

Common Questions

 Think through the requirement  Think about the design and usability of the API  There’s never time to write it afterwards  You write much less tests (if at all) otherwise Team Agile - All rights reserved Why write the test before the code?

 Make sure the test does not have a bug  Make sure you’re testing the right thing  Define a small problem to solve  When the test passes, you are done  If you can’t write that test, you may  Not understand the requirement  Have over designed things (not testable)  Not have a small enough problem to solve Team Agile - All rights reserved Why make it fail first?

 Force you to write more tests you hadn’t considered  Simpler solutions are easier to maintain  Better code coverage of tested code Team Agile - All rights reserved Why solve it as simply as possible?

 Constantly improve the design of the code  Unit tests act as safety net  Remove duplication, improve readability and maintainability  You’ll need to when things change (requirements, your understanding of them, other factors..) Team Agile - All rights reserved Why Refactor?

 60% of the features you build won’t be used  Hopping between tasks can leave stuff undone  Something working is better than nothing  Meanwhile requirements may change, you lose less work (simpler solution, less time).  Small units of work are easier for people – better life!  Feeling of accomplishment that stuff is done Team Agile - All rights reserved Why work incrementally?

 It’s a much bigger problem to solve  Longer time to “green bar” feeling  You won’t know you have good code coverage  Solution probably more complex than it could have been  To support all tests at once  Also takes longer to create, more possibility of undetected bugs Team Agile - All rights reserved Why not write many tests at once?

 Implement – 7d  Testing – 3d  Fix Bugs – 3d  Testing – 3d  Fix Bugs – 2d  Testing – 1d  Release(19d)  Implement – 14d  Testing – 3d  Fix Bugs – 2d  Testing – 1d  Fix Bugs – 1d  Testing – 1d  Release(22d) Team Agile - All rights reserved Scenario

 Potential “Production Bugs” reduced by up to 90% - > more stable product  Better designed interfaces  API Documentation  Safety net for past and future  Happier customer  Happier coders Team Agile - All rights reserved ROI

 Implementat – 7d  Integration – 7d  Testing – 3d  Fix Bugs – 3d  Testing – 3d  Fix Bugs – 2d  Testing – 1d  Release(26d)  Implement – 14d  Integration – 2d  Testing – 3d  Fix Bugs – 2d  Testing – 1d  Fix Bugs – 1d  Testing – 1d  Release(24d) Team Agile - All rights reserved Scenario

Questions?