dalailomo / behato
Quick QA tool using behat
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/dalailomo/behato
Requires
- php: >=5.6
- behat/behat: ^3.3
- behat/mink-extension: ^2.2
- behat/mink-goutte-driver: ^1.2
- behat/mink-selenium2-driver: ^1.3
- devinci/devinci-behat-extension: dev-master
- react/child-process: dev-master
This package is not auto-updated.
Last update: 2025-10-16 02:38:14 UTC
README
Quick behavioural testing tool using behat and vvo/selenium-standalone.
Requirements
- PHP >= 5.6
- NodeJS >= 7.10
Installation
Create a composer.json file with the following:
{
"config": {
"bin-dir": "bin/"
},
"minimum-stability": "dev",
"require": {
"dalailomo/behato": "dev-master"
}
}
The require dependencies
$ composer install
Then, install the selenium server:
$ bin/installSeleniumStandalone
Create a config file called behat.yml in the root of your project with the following:
# behat.yml default: suites: default: contexts: - BaseContext - Devinci\DevinciExtension\Context\DebugContext: asset_dump_path: '<THE PATH YOU WANT TO DUMP ASSETS>' - Devinci\DevinciExtension\Context\JavascriptContext: maximum_wait: 30 extensions: Behat\MinkExtension: base_url: '<THE BASE URL YOU WANT>' browser_name: chrome sessions: default: #goutte: ~ selenium2: ~
Then run bin/behat --init
Testing example
Set the parameters in the config file
- Change the
asset_dump_pathkey to%paths.base%/asset(make sure you create a directory calledasseton the root path of your project). - Change the
base_urlkey tohttp://wikipedia.org
Create a feature file
Now, create a file features/search.feature on features folder (this has been created by running bin/behat --init).
Feature: Search In order to see a word definition As a website user I need to be able to search for a word Scenario: Searching for a page that does exist Given I am on "/wiki/Main_Page" When I fill in "search" with "Behavior Driven Development" And I press "searchButton" Then I should see "agile software development" Scenario: Searching for a page that does NOT exist Given I am on "/wiki/Main_Page" When I fill in "search" with "Glory Driven Development" And I press "searchButton" Then I should see "Search results"
Now, go to the file features/bootstrap/BaseContext.php and change the contents by the following:
<?php use Behat\MinkExtension\Context\MinkContext; /** * Defines application features from the specific context. */ class BaseContext extends MinkContext { /** * Initializes context. * * Every scenario gets its own context instance. * You can also pass arbitrary arguments to the * context constructor through behat.yml. */ public function __construct() { } }
Now, in a separate console, run the server:
$ bin/runServer
And run the test!
$ bin/behat
If a step fails, you will see a screenshot and a HTML dump of the failed step inside the
asset/folder. Pretty useful huh?