Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
User Acceptance Test
with Behat
Long Nguyen
Architecture
Test Google ??
HOW #1
composer.json
"require-dev": {
"behat/behat": "^3.0",
"behat/gherkin": "^4.4",
"behat/mink-extension": "^2.1",
"beh...
Mink Driver
https://mink.readthedocs.org/en/l
atest/guides/drivers.html
choose appropriate driver for
appropriate kind of ...
install selenium (HOW #1.1)
http://www.seleniumhq.org/download/
alias startselenium='java -jar /opt/selenium-testing/selen...
HOW #2
behat.yml
default:
autoload: [ %paths.base%/test/acceptance/contexts ]
suites:
test_google_features:
paths: [ %path...
HOW #3
define feature
# features/TestGoogle.feature
Feature: Test Google
In order to search for something
Scenario: Search...
HOW #4
define context
<?php
use BehatMinkExtensionContextMinkContext;
class TestGoogleContext extends MinkContext
{
/**
* ...
HOW #5
vendor/bin/behat
autoload
read feature - compare with context
Hooks
Hooks
xpath
ref: http://mink.behat.org/en/latest/guides/traversing-pages.html
Reference:
http://docs.behat.org/en/v3.0/
https://mink.readthedocs.org/en/latest/
Demo code:
https://github.com/nguyentien...
Acceptance test with behat
Acceptance test with behat
Upcoming SlideShare
Loading in …5
×

Acceptance test with behat

979 views

Published on

Acceptance test with behat (PHP)

Published in: Software
  • Be the first to comment

Acceptance test with behat

  1. 1. User Acceptance Test with Behat Long Nguyen
  2. 2. Architecture
  3. 3. Test Google ??
  4. 4. HOW #1 composer.json "require-dev": { "behat/behat": "^3.0", "behat/gherkin": "^4.4", "behat/mink-extension": "^2.1", "behat/mink-selenium2-driver": "^1.3" },
  5. 5. Mink Driver https://mink.readthedocs.org/en/l atest/guides/drivers.html choose appropriate driver for appropriate kind of browser (selenium, phantomjs, etc …)
  6. 6. install selenium (HOW #1.1) http://www.seleniumhq.org/download/ alias startselenium='java -jar /opt/selenium-testing/selenium-server-standalone-2.47.1.jar'
  7. 7. HOW #2 behat.yml default: autoload: [ %paths.base%/test/acceptance/contexts ] suites: test_google_features: paths: [ %paths.base%/test/acceptance/features ] contexts: [ TestGoogleContext ] extensions: BehatMinkExtension: base_url: https://google.com selenium2: ~
  8. 8. HOW #3 define feature # features/TestGoogle.feature Feature: Test Google In order to search for something Scenario: Search for how google works Given I am on "/" When I fill in "q" with "how google works" And I press "btnG" Then I wait for the next step Then I should see "How Google Works"
  9. 9. HOW #4 define context <?php use BehatMinkExtensionContextMinkContext; class TestGoogleContext extends MinkContext { /** * @Then /^I wait for the next step$/ */ public function iWaitForTheNextStep() { $this->getSession()->wait(1000); } }
  10. 10. HOW #5 vendor/bin/behat autoload read feature - compare with context
  11. 11. Hooks
  12. 12. Hooks
  13. 13. xpath ref: http://mink.behat.org/en/latest/guides/traversing-pages.html
  14. 14. Reference: http://docs.behat.org/en/v3.0/ https://mink.readthedocs.org/en/latest/ Demo code: https://github.com/nguyentienlong/demo-behat

×