16. Мы не тестируем, что приложение
функционирует так, как мы
(разработчики) ожидаем, чтобы оно
работало.
Sunday, June 9, 13
17. Мы не тестируем, что приложение
функционирует так, как мы
(разработчики) ожидаем, чтобы оно
работало.
Вместо этого, мы тестируем, что
приложение соотвествует бизнес
ожиданиям клиента.
Sunday, June 9, 13
21. Вы можете думать о StoryBDD,
как о способе обучить
клиентов тестированию.
Sunday, June 9, 13
22. Вы можете думать о StoryBDD,
как о способе обучить
клиентов тестированию.
В действительности, это
инструмент, который может
обучить вас бизнесу клиента.
Sunday, June 9, 13
27. (возможные сценарии)
possible scenarios
2
(детали сценариев)
scenario details
3
Feature: Authorization
In order to get access to the shopping history
As a frequent buyer
I need to be able to authenticate
Sunday, June 9, 13
28. (детали сценариев)
scenario details
3
Feature: Authorization
In order to get access to the shopping history
As a frequent buyer
I need to be able to authenticate
Scenario: Successfully authenticating
with correct credentials
Sunday, June 9, 13
29. Feature: Authorization
In order to get access to the shopping history
As a frequent buyer
I need to be able to authenticate
Scenario: Successfully authenticating
with correct credentials
Given there is a user “neochief” with password “123”
And I am on the login page
When I fill in “username” with “neochief”
And I fill in “password” with “123”
And I press “login”
Then I should see “Hello, neochief”
Sunday, June 9, 13
30. Feature: Authorization
In order to get access to the shopping history
As a frequent buyer
I need to be able to authenticate
Scenario: Successfully authenticating
with correct credentials
Sunday, June 9, 13
31. Feature: Authorization
In order to get access to the shopping history
As a frequent buyer
I need to be able to authenticate
Scenario: Successfully authenticating
with correct credentials
Sunday, June 9, 13
32. Feature: Authorization
In order to get access to the shopping history
As a frequent buyer
I need to be able to authenticate
Scenario: Successfully authenticating
with correct credentials
Scenario: Can not authenticate with
wrong credentials
Scenario: Blocked user can not
authenticate, even with correct
credentials
Sunday, June 9, 13
33. Feature: Authorization
In order to get access to the shopping history
As a frequent buyer
I need to be able to authenticate
Sunday, June 9, 13
34. Feature: Authorization
In order to get access to the shopping history
As a frequent buyer
I need to be able to authenticate
User story?
Sunday, June 9, 13
36. StoryBDD гарантирует, что
разработчики понимают бизнес
клиента на том же уровне, что и сам
клиент.
А иногда помогает и самому клиенту
разобраться в его бизнесе.
Sunday, June 9, 13
44. Что делает Behat?
• Превращает сценарии StoryBDD в PHP
код (например, команды Selenium).
• Исполняет этот код.
• Выводит отчеты о тестировании.
Sunday, June 9, 13
48. ...
You can implement step definitions for undefined steps with these
snippets:
/**
* @When /^I fill in “([^”]+)” with “([^”]+)”$/
*/
public function iFillInWith($val1, $val2)
{
throw new PendingException();
}
...
$> bin/behat
Пишем реализацию
Sunday, June 9, 13
49. ...
You can implement step definitions for undefined steps with these
snippets:
/**
* @When /^I fill in “([^”]+)” with “([^”]+)”$/
*/
public function iFillInWith($val1, $val2)
{
throw new PendingException();
}
...
$> bin/behat
Sunday, June 9, 13
51. /**
* @Given /^I am on homepage$/
*/
public function iAmOnHomepage()
{
throw new PendingException();
}
/**
* @Given /^I follow “sign up”$/
*/
public function iFollowSignUp()
{
throw new PendingException();
}
/**
* @When /^I fill in “([^”]+)” with “([^”]+)”$/
*/
public function iFillInWith($val1, $val2)
{
throw new PendingException();
}
FeatureContext.php
Sunday, June 9, 13
52. 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 homepage
TODO: write pending definition
And I follow “sign up”
When I fill in “email” with “linkedin@example.com”
And I fill in “username” with “linkedin”
And I fill in “password” with “sha1_without_salt”
And I press “register”
Then I should see “You have been successfully registered”
And I should be on homepage
1 scenario (1 pending)
8 steps (7 skipped, 1 pending)
0m0.015s
$> bin/behat Выполняем
Sunday, June 9, 13
53. /**
* @Given /^I am on homepage$/
*/
public function iAmOnHomepage()
{
$crawler = new SomeCrawlerLibCrawler();
$crawler->goto(“http://localhost:8080/”);
if (200 !== $crawler->getCurrentStatusCode())
{
throw new RuntimeException(‘Can not open homepage’);
}
}
FeatureContext.php
Sunday, June 9, 13
54. 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 homepage
Can not open homepage
And I follow “sign up”
When I fill in “email” with “linkedin@example.com”
And I fill in “username” with “linkedin”
And I fill in “password” with “sha1_without_salt”
And I press “register”
Then I should see “You have been successfully registered”
And I should be on homepage
1 scenario (1 FAILED)
8 steps (7 skipped, 1 FAILED)
0m0.015s
$> bin/behat
Sunday, June 9, 13
55. 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 homepage
And I follow “sign up”
TODO: write pending definition
When I fill in “email” with “linkedin@example.com”
And I fill in “username” with “linkedin”
And I fill in “password” with “sha1_without_salt”
And I press “register”
Then I should see “You have been successfully registered”
And I should be on homepage
1 scenario (1 pending)
8 steps (1 passed, 7 skipped, 1 pending)
0m0.015s
$> bin/behat
Sunday, June 9, 13
56. Drupal?
• Drupal Extension (https://drupal.org/
project/drupalextension)
• Инфраструктура Drupal.org тестируется
при помощи Behat (https://drupal.org/
project/doobie).
• http://groups.drupal.org/behat
Sunday, June 9, 13