Greenfield projects are awesome – you can develop highest quality application using best practices on the market. But what if your bread actually is Legacy projects? Does it mean that you need to descend into darkness of QA absence? This talk will show you how to be successful even with the oldest legacy projects out there through the introduction of Agile processes and tools like Behat.
2. Who?
!
BDD Evangelist
!
BDD Practice Manager @Inviqa
!
Creator of Behat, Mink, PhpSpec2,
Prophecy
!
Contributor to Symfony2, Composer
!
Host of the “Elephant in the Room”
podcast
3. This talk is about
•
Solving purely technical “TCIAM” problem with agile
business analysis and discovery processes
•
Building a delivery strategy on the idea of constant
change
•
Real-life experience
4. This talk is not about
•
Greenfield projects
•
Solutions for everyone
•
How to write code
5. This talk is not about
•
Greenfield projects
•
Maintenance-mode projects
•
Solutions for everyone
•
How to write code (well, mostly)
12. If the project can afford at least one full-time
specialist on a payroll that whines how horrible
this project is, then surely it did something right.
20. Three options
1. Rewrite an entire application using “the right way”
2. Do functional refactoring
3. Do business-oriented rewrite using “BDD pipeline”
39. Questionnaire
1. What is the goal and minimal valuable product?
2. What is the minimal set of features to support it?
3. Which features are more likely to change?
4. How fully those features should be implemented?
5. How to avoid gold plating?
41. 1. What is the Goal &
minimal valuable product?
Impact Mapping
42. “Impact mapping is a strategic planning technique
that prevents organisations from getting lost
while building products and delivering projects,
by clearly communicating assumptions, helping
teams align their activities with overall business
objectives and make better roadmap decisions.”
– Gojko Adzic
43. Four levels of Impact Map
1. Why? are we doing all this (rewrite)? What is the
goal we’re trying to achieve?
2. Who? will be impacted by it?
3. How? can they help us to achieve the goal?
4. What? can we do to support them?
47. 2. What is the minimal set
of features to support it?
Feature Mapping
48. “Feature mapping is a backlog grooming
technique. It is a graphical process which helps
teams in finding features that are necessary to
support discovered MVP”
– Marcello Duarte
49. Three levels of feature map
1. What? is the minimal marketable feature?
2. Who? will be impacted by this feature?
3. What? particular parts of this feature do they need
to create this impact?
58. 4. How fully those features
should be implemented?
Example workshops
59. Three layers of a User-Story
•
Business rule(s)
•
Communication
•
Acceptance criteria
60. Three layers of a User-Story
•
Business rule(s) == Acceptance criteria
•
Communication
61. Three layers of a User-Story
•
Business rule(s) == Acceptance criteria
•
Communication == Examples
62. Three layers of a User-Story
•
Business rule(s)
•
Communication == Examples == Acceptance criteria
63. Feature: registration
in order to maintain my shopping history
as a site visitor
i need to be able to register on this site
64. Feature: registration
in order to maintain my shopping history
as a site visitor
i need to be able to register on this site
Scenario: Successful registration when visitor provides all the required info
65. Feature: registration
in order to maintain my shopping history
as a site visitor
i need to be able to register on this site
Scenario: Successful registration when visitor provides all the required info
Scenario: Unable to register when visitor misses required info
66. Feature: registration
in order to maintain my shopping history
as a site visitor
i need to be able to register on this site
Scenario: Successful registration when visitor provides all the required info
Scenario: Unable to register when visitor misses required info
Scenario: ...
67. Feature: registration
in order to maintain my shopping history
as a site visitor
i need to be able to register on this site
Scenario: Successful registration when visitor provides all the required info
Scenario: Unable to register when visitor misses required info
Scenario: ...
Scenario: ...
Scenario: ...
Scenario: ...
Scenario: ...
68. Feature: registration
in order to maintain my shopping history
as a site visitor
i need to be able to register on this site
Scenario: Successful registration when visitor provides all the required info
Given I am on the homepage
When I follow “sign up”
And I fill in registration form
And I submit it
Then I should be successfully registered
And I should be on the homepage again
80. Feature: registration
in order to maintain my shopping history
as a site visitor
i need to be able to register on this site
Scenario: Successful registration when visitor provides all the required info
Given I am on the homepage
When I follow “sign up”
And I fill in registration form
And I submit it
Then I should be successfully registered
And I should be on the homepage again
81. Feature:
in order
as a
i need
Scenario: Successful registration when visitor provides
Given I am on the
When
And I fill in
And I submit it
Then
And I should be on the homepage
What could be automated
should be automated
84. Setup
1. Dump your sprint features into text files
2. Put those text files into the `features/` folder inside
project
3. Install behat (via composer or behat.phar)
4. Initialize behat test suite by running `bin/behat —init`
86. First run
$> bin/behat
...
You can implement step definitions for undefined steps with these snippets:
!
/**
* @Then I should see :arg1
*/
public function iShouldSee($arg1)
{
throw new PendingException();
}
...
88. Feedback loop
$> bin/behat
!
Feature: registration
in order to maintain my shopping history
as a site visitor
i need to be able to register on this site
!
Scenario: Successful registration when visitor provides all the required info
Given I am on the homepage
TODO: write pending definition
When I follow “sign up”
And I fill in registration form
And I submit it
Then I should be successfully registered
And I should be on the homepage again
91. Colour it red
/**
* @Given /^I am on the homepage$/
*/
public function iAmOnTheHomepage()
{
$crawler = new SomeCrawlerLibCrawler();
$crawler->goto(“http://localhost:8080/”);
if (200 !== $crawler->getCurrentStatusCode())
{
throw new RuntimeException(‘Can not open homepage’);
}
}
92. Colour it red
$> bin/behat
!
Feature: registration
in order to maintain my shopping history
as a site visitor
i need to be able to register on this site
!
Scenario: Successful registration when visitor provides all the required info
Given I am on the homepage
Can not open homepage (RuntimeException)
When I follow “sign up”
And I fill in registration form
And I submit it
Then I should be successfully registered
And I should be on the homepage again
95. Change the message
$> bin/behat
!
Feature: registration
in order to maintain my shopping history
as a site visitor
i need to be able to register on this site
!
Scenario: Successful registration when visitor provides all the required info
Given I am on the homepage
Can not open homepage (RuntimeException)
When I follow “sign up”
And I fill in registration form
And I submit it
Then I should be successfully registered
And I should be on the homepage again
96. Change the message
$> bin/behat
!
Feature: registration
in order to maintain my shopping history
as a site visitor
i need to be able to register on this site
!
Scenario: Successful registration when visitor provides all the required info
Given I am on the homepage
Route … not found (FrameworkException)
When I follow “sign up”
And I fill in registration form
And I submit it
Then I should be successfully registered
And I should be on the homepage again
97. Change the message
$> bin/behat
!
Feature: registration
in order to maintain my shopping history
as a site visitor
i need to be able to register on this site
!
Scenario: Successful registration when visitor provides all the required info
Given I am on the homepage
Template … not found (FrameworkException)
When I follow “sign up”
And I fill in registration form
And I submit it
Then I should be successfully registered
And I should be on the homepage again
98. Change the message
$> bin/behat
!
Feature: registration
in order to maintain my shopping history
as a site visitor
i need to be able to register on this site
!
Scenario: Successful registration when visitor provides all the required info
Given I am on the homepage
When I follow “sign up”
TODO: write pending definition
And I fill in registration form
And I submit it
Then I should be successfully registered
And I should be on the homepage again
100. Change the message
$> bin/behat
!
Feature: registration
in order to maintain my shopping history
as a site visitor
i need to be able to register on this site
!
Scenario: Successful registration when visitor provides all the required info
Given I am on the homepage
When I follow “sign up”
And I fill in registration form
And I submit it
Then I should be successfully registered
Object `User` and its method `isRegistered` does not exist (RuntimeException)
And I should be on the homepage again
106. Describe your first message
<?php
!
namespace specAcmeUserbase;
!
class User extends ObjectBehavior
{
function it_is_registered_by_default()
{
$this->shouldBeRegistered();
}
}
107. Colour it red
$> bin/phpspec
!
Class “AcmeUserbaseUser” does not exist. Create? [Y/n]
y
!
Method `AcmeUserbaseUser::isRegistered()` does not exist. Create? [Y/n]
y
112. Verify feature
$> bin/behat
!
Feature: registration
in order to maintain my shopping history
as a site visitor
i need to be able to register on this site
!
Scenario: Successful registration when visitor provides all the required info
Given I am on the homepage
When I follow “sign up”
And I fill in registration form
And I submit it
Then I should be successfully registered
And I should be on the homepage again
113. Verify feature
$> bin/behat
!
Feature: registration
in order to maintain my shopping history
as a site visitor
i need to be able to register on this site
!
Scenario: Successful registration when visitor provides all the required info
Given I am on the homepage
When I follow “sign up”
And I fill in registration form
And I submit it
Then I should be successfully registered
And I should be on the homepage again