Rubyconf2016 - Solving communication problems in distributed teams with BDD
-
Upload
rodrigo-urubatan -
Category
Technology
-
view
114 -
download
0
Transcript of Rubyconf2016 - Solving communication problems in distributed teams with BDD
![Page 1: Rubyconf2016 - Solving communication problems in distributed teams with BDD](https://reader036.fdocuments.us/reader036/viewer/2022081605/58eb82c61a28ab33728b460b/html5/thumbnails/1.jpg)
Solving communication problems in distributed
teams with BDDRodrigo Urubatan
Developer, Writer, Crossfitter, Archer
![Page 2: Rubyconf2016 - Solving communication problems in distributed teams with BDD](https://reader036.fdocuments.us/reader036/viewer/2022081605/58eb82c61a28ab33728b460b/html5/thumbnails/2.jpg)
What is the biggest problem in software projects?
![Page 3: Rubyconf2016 - Solving communication problems in distributed teams with BDD](https://reader036.fdocuments.us/reader036/viewer/2022081605/58eb82c61a28ab33728b460b/html5/thumbnails/3.jpg)
What is the root cause for this problem?
Client DeveloperTester
![Page 4: Rubyconf2016 - Solving communication problems in distributed teams with BDD](https://reader036.fdocuments.us/reader036/viewer/2022081605/58eb82c61a28ab33728b460b/html5/thumbnails/4.jpg)
What do we need to solve this problem?
![Page 5: Rubyconf2016 - Solving communication problems in distributed teams with BDD](https://reader036.fdocuments.us/reader036/viewer/2022081605/58eb82c61a28ab33728b460b/html5/thumbnails/5.jpg)
How to solve this problem?
![Page 6: Rubyconf2016 - Solving communication problems in distributed teams with BDD](https://reader036.fdocuments.us/reader036/viewer/2022081605/58eb82c61a28ab33728b460b/html5/thumbnails/6.jpg)
Ok, but how’s that going to help design software?
• Business value is the key• What is the next important thing the system does not do
yet?• Use the business language to specify the software• Use the business language to test the software• Use the business language to write the software• Use the business language to validate the software
![Page 7: Rubyconf2016 - Solving communication problems in distributed teams with BDD](https://reader036.fdocuments.us/reader036/viewer/2022081605/58eb82c61a28ab33728b460b/html5/thumbnails/7.jpg)
![Page 8: Rubyconf2016 - Solving communication problems in distributed teams with BDD](https://reader036.fdocuments.us/reader036/viewer/2022081605/58eb82c61a28ab33728b460b/html5/thumbnails/8.jpg)
User Stories!!
•As a …• I want to ...•So that ...
•AS A BANK CLIENT
•I WANT TO USE THE CASH MACHINE
•SO THAT I CAN TAKE MONEY FROM MY ACCOUNT
![Page 9: Rubyconf2016 - Solving communication problems in distributed teams with BDD](https://reader036.fdocuments.us/reader036/viewer/2022081605/58eb82c61a28ab33728b460b/html5/thumbnails/9.jpg)
Need to see it everywhere
![Page 10: Rubyconf2016 - Solving communication problems in distributed teams with BDD](https://reader036.fdocuments.us/reader036/viewer/2022081605/58eb82c61a28ab33728b460b/html5/thumbnails/10.jpg)
But it is not enough!
![Page 11: Rubyconf2016 - Solving communication problems in distributed teams with BDD](https://reader036.fdocuments.us/reader036/viewer/2022081605/58eb82c61a28ab33728b460b/html5/thumbnails/11.jpg)
Behaviour Specification
• Context• Actions• Verification
• GIVEN THERE IS MONEY IN MY ACCOUNT
• AND I HAVE A VALID CARD
• AND THE MONEY DISPENSER HAS MONEY
• WHEN I ASK THE MACHINE FOR MONEY
• THEN THE MONEY SHOULD BE SUBTRACTED FROM MY ACCOUNT
• AND THE MONEY SHOULD BE DELIVERED TO ME
• AND MY CARD SHOULD BE RETURNED
![Page 12: Rubyconf2016 - Solving communication problems in distributed teams with BDD](https://reader036.fdocuments.us/reader036/viewer/2022081605/58eb82c61a28ab33728b460b/html5/thumbnails/12.jpg)
But how much details can I get?
![Page 13: Rubyconf2016 - Solving communication problems in distributed teams with BDD](https://reader036.fdocuments.us/reader036/viewer/2022081605/58eb82c61a28ab33728b460b/html5/thumbnails/13.jpg)
Have you seen that sintaxe anywhere before?
![Page 14: Rubyconf2016 - Solving communication problems in distributed teams with BDD](https://reader036.fdocuments.us/reader036/viewer/2022081605/58eb82c61a28ab33728b460b/html5/thumbnails/14.jpg)
Did you remember where?
• In tester spreadsheets, sometimes with columns instead of given/when/then
• It is almost the syntax for the gherkin language!!
![Page 15: Rubyconf2016 - Solving communication problems in distributed teams with BDD](https://reader036.fdocuments.us/reader036/viewer/2022081605/58eb82c61a28ab33728b460b/html5/thumbnails/15.jpg)
What if I use the same business words to name things in code?
![Page 16: Rubyconf2016 - Solving communication problems in distributed teams with BDD](https://reader036.fdocuments.us/reader036/viewer/2022081605/58eb82c61a28ab33728b460b/html5/thumbnails/16.jpg)
Let’s try that!
• GIVEN THERE IS MONEY IN MY ACCOUNT
• AND I HAVE A VALID CARD
• AND THE MONEY DISPENSER HAS MONEY
• WHEN I ASK THE MACHINE FOR MONEY
• THEN THE MONEY SHOULD BE SUBTRACTED FROM MY ACCOUNT
• AND THE MONEY SHOULD BE DELIVERED TO ME
• AND MY CARD SHOULD BE RETURNED
•ACCOUNT.HAS_ENOUGH_MONEY?(VALUE)
•CARD.VALID?
•DISPENSER.HAS_MONEY?
•MACHINE.I_WANT(VALUE)
•ACCOUNT.SUBTRACT(VALUE)
•MACHINE.DELIVER_MONEY(VALUE)
•MACHINE.RETURN_CARD
![Page 17: Rubyconf2016 - Solving communication problems in distributed teams with BDD](https://reader036.fdocuments.us/reader036/viewer/2022081605/58eb82c61a28ab33728b460b/html5/thumbnails/17.jpg)
Wow! Everyone talks the same language!
![Page 18: Rubyconf2016 - Solving communication problems in distributed teams with BDD](https://reader036.fdocuments.us/reader036/viewer/2022081605/58eb82c61a28ab33728b460b/html5/thumbnails/18.jpg)
![Page 19: Rubyconf2016 - Solving communication problems in distributed teams with BDD](https://reader036.fdocuments.us/reader036/viewer/2022081605/58eb82c61a28ab33728b460b/html5/thumbnails/19.jpg)
BDD Development cycleTalk to the client, write a user story
orSelect a user
story
Detail the story into
scenarions
Automate scenarios with selected tool
Run tests and see them fail
Write ony the code to make tests
pass
Refactor
Almost the same as TDD?
![Page 20: Rubyconf2016 - Solving communication problems in distributed teams with BDD](https://reader036.fdocuments.us/reader036/viewer/2022081605/58eb82c61a28ab33728b460b/html5/thumbnails/20.jpg)
OK, how is that different from TDD “Red, green, refactor”?• The main focus is not the test, in reality the automate step can be
skiped sometimes• The main focus is on communication• Test business behaviour not language dependent functions• Behaviour is more important to the software than how it was
implemented• The main focus in using a ubiquitous language like in DDD• Using the ubiquitous language, the user story template and the scenario
template the communication with the entire team will improve a lot
![Page 21: Rubyconf2016 - Solving communication problems in distributed teams with BDD](https://reader036.fdocuments.us/reader036/viewer/2022081605/58eb82c61a28ab33728b460b/html5/thumbnails/21.jpg)
Haven’t we forgot about test automation?
![Page 22: Rubyconf2016 - Solving communication problems in distributed teams with BDD](https://reader036.fdocuments.us/reader036/viewer/2022081605/58eb82c61a28ab33728b460b/html5/thumbnails/22.jpg)
That same context sintaxe can be automated by:
• Cucumber using gherkin - https://cucumber.io/ • Thoughtworks gauge - http://getgauge.io/• Rspec can use that syntax to name the test specs• Jbehave was created thinking about that• Specflow using gherkin - http://www.specflow.org/
![Page 23: Rubyconf2016 - Solving communication problems in distributed teams with BDD](https://reader036.fdocuments.us/reader036/viewer/2022081605/58eb82c61a28ab33728b460b/html5/thumbnails/23.jpg)
Sample gherkin codeFeature: A sample code for my presentation
As a speakerI want to have some code samplesSo that everyone understand what I'm talking about
Scenario: doing a simple google searchGiven I'm on the google home pageWhen I fill the search field with "Urubatan"Then I want to see "my web page" in the resultsAnd I want to see "my facebook profile" in the results
![Page 24: Rubyconf2016 - Solving communication problems in distributed teams with BDD](https://reader036.fdocuments.us/reader036/viewer/2022081605/58eb82c61a28ab33728b460b/html5/thumbnails/24.jpg)
Sample cucumber RuBY code
Given(/^I'm on the google home page$/) do pending # express the regexp above with the code you wish you hadend
When(/^I fill the search field with "(.*?)"$/) do |arg1| pending # express the regexp above with the code you wish you hadend
Then(/^I want to see "(.*?)" in the results$/) do |arg1| pending # express the regexp above with the code you wish you hadend
![Page 25: Rubyconf2016 - Solving communication problems in distributed teams with BDD](https://reader036.fdocuments.us/reader036/viewer/2022081605/58eb82c61a28ab33728b460b/html5/thumbnails/25.jpg)
SAMPLE CUCUMBER JAVA CODEpublic class MyStepdefs { @cucumber.api.java.en.Then("^I want to see \"([^\"]*)\" in the results$") public void iWantToSeeInTheResults(String arg0) throws Throwable { // Write code here that turns the phrase above into concrete actions throw new cucumber.api.PendingException(); } @cucumber.api.java.en.When("^I fill the search field with \"([^\"]*)\"$") public void iFillTheSearchFieldWith(String arg0) throws Throwable { // Write code here that turns the phrase above into concrete actions throw new cucumber.api.PendingException(); } @cucumber.api.java.en.Given("^I'm on the google home page$") public void iMOnTheGoogleHomePage() throws Throwable { // Write code here that turns the phrase above into concrete actions throw new cucumber.api.PendingException(); }}
![Page 26: Rubyconf2016 - Solving communication problems in distributed teams with BDD](https://reader036.fdocuments.us/reader036/viewer/2022081605/58eb82c61a28ab33728b460b/html5/thumbnails/26.jpg)
Sample gauge codeA sample code for my presentation=============
As a speaker, I want to have some code samples, So that everyone understand what I'm talking about
doing a simple google search-----------* I'm on the google home page* I fill the search field with "Urubatan"* I want to see "my web page" in the results* I want to see "my facebook profile" in the results
![Page 27: Rubyconf2016 - Solving communication problems in distributed teams with BDD](https://reader036.fdocuments.us/reader036/viewer/2022081605/58eb82c61a28ab33728b460b/html5/thumbnails/27.jpg)
SAMPLE GAUGE JAVA CODEpublic class SampleGauge { @Step("I'm on the google home page") public void goToGoogle() { // Step implementation } @Step("I fill the search field with <value>") public void fillField(String value) { // Step implementation } @Step("I want to see <addr> in the results") public void checkValue(String value) { // Step implementation }}
![Page 28: Rubyconf2016 - Solving communication problems in distributed teams with BDD](https://reader036.fdocuments.us/reader036/viewer/2022081605/58eb82c61a28ab33728b460b/html5/thumbnails/28.jpg)
Sample gauge ruby codestep "I'm on the google home page" do
endstep "I fill the search field with <name>" do |name|
endstep "I want to see <address> in the results" |address|
end
![Page 29: Rubyconf2016 - Solving communication problems in distributed teams with BDD](https://reader036.fdocuments.us/reader036/viewer/2022081605/58eb82c61a28ab33728b460b/html5/thumbnails/29.jpg)
Rodrigo Urubatan• http://www.urubatan.com.br• http://sobrecodigo.com• Twitter @urubatan• http://github.com/urubatan• http://linkedin.com/in/urubatan• http://fb.com/urubatan