Practiced agile developer with tdd & bdd

Post on 05-Dec-2014

473 views 6 download

description

 

transcript

Practiced Agile Developer with TDD and BDD by Sakares SaengkaewSoftware Development and Quality Improvement, Asian Institute of Technology

How many hours testing of your software? When will you perform testing? What happens?

● 8 hours?● 10 % of project work hours.● before deployment 5 days and some bugs

still be unsolved left.● complicate unsolvable bug.● Need more time to debug.● Just show to customer and wish they will not

see unexpected scene.

How should we make it better?

- Change the way of coding by TDD !

What's TDD ?- abbreviated from "Test Driven Development".

- a programming technique based on a very simple rule :

Only ever write code to fix a failing test.

What's TDD ?- Test first, then code and design afterward.

What's TDD ?- But It's not finished yet.- We call it refactoring to better communicate that the last step is about transforming the current design toward a better design.

How to ?- Using Unit Test. For example, JUnit in Java, BoostTest in C++ or UnitTest in Ruby on Rails.

- Perform Red-Green-Refactor principle.

Red-Green-Refactor- Firstly, write a test. Hence, it failed (Red) since there is no functionality code at start.- Secondly, make it pass by simply implementing the missing functionality. Then it turn pass (Green).- Last, refactoring. As we improve the design of the code without altering its external behavior, all tests should pass and, thus, we should remain green.

Brief summary : TDD- TDD is when you use Automated Testing (usually Unit Testing) as a design practice.- TDD ensures high quality code.- Release work with confident.- Make a collective code ownership since unit test suite is a clear document that every developer in teams can read, follow and write by individual.

But the defect of TDD- The unit tests still test the behavior of the method. - It may be difficult to trace the behavior of the method directly to the behavior that the external stakeholders asked for and/or understand.- Hence, we consider BDD .

What's BDD ?- abbreviated from "Behavior Driven Development".- BDD is an extension/revision of TDD.- BDD specifies that tests of any unit of software should be specified in terms of the desired behavior of the unit.

What's BDD ?- Borrowing from agile software development the "desired behavior" in this case consists of the requirements set by the business.- BDD utilizes a "Ubiquitous Language", a body of knowledge that can be understood by both the developer and the customer. Moreover, it is used to shape and develop the requirements and testing needed, at the level of the customer's understanding.

How to ?- Popular BDD tools include Cucumber, RSpec, SpecFlow and others. - To explain how to perform simply BDD, we will illustrate from the Cucumber tool by Ruby language .

BDD by Cucumber 1: Describe behaviour in plain text

BDD by Cucumber 2: Write a step definition in Ruby

BDD by Cucumber 3: Run and watch it fail

BDD by Cucumber 4: Write code to make the step pass

BDD by Cucumber 5: Run again and see the step pass

BDD by Cucumber 6: Repeat 2-5 until green like a cuke

Brief summary : BDD- BDD is when you use Automated Testing to flesh out & capture domain logic starting from the (high-enough) functional testing down to the domain unit logic.- BDD ensures high cohesion between technical implementation and the domain. - makes sense to business via the domain units and behaviour that domain experts understand.

Summary : What's different between TDD and BDD ?- BDD focuses on the behavioural aspect of the system rather than the implementation aspect of the system that TDD focuses on. - BDD gives a clearer understanding as to what the system should do from the perspective of the developer and the customer. - TDD only gives the developer an understanding of what the system should do.

Summary - One of the principles in agile, "Responding to change over following a plan". This means that do not know in advance what you have to build. - TDD and BDD support the change since you can write exactly needed feature. Also prevent overproduction.

Summary - "Customer collaboration over contract negotiation". It's clear by using BDD. Customer become to cooperate in software development. Sharpen the product requirement in business aspect.

Reference● Practices of an agile developer: working in the real world

by Venkat Subramaniam, Andy Hunt● Test Driven: Practical TDD and Acceptance TDD for Java

Developers by Lasse Koskela● The Cucumber Book: Behaviour-Driven Development for

Testers and Developers by Matt Wynne, Matt Wynne● http://www.anitpatel.net/2012/06/14/what-is-the-difference-

between-tddatddbdd-in-agile-development/● http://en.wikipedia.org/wiki/Behavior-driven_development● http://programmers.stackexchange.

com/questions/21870/can-you-be-agile-without-doing-tdd-test-driven-development

● http://cukes.info/