Practiced agile developer with tdd & bdd
-
Upload
sakares-saengkaew -
Category
Technology
-
view
482 -
download
6
description
Transcript of Practiced agile developer with tdd & bdd
![Page 1: Practiced agile developer with tdd & bdd](https://reader034.fdocuments.us/reader034/viewer/2022042713/54850be3b47959fb0c8b4d96/html5/thumbnails/1.jpg)
Practiced Agile Developer with TDD and BDD by Sakares SaengkaewSoftware Development and Quality Improvement, Asian Institute of Technology
![Page 2: Practiced agile developer with tdd & bdd](https://reader034.fdocuments.us/reader034/viewer/2022042713/54850be3b47959fb0c8b4d96/html5/thumbnails/2.jpg)
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.
![Page 3: Practiced agile developer with tdd & bdd](https://reader034.fdocuments.us/reader034/viewer/2022042713/54850be3b47959fb0c8b4d96/html5/thumbnails/3.jpg)
How should we make it better?
- Change the way of coding by TDD !
![Page 4: Practiced agile developer with tdd & bdd](https://reader034.fdocuments.us/reader034/viewer/2022042713/54850be3b47959fb0c8b4d96/html5/thumbnails/4.jpg)
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.
![Page 5: Practiced agile developer with tdd & bdd](https://reader034.fdocuments.us/reader034/viewer/2022042713/54850be3b47959fb0c8b4d96/html5/thumbnails/5.jpg)
What's TDD ?- Test first, then code and design afterward.
![Page 6: Practiced agile developer with tdd & bdd](https://reader034.fdocuments.us/reader034/viewer/2022042713/54850be3b47959fb0c8b4d96/html5/thumbnails/6.jpg)
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.
![Page 7: Practiced agile developer with tdd & bdd](https://reader034.fdocuments.us/reader034/viewer/2022042713/54850be3b47959fb0c8b4d96/html5/thumbnails/7.jpg)
How to ?- Using Unit Test. For example, JUnit in Java, BoostTest in C++ or UnitTest in Ruby on Rails.
- Perform Red-Green-Refactor principle.
![Page 8: Practiced agile developer with tdd & bdd](https://reader034.fdocuments.us/reader034/viewer/2022042713/54850be3b47959fb0c8b4d96/html5/thumbnails/8.jpg)
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.
![Page 9: Practiced agile developer with tdd & bdd](https://reader034.fdocuments.us/reader034/viewer/2022042713/54850be3b47959fb0c8b4d96/html5/thumbnails/9.jpg)
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.
![Page 10: Practiced agile developer with tdd & bdd](https://reader034.fdocuments.us/reader034/viewer/2022042713/54850be3b47959fb0c8b4d96/html5/thumbnails/10.jpg)
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 .
![Page 11: Practiced agile developer with tdd & bdd](https://reader034.fdocuments.us/reader034/viewer/2022042713/54850be3b47959fb0c8b4d96/html5/thumbnails/11.jpg)
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.
![Page 12: Practiced agile developer with tdd & bdd](https://reader034.fdocuments.us/reader034/viewer/2022042713/54850be3b47959fb0c8b4d96/html5/thumbnails/12.jpg)
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.
![Page 13: Practiced agile developer with tdd & bdd](https://reader034.fdocuments.us/reader034/viewer/2022042713/54850be3b47959fb0c8b4d96/html5/thumbnails/13.jpg)
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 .
![Page 14: Practiced agile developer with tdd & bdd](https://reader034.fdocuments.us/reader034/viewer/2022042713/54850be3b47959fb0c8b4d96/html5/thumbnails/14.jpg)
BDD by Cucumber 1: Describe behaviour in plain text
![Page 15: Practiced agile developer with tdd & bdd](https://reader034.fdocuments.us/reader034/viewer/2022042713/54850be3b47959fb0c8b4d96/html5/thumbnails/15.jpg)
BDD by Cucumber 2: Write a step definition in Ruby
![Page 16: Practiced agile developer with tdd & bdd](https://reader034.fdocuments.us/reader034/viewer/2022042713/54850be3b47959fb0c8b4d96/html5/thumbnails/16.jpg)
BDD by Cucumber 3: Run and watch it fail
![Page 17: Practiced agile developer with tdd & bdd](https://reader034.fdocuments.us/reader034/viewer/2022042713/54850be3b47959fb0c8b4d96/html5/thumbnails/17.jpg)
BDD by Cucumber 4: Write code to make the step pass
![Page 18: Practiced agile developer with tdd & bdd](https://reader034.fdocuments.us/reader034/viewer/2022042713/54850be3b47959fb0c8b4d96/html5/thumbnails/18.jpg)
BDD by Cucumber 5: Run again and see the step pass
![Page 19: Practiced agile developer with tdd & bdd](https://reader034.fdocuments.us/reader034/viewer/2022042713/54850be3b47959fb0c8b4d96/html5/thumbnails/19.jpg)
BDD by Cucumber 6: Repeat 2-5 until green like a cuke
![Page 20: Practiced agile developer with tdd & bdd](https://reader034.fdocuments.us/reader034/viewer/2022042713/54850be3b47959fb0c8b4d96/html5/thumbnails/20.jpg)
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.
![Page 21: Practiced agile developer with tdd & bdd](https://reader034.fdocuments.us/reader034/viewer/2022042713/54850be3b47959fb0c8b4d96/html5/thumbnails/21.jpg)
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.
![Page 22: Practiced agile developer with tdd & bdd](https://reader034.fdocuments.us/reader034/viewer/2022042713/54850be3b47959fb0c8b4d96/html5/thumbnails/22.jpg)
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.
![Page 23: Practiced agile developer with tdd & bdd](https://reader034.fdocuments.us/reader034/viewer/2022042713/54850be3b47959fb0c8b4d96/html5/thumbnails/23.jpg)
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.
![Page 24: Practiced agile developer with tdd & bdd](https://reader034.fdocuments.us/reader034/viewer/2022042713/54850be3b47959fb0c8b4d96/html5/thumbnails/24.jpg)
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/