You can easily use tools such as Behat and phpspec for practicing BDD in PHP. Regardless of the specific BDD tools, the question of how to do BDD “properly” arises. According to Dan North, initiator of the BDD philosophy, it should be be practiced as a “mutliple-stakeholder, agile methodology”. However, most open-source projects are not developed with an explicit agile methodology. Also, there are hardly any stakeholder roles that are clearly distinguishable from each other - often contributor and user are actually one and the same. So, in the case of open-source projects, you can question the benefit of BDD.
7. I WILL
Question BDD!
Dan North: « BDD is a [...] multiple-stakeholder, agile methodology »
BDD is beneficial in agile customer projects.
8. I WILL
Question BDD!
Dan North: « BDD is a [...] multiple-stakeholder, agile methodology »
BDD is beneficial in agile customer projects.
customer pays
→ explicit customer
→ agile process
9. I WILL
Question BDD!
Dan North: « BDD is a [...] multiple-stakeholder, agile methodology »
BDD is beneficial in agile customer projects.
open-source projects
customer pays
→ explicit customer
→ agile process
developers work for free
→ no explicit customer
→ emergent process
10. I WILL
Question BDD!
Dan North: « BDD is a [...] multiple-stakeholder, agile methodology »
BDD is beneficial in agile customer projects.
customer pays
→ explicit customer
→ agile process
Is it beneficial in open-source projects as well?
developers work for free
→ no explicit customer
→ emergent process
23. METHOD
SpecBDD
NOTION
Dan North 2003:
SYNTAX
function it_greets_with_hello_world()
{
$this->greet()->shouldReturn(
'Hello World'
);
}
StoryBDD
TOOL
names of test methods
describe intended behavior
Scenario:
Given a
When an
Then an
A successful scenario
precondition
event occurred
outcome is achieved
27. QUESTION #1
Should you use SpecBDD as substitute for xUnit?
phpspec
CUSTOMER
PROJECT
no problem in principal
PHPUnit
28. QUESTION #1
Should you use SpecBDD as substitute for xUnit?
phpspec
CUSTOMER
PROJECT
OPEN-SOURCE
PROJECT
PHPUnit
no problem in principal
community developers unfamiliar with the code might be irritated
29. QUESTION #1
Should you use SpecBDD as substitute for xUnit?
phpspec
CUSTOMER
PROJECT
OPEN-SOURCE
PROJECT
PHPUnit
no problem in principal
community developers unfamiliar with the code might be irritated
“Where are the unit tests?”
“How to unit test with that?”
30. QUESTION #1
Should you use SpecBDD as substitute for xUnit?
phpspec
CUSTOMER
PROJECT
OPEN-SOURCE
PROJECT
PHPUnit
no problem in principal
community developers unfamiliar with the code might be irritated
“Where are the unit tests?”
“How to unit test with that?”
32. METHOD
SpecBDD
StoryBDD
Dan North 2011:
NOTION
SYNTAX
TOOL
“TDD done right”
function it_greets_with_hello_world()
{
$this->greet()->shouldReturn(
'Hello World'
);
}
« BDD is about understanding
the customer's need [...] (and
being able to prove that with
an evolving suite of
acceptance tests) »
Scenario:
Given a
When an
Then an
A successful scenario
precondition
event occurred
outcome is achieved
33. METHOD
NOTION
SYNTAX
TOOL
SpecBDD
“TDD done right”
function it_greets_with_hello_world()
{
$this->greet()->shouldReturn(
'Hello World'
);
}
StoryBDD
understanding
customer’s need
+ evolving suite of
acceptance tests
Scenario:
Given a
When an
Then an
A successful scenario
precondition
event occurred
outcome is achieved
36. STORYBDD IN DETAIL
implementing something correctly && implementing the right thing
acceptance tests are secondary to the understanding
37. STORYBDD IN DETAIL
implementing something correctly && implementing the right thing
acceptance tests are secondary to the understanding
customer explicitly asks for their production && co-produces them
38. STORYBDD IN DETAIL
implementing something correctly && implementing the right thing
acceptance tests are secondary to the understanding
customer explicitly asks for their production && co-produces them
41. QUESTION #2
Who decides what the right thing is?
CUSTOMER
PROJECT
OPEN-SOURCE
PROJECT
customer, thus no problem
developer, thus potential problem
42. QUESTION #2
Who decides what the right thing is?
CUSTOMER
PROJECT
OPEN-SOURCE
PROJECT
customer, thus no problem
developer, thus potential problem
customer === (other) developers (i.e. bundle level) → no problem
elsewise (i.e. application level) → “language of the customer” is not met
43. QUESTION #2
Who decides what the right thing is?
CUSTOMER
PROJECT
OPEN-SOURCE
PROJECT
customer, thus no problem
developer, thus potential problem
customer === (other) developers (i.e. bundle level) → no problem
elsewise (i.e. application level) → “language of the customer” is not met
44. STORYBDD IN DETAIL
implementing something correctly && implementing the right thing
acceptance tests are secondary to the understanding
customer explicitly asks for their production && co-produces them
46. QUESTION #3
How to facilitate understanding?
CUSTOMER
PROJECT
face-to-face communication, thus no problem
47. QUESTION #3
How to facilitate understanding?
CUSTOMER
PROJECT
OPEN-SOURCE
PROJECT
face-to-face communication, thus no problem
communication mainly via issue tracker. pull requests, Twitter, etc.
→ StoryBDD is impeded
48. QUESTION #3
How to facilitate understanding?
CUSTOMER
PROJECT
OPEN-SOURCE
PROJECT
face-to-face communication, thus no problem
communication mainly via issue tracker. pull requests, Twitter, etc.
→ StoryBDD is impeded
→ but StoryBDD is the solution
49. QUESTION #3
How to facilitate understanding?
CUSTOMER
PROJECT
OPEN-SOURCE
PROJECT
face-to-face communication, thus no problem
communication mainly via issue tracker. pull requests, Twitter, etc.
→ StoryBDD is impeded
→ but StoryBDD is the solution
(watching the execution of the Behat suite live in a browser facilitates
your understanding about the features of the open-source project)
50. QUESTION #3
How to facilitate understanding?
CUSTOMER
PROJECT
OPEN-SOURCE
PROJECT
face-to-face communication, thus no problem
communication mainly via issue tracker. pull requests, Twitter, etc.
→ StoryBDD is impeded
→ but StoryBDD is the solution
(but browser is emulated so far)
(watching the execution of the Behat suite live in a browser facilitates
your understanding about the features of the open-source project)
51. STORYBDD IN DETAIL
implementing something correctly && implementing the right thing
acceptance tests are secondary to the understanding
customer explicitly asks for their production && co-produces them
53. QUESTION #4
Who asks for their production?
CUSTOMER
PROJECT
customer, thus no problem
54. QUESTION #4
Who asks for their production?
CUSTOMER
PROJECT
OPEN-SOURCE
PROJECT
customer, thus no problem
(some) community developers, thus potential problem
55. QUESTION #4
Who asks for their production?
CUSTOMER
PROJECT
OPEN-SOURCE
PROJECT
customer, thus no problem
(some) community developers, thus potential problem
StoryBDD might be process overhead → more impediment than benefit
56. QUESTION #4
Who asks for their production?
CUSTOMER
PROJECT
OPEN-SOURCE
PROJECT
customer, thus no problem
(some) community developers, thus potential problem
StoryBDD might be process overhead → more impediment than benefit
“The code doesn’t get green anymore!”
“If the worst comes to the worst, who decides to abandon Behat?”
57. QUESTION #4
Who asks for their production?
CUSTOMER
PROJECT
OPEN-SOURCE
PROJECT
customer, thus no problem
(some) community developers, thus potential problem
StoryBDD might be process overhead → more impediment than benefit
“The code doesn’t get green anymore!” (at early development stage)
“If the worst comes to the worst, who decides to abandon Behat?”
64. CONCLUSION
SpecBDD might benefit open-source projects.
StoryBDD might benefit open-source projects.
(even more than customer projects)
StoryBDD might impede open-source projects.
What to do?
65. CONCLUSION
SpecBDD might benefit open-source projects.
StoryBDD might benefit open-source projects.
(even more than customer projects)
StoryBDD might impede open-source projects.
What to do?
Contribute!
66. CONCLUSION
SpecBDD might benefit open-source projects.
StoryBDD might benefit open-source projects.
(even more than customer projects)
StoryBDD might impede open-source projects.
What to do?
Contribute!
e.g.
67. QUESTIONS?
fabian.kiss@ymc.ch
@head_revision
www.ymc.ch
Quotes:
Slide 06: How to sell BDD to the business by Dan North
Slide 32: Defining BDD by Dan North
Photo Credits:
Slide 01: off to save something by bokeh burger
Slide 04: Alpkäse, Aeschi bei Spiez by Time.Captured
Slide 12: Background image by Sylius
Slide 15: Swiss Army by Jim Pennucci
Slide 58: Vancouver Symphony Orchestra with Bramwell Tovey by Vancouver 125