GithubHelp home page GithubHelp logo

behat / behat Goto Github PK

View Code? Open in Web Editor NEW
3.9K 3.9K 611.0 5.57 MB

BDD in PHP

Home Page: http://behat.org

License: MIT License

PHP 73.88% Gherkin 26.12%
bdd behat behavior-driven-development cucumber documentation-tool gherkin hacktoberfest php test-driven-development

behat's Introduction

Behat

Behat is a BDD framework for PHP to help you test business expectations.

Gitter chat License Build Status

Installing Behat

The easiest way to install Behat is by using Composer:

$> composer require --dev behat/behat

After that you'll be able to run Behat via:

$> vendor/bin/behat

Installing Development Version

Clone the repository and install dependencies via Composer:

$> composer install

After that you will be able to run development version of Behat via:

$> bin/behat

Contributing

Before contributing to Behat, please take a look at the CONTRIBUTING.md document.

Versioning

Starting from v3.0.0, Behat is following Semantic Versioning v2.0.0. This basically means that if all you do is implement interfaces (like this one) and use service constants (like this one), you would not have any backwards compatibility issues with Behat up until v4.0.0 (or later major) is released. Exception could be an extremely rare case where BC break is introduced as a measure to fix a serious issue.

You can read detailed guidance on what BC means in Symfony BC guide.

Useful Links

Contributors

behat's People

Contributors

benji07 avatar ciaranmcnulty avatar davedevelopment avatar davidgrayston avatar dmaicher avatar docteurklein avatar dvdoug avatar everzet avatar fgm avatar freecastle avatar glennmcewan avatar headrevision avatar jakzal avatar japicoder avatar jdeniau avatar muhqu avatar pamil avatar pfrenssen avatar phil-davis avatar robocoder avatar rpkamp avatar sam-burns avatar simonhammes avatar sky-glenjamin avatar slavcodev avatar snapshotpl avatar stloyd avatar stof avatar taluu avatar wouterj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

behat's Issues

New path loader doesn't seem to respect paths config

Sample below, this setup used to work on 1.1.0

/path/behat.yml

default:
    paths:
        features: '%%BEHAT_CONFIG_PATH%%/acceptance_tests/features'

/path/> behat -v

 [InvalidArgumentException]                     
 Path "/path/features" not found  

Exception trace:
 () at /usr/share/php/Behat/src/Behat/Behat/Console/Command/BehatCommand.php:261
 Behat\Behat\Console\Command\BehatCommand->execute() at /usr/share/php/Behat/vendor/Symfony/Component/Console/Command/Command.php:188
 Symfony\Component\Console\Command\Command->run() at /usr/share/php/Behat/vendor/Symfony/Component/Console/Application.php:193
 Symfony\Component\Console\Application->doRun() at /usr/share/php/Behat/vendor/Symfony/Component/Console/Application.php:119
 Symfony\Component\Console\Application->run() at /usr/share/php/Behat/bin/behat.php:30

Behat 1.1 will not install from pear channel

I believe there might be problems with the package.xml file.

"pear remote-list -c behat" shows 1.1.0
"pear upgrade behat/behat" nothing to update
"pear uninstall behat/behat && pear install behat/behat" shows 1.0.0 installed

Downloading the tar.gz from http://pear.behat.org/ and then running "pear install" installs 1.0.0

Allow to define in which browser types to run tests

It would be nice if you could define on a scenario basis which browser types to run the test in (if it's a test annotated with @javascript). Let's say I want to generally run all scenarios in chrome and firefox, but certain scenarios I only want to run in firefox.

Right now, it seems like I can only configure this globally, and only a single browser type.

Suite hooks don't work

the other hooks seem to work fine but beforeSuite and afterSuite give me an error

Uninitialized string offset: 1 in /usr/share/php/behat/src/Behat/Behat/Hook/HookDispatcher.php on line 202

Support testing for expected exceptions

For testing APIs in particular, it would be helpful to be able to test that a given action throws a particular exception.

For example, a scenario similar to this:

Scenario: Trying to access protected fields without authentication generates an exception
  Given I have a new API object
  Then I should catch an AccessDeniedException when I access the email property
  And the exception message should contain "foo"

The most obvious and reusable way to achieve this would be to chain a step from the "Then I should catch..." definition.

However, after playing around for a while, I can't see a way to implement this in the current architecture. Obviously the existing step chaining won't work because in that case the chained step would fail and so would the scenario. I thought about implementing a hook, but they seem to be able only to read the scenario/step results rather than being able to change them.

I think the best approach would be to support executing a substep directly within a FeatureContext - something like this:

   /**
     * @Then /^I should catch an ([a-zA-Z_]+) when (.+)$/
     */
    public function iShouldCatchAnException($exception_type, $when_step)
    {
        // Execute the action
                $step = new When($when_step);

                try
                {
                    // Execute Step
                }
                catch (\Exception $e)
                {
                   // Test for the expected type and store or rethrow
                }
    }

However, I don't think that's possible at present because the FeatureContext doesn't have a reference to either the StepTester or the DI container, so it's not even able to duplicate the StepTester logic as it can't access the definitions.

I'm not sure the best way to resolve this, but I don't think it's possible without changing the core to pass in one or other of those dependencies to the FeatureContext method somehow? I'm happy to have a go at doing so if you agree that this would be a useful scenario to be able to support?

Otherwise, I think the only option would be to specifically define individual steps, which is fairly brittle and would probably cause duplication especially since often you'll want to test that an exception is thrown from a method that you are anyway testing in non-exception use cases - it would be nice to be able to share that definition.

feature: Background Outline

Having a Background Outline to test different variations of a given action or state would be great, that way you could cut down on some of the duplication that needs to be done now since Background Outline doesn't exist.

Example:

Feature: Sessions
    In order to query the API
    As a user
    I need to have a valid session

    Scenario Outline: Session header is sent and has to be valid
        # Internal Fuel URI is not the public URI, but it's the only way to fake a URI in Fuel internally.
        When I do a request on "<Internal Fuel URI>" via "<HTTP Method>"
        Given a Session HREF of "<Session HREF>"
        Then hasValidSession Method should return "<hasValidSession Boolean>"

        Examples:
        | Internal Fuel URI             | HTTP Method   | Session HREF          | hasValidSession Boolean   |
        | /sessions/post_index          | POST          | /sessions/abcdef      | TRUE                      |
        | /sessions/get_index           | GET           | /sessions/abcdef      | TRUE                      |
        | /sessions/update_index        | UPDATE        | /sessions/abcdef      | TRUE                      |
        | /sessions/delete_index        | DELETE        | /sessions/abcdef      | TRUE                      |
        |                               |               | /sessions/zyxwvu      | FALSE                     |

Can be changed to:

Feature: Sessions
    In order to query the API
    As a user
    I need to have a valid session

    Background Outline:
        When I do a request on "<Internal Fuel URI>" via "<HTTP Method>"

        Examples:
        | Internal Fuel URI             | HTTP Method   |
        | /sessions/post_index          | POST          |
        | /sessions/get_index           | GET           |
        | /sessions/update_index        | UPDATE        |
        | /sessions/delete_index        | DELETE        |
        |                               |               |

    Scenario Outline: Session header is sent and has to be valid
        # Internal Fuel URI is not the public URI, but it's the only way to fake a URI in Fuel internally.
        When I do a request on "<Internal Fuel URI>" via "<HTTP Method>"
        Given a Session HREF of "<Session HREF>"
        Then hasValidSession Method should return "<hasValidSession Boolean>"

        Examples:
        | Session HREF          | hasValidSession Boolean   |
        | /sessions/abcdef      | TRUE                      |
        | /sessions/abcdef      | TRUE                      |
        | /sessions/abcdef      | TRUE                      |
        | /sessions/abcdef      | TRUE                      |
        | /sessions/zyxwvu      | FALSE                     | 

Each Background Example will run once before each Scenario/Scenario Outline.

P.S. There's a reason why I used When, Given, Then instead of Given, When, Then.

Proposed snippets use translated method names

Example FR feature:

# language: fr
Fonctionnalitรฉ: Compte en banque

  Scรฉnario: Ajout d'argent
        Etant donnรฉ que j'ai un compte en banque avec 0 โ‚ฌ
        Lorsque j'ajoute 35 โ‚ฌ sur mon compte en banque
        Alors j'ai 35 โ‚ฌ sur mon compte en banque

Output:

You can implement step definitions for undefined steps with these snippets:

$steps->Alors('/^j\'ai (\d+) โ‚ฌ sur mon compte en banque$/', function($world, $arg1) {
    throw new \Behat\Behat\Exception\Pending();
});

If you copy-paste that, it's of course a fatal error (undefined method "Alors"). So bad for such a nice feature ;)

I think the issue doesn't come from parser, as the test is properly executed when I copy-paste and replace "Alors" with "Then". Not identified exactly where it occurs yet, I'll pull request if I find it first.

rerun profiles

Having a rerun profile like cucumber would be massively useful

a few things need to happen to allow this:

  • multiple formatters where one outputs to console and other to --out
  • a rerun formatter that saves a rerun.txt with a list of files:scenarios to run
  • the ability to pass in multiple files:scenarios to run

Displaying scenarios that use an undefined step

Currently, Behat displays the code to create undefined steps (which is very cool) but it does not say in which scenerio they are used (forcing us to read the entire output to find it, and even worse for the progress formatter as it does not display the name at all). Adding the scenario using them would be a great add-on, especially when the undefined step is in fact a typo in a feature file.

Running scenarios and features in random order

Running them in random order greatly helps when your tests aren't isolated enough or you are not confident in it.
Ruby's MiniTest has such option (actually, it's a unit testing library, not BDD, but I don't see differences in this case). Take a look at the part Randomization.
Basically, when you run your tests, the runner will run them in random order and show you a seed - special number. If something fails, you can rerun tests in a particular order passing that seed number to the runner as an argument.
I think it will be great to have this feature in Behat.

Paths defined in config.yml are scalar

I am trying to add multiple step paths by editing the config.yml but it will not accept a list of paths as the config reader only accepts a scalar for the value (even though it is treated as an array internally)

I am trying to resurrect sfBehatPlugin and am having trouble telling it where both my step definitions are and the plugins step definitions.

scalarNode('steps')->
defaultValue('%behat.paths.base%/steps')->
end()->

Behat fails with an argument features/file:LINE_NUMBER

When running the mink demo, calling behat with a specific scenario to run fails:

$ behat features/search.feature:6



[RuntimeException]                                           
File "features/search.feature" not exist or is not readable  



behat [--init] [--usage] [--steps] [-c|--config="..."] [-p|--profile="..."] [--name="..."] [--tags="..."] [-f|--format="..."] [--out="..."] [--colors] [--no-colors] [--no-time] [--lang="..."] [--no-multiline] [--strict] [--rerun="..."] [features]

Seems to be related to issue #25 since adding the full path to the argument works:

$ behat `pwd`/features/search.feature:6
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               # features/search.feature:6
    Given I am on /wiki/Main_Page                              # /usr/local/zend/share/pear/mink/src/Behat/Mink/Integration/steps/mink_steps.php:15
    When I fill in "search" with "Behavior Driven Development" # /usr/local/zend/share/pear/mink/src/Behat/Mink/Integration/steps/mink_steps.php:31
    And I press "searchButton"                                 # /usr/local/zend/share/pear/mink/src/Behat/Mink/Integration/steps/mink_steps.php:23
    Then I should see "agile software development"             # /usr/local/zend/share/pear/mink/src/Behat/Mink/Integration/steps/mink_steps.php:62

    1 scenario (1 passed)
    4 steps (4 passed)
    0m1.038s

About "behat --definitions"

Hi,

why when I do "behat --definitions" I just find this below?

Given /^(?:there is )?a file named "([^"])" with:$/ - Creates a file with specified name and context in current workdir.
Given /^I am in the "([^"]
)" path$/ - Moves user to the specified path.
Given /^file "([^"])" should exist$/ - Checks whether a file at provided path exists.
When /^I run "behat ([^"]
)"$/ - Runs behat command with provided parameters
Then /^it should (fail|pass) with:$/ - Checks whether previously runned command passes|failes with provided output.
Then display last command output - Prints last command output string.
Then the output should contain: - Checks whether last command output contains provided string.
Then /^it should (fail|pass)$/ - Checks whether previously runned command failed|passed.

I expected more definitions.. as here are showed:

http://knplabs.com/en/blog/behat-2.0

behat 2.1.0

Regards

Javi

Javascript can't get text inputed by Sahi in an <input type="text">

Hello,

TL;DR : In a Behat+Mink (@javascript w/ Sahi) scenario, Sahi enter some text in an <input>, and the Javascript in the page isn't able to get what was entered by Sahi

Context

I'm building a little demo website, to show my team what Behat+Mink can do. There's a few pages, where one can input the size of a square and get the perimeter of this square.
One page is using plain old POST method, another page is using Javascript to calculate the perimeter

Url of the "JS page" : http://behatdemo.widop.com/js-square

To show my team that testing javascript is possible, I'm using Sahi as Mink driver, however it doesn't seems to work. I wrote a scenario where a user input 6 as the square side length, and get 24 as perimeter (link to file on github)

@javascript
Scenario: Inputting a valid side size
Given I am on "/js-square"
When I fill in "side" with "6"
And I press "Calculate"
And I wait for the result to appear
And I wait a little
Then I should see "Perimeter (using js): 24 cm"

Note: And I wait a little is a debug steps that waits 10 seconds, to be able to look at what is displayed on the Sahi firefox window

Problem

It seems that the snippet of javascript that calculate the perimeter isn't able to get the 6 inputed by Sahi. Here is the code (link to file on github)

Instead of having "Perimeter (using js): 24 cm", I get a "Perimeter (using js): Error cm".

(function($) {
  $('form').submit(function(e) {
    e.preventDefault();
    // #side is a <input type="text"> tag, where user input a square side length
    var side = parseFloat(jQuery('#side').val()) || NaN;
    var perimeter = side*4.0 || 'Error';
    $('#sidebar').text('Perimeter (using js): '+perimeter+ ' cm');
  });
})(jQuery);

Debug/Ideas

After some investigation, it turns out that jQuery('#side').val()returns an empty string, which is why I get a "Error" displayed, instead of the perimeter.
It seems that Javascript isn't able to get what was inputed by Sahi during the Scenario.

I'm pretty stuck on this one, I feel like I'm missing something.

Links :
Github project (with *.features): https://github.com/clemherreman/behatdemo
Live website: http://behatdemo.widop.com/js-square

Versions:

  • Behat: 2.1.2
  • Mink: 1.1.1
  • Sahi: 3.5
  • PHP: 5.3.6

Support PEAR package conventions

Consider moving of Behat source code to the top level of installation and renaming of package into "Behat".
Because some people prefer to autoload whole PEAR directory with PSR-0 autoloader.

Add Terminate hook to catch SIGINT and terminate browser properly

When I am running tests on a browser through Behat/Mink/Sahi, if I press CTRL+C during the Behat test, it would be nice if it were able to send a command to Sahi to correctly terminate the browser.

At the moment it only does this when the tests naturally conclude, not when a user unexpectedly terminates Behat.
I noticed this behaviour when testing with PhantomJS and hitting CTRL+C during the test left PhantomJS processes building up on the remote server.

Having discussed briefly with Konstantin, it sounds like the best approach is to create a Terminate hook which catches SIGINT, however this uses pcntl functions and would thus not be able to support Windows (Cygwin should be ok though?), but would be of benefit to everyone else.

No output

After execute behat no output is shown. That happed because EventDispatcher::addSubscriber call $subscriber->getSubscribedEvents() and it returns an 0-indexed array but EventDispatcher::addSubscriber uses it 0-key as $eventName, so , in dispatch, no listeners are found.

Make behat more analogue to phpunit

I'm just reading through the behat 2.0 docs, and got another feature request for you :)

If you take the following example:

<?php
/**
 * @Then /^I should get:$/
 */
public function iShouldGet(PyStringNode $string)
{
    if ((string) $string !== $this->output) {
        throw new Exception(
            "Actual output is:\n" . $this->output
        );
    }
}

I would suggest to make this more similar to phpunit:

<?php
/**
 * @Then /^I should get:$/
 */
public function iShouldGet(PyStringNode $string)
{
    $this->assertEquals($this->output, (string) $string);
}

or maybe just instead of throwing an exception, add a convenience method fail(). The main reasoning behind this is that people don't have to learn an entirely new API, but can re-use some of the methods that they already know from PHPUnit.

Passing a directory to behat doesn't work.

Behat version 1.0.0

- public
-- behat
--- features
---- steps
---- support

If I run behat from the behat directory with this command, the output is correct (running the tests).

behat -f progress -t ~@ignore

Now I try running this from the public directory and behat breaks

behat -f progress -t ~@ignore behat/

The error:

[InvalidArgumentException]                                                                  
The "/var/www/nolimits/public//var/www/nolimits/public/features" directory does not exist. 

Better step failure reporting

Steps that fail should show more detail. For example, if a step's method calls other context methods, it would be nice to have something like a stack trace showing the call stack. This will make it easier to debug failures that happen from step chains.

I'm not sure on the exact implementation, but anything would be better than how it works now :)

Selenium as default @javascript Driver

Is there a way to configure which driver is used when you have the @javascript tag before a scenario?

As of now, it seems that it defaults to Sahi if I don't explicably tag the scenario with @mink:selenium.

I tried looking at the behat.yml documentation but couldn't find anything about that there.

filters not working

I've just updated to behat v1.1 and am playing with the new profiles functionality

whilst I've got formatters in the profiles to work fine filters (neither tags or name) are working

Behat runs without error but the filters are not applied

behat --steps should lists the type of steps (Given, When, Then)

Having the type of each steps included when listing the known steps would be helpful in discovering existing steps made available through 3rd party extensions.

For example when using mink with behat, the list of steps provided by mink misses some information that needs to be looked up in the source code:

$ behat --steps       
'/^I should be redirected to "([^"]*)"$/'                                       

'/^(?:|I )am on (?P<page>.+)$/'                                                 

'/^(?:|I )go to (?P<page>.+)$/'                                                 

'/^(?:|I )press "(?P<button>[^"]*)"$/'                                          

[...]

JUnitFormatter depends of the locale conf

The time formatter use sprintf '%f' float format. Is it possible to change to %F (locale not aware)
in fr_FR.UTF8 the decimal_point is a comma, and Junit formatter need a point.

thanks

Update BehatBundle to support 2.2.0

after install behat 2.2.0 with pear always in my symfony project get this warning
PHP Fatal error: Class 'Behat\Behat\Console\Processor\RerunProcessor' not found

with the 2.1.3 version dont happens

i have
installed by pear

  • mink 1.2.0
  • gherking 1.1.3

installed by vendors install

  • BehatBundle
  • MinkBundle

Trying to use Mink

I've installed mink with pear, included the mink autoloader and added the mink/behat.yml to imports in my behat.yml file. When I run behat --steps, I don't get any extra steps

Extend MinkContext in Subcontexts classes

I get an error while having multiple extensions of subcontext and main context classes with minkcontext
is there a way to allow for extending minkcontext so to use the steps for interacting with forms, dom, etc?

Thanks

[bug] variable scope bug in BehatApplication.php

Hello!
I'm checking your work and i found something wrong.
In Behat\Behat\Console\BehatApplication

this class extends Symfony\Component\Console\Application and all its properties are private.
So into the renderException method you can't set to null the parent property "runningCommand" (and also create a public property of BehatApplication) and expects the parent::renderException use it. The parent::method will use its private property.

The console component is not easy to extends because of all this private properties

Impossible to modify scenarios in beforeFeature event

In a FeatureContext, if I create a "@beforeFeature" static method, i can't modify scenarios (add tag(s), by example) because in behat/src/Behat/Behat/Tester/FeatureTester.php file, scenarios was already get in a variable (line 75) and use later (line 80).

I think, you should do something like that:

if (count($feature->getScenarios())) {
    $this->dispatcher->dispatch(
        'beforeFeature', new FeatureEvent($feature, $this->parameters)
    );

    foreach ($feature->getScenarios() as $scenario) {
        ...
    }
}

How to autload Behat (instanciate a run from phar) ?

We used to do this with the former release of behat, to instanciate our own Behat runs :

require_once('phar://workspace/lib/vendor/behat.phar/autoload.php');
$app = new Behat\Behat\Console\BehatApplication('0');
$app->run(new Symfony\Component\Console\Input\ArrayInput($args));

We are doing this to have a better control of our pathes and behat options.

There is no autoload.php file anymore now, any idea how we can achieve that with the new release ?

Empty string in regex capture subpattern causes exception

Short version:

Uninitialized string offset: 0 in Behat/src/Behat/Behat/Formatter/HtmlFormatter.php at line 383

The recent fix to skip colouring of outline captures uses $match[0][0], however if the string is empty this raises a notice. Using substr($match, 0, 1) solves this problem.

Potential bug in hooks beforeFeature and afterFeature filtering parameter

I am trying to apply some hooks on a per-feature basis in the same way I do it succesfully on a per scenario basis.

It seems that, passing a filtering string as first argument of the beforeFeature and afterFeature methods, the filter does not apply at all, and the hook is applied to any runned feature, regardless of the passed filter.

HTML Formatter displays "Array" in each cell.

This is trivial, I can whip up a patch if you want, but it's basically this:

    foreach ($row as $column) {
        $this->writeln('<td>' . $row . '</td>');
    }

$row inside the loop should be $column. There's a case for calling the variable $cell, to be clearer.

Passing a relative filename to behat is broken if multiple feature files are defined

Trying to run behat with a relative filename on a directory with multiple feature files defined runs all the feature files:

For example, the mink demo application with the search feature split into to two files:

$ ls features/
search.feature  search2.feature  steps  support

$ cat features/search.feature 
Feature: Search
    In order to see a word definition
    As a website user
    I need to be able to search for a word

    @javascript
    Scenario: Searching for a page with autocompletion
        Given I am on /wiki/Main_Page
        When I fill in "search" with "Behavior Driv"
        And I wait for the suggestion box to appear
        Then I should see "Behavior Driven Development"

$ cat features/search2.feature 
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"

Running behat on search2.feature also run search.feature:

$ behat features/search2.feature
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               # features/search
2.feature:6                                                                     
    Given I am on /wiki/Main_Page                              # /usr/local/zend/share/pear/mink/src/Behat/Mink/Integration/steps/mink_steps.php:15
    When I fill in "search" with "Behavior Driven Development" # /usr/local/zend/share/pear/mink/src/Behat/Mink/Integration/steps/mink_steps.php:31
    And I press "searchButton"                                 # /usr/local/zend/share/pear/mink/src/Behat/Mink/Integration/steps/mink_steps.php:23
    Then I should see "agile software development"             # /usr/local/zend/share/pear/mink/src/Behat/Mink/Integration/steps/mink_steps.php:62

  Scenario: Searching for a page that does NOT exist           # features/search2.feature:12
    Given I am on /wiki/Main_Page                              # /usr/local/zend/share/pear/mink/src/Behat/Mink/Integration/steps/mink_steps.php:15
    When I fill in "search" with "Glory Driven Development"    # /usr/local/zend/share/pear/mink/src/Behat/Mink/Integration/steps/mink_steps.php:31
    And I press "searchButton"                                 # /usr/local/zend/share/pear/mink/src/Behat/Mink/Integration/steps/mink_steps.php:23
    Then I should see "Search results"                         # /usr/local/zend/share/pear/mink/src/Behat/Mink/Integration/steps/mink_steps.php:62

Feature: Search
  In order to see a word definition
  As a website user
  I need to be able to search for a word




  [Behat\SahiClient\Exception\ConnectionException]  
  Sahi proxy seems not running                      



behat [--init] [--usage] [--steps] [-c|--config="..."] [-p|--profile="..."] [--name="..."] [--tags="..."] [-f|--format="..."] [--out="..."] [--colors] [--no-colors] [--no-time] [--lang="..."] [--no-multiline] [--strict] [--rerun="..."] [features]

Seems to be related to issue #25 since passing a full path to behat leads to the correct behavior:



$ behat `pwd`/features/search2.feature  
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               # features/search2.feature:6
    Given I am on /wiki/Main_Page                              # /usr/local/zend/share/pear/mink/src/Behat/Mink/Integration/steps/mink_steps.php:15
    When I fill in "search" with "Behavior Driven Development" # /usr/local/zend/share/pear/mink/src/Behat/Mink/Integration/steps/mink_steps.php:31
    And I press "searchButton"                                 # /usr/local/zend/share/pear/mink/src/Behat/Mink/Integration/steps/mink_steps.php:23
    Then I should see "agile software development"             # /usr/local/zend/share/pear/mink/src/Behat/Mink/Integration/steps/mink_steps.php:62

  Scenario: Searching for a page that does NOT exist           # features/search2.feature:12
    Given I am on /wiki/Main_Page                              # /usr/local/zend/share/pear/mink/src/Behat/Mink/Integration/steps/mink_steps.php:15
    When I fill in "search" with "Glory Driven Development"    # /usr/local/zend/share/pear/mink/src/Behat/Mink/Integration/steps/mink_steps.php:31
    And I press "searchButton"                                 # /usr/local/zend/share/pear/mink/src/Behat/Mink/Integration/steps/mink_steps.php:23
    Then I should see "Search results"                         # /usr/local/zend/share/pear/mink/src/Behat/Mink/Integration/steps/mink_steps.php:62

2 scenarios (2 passed)
8 steps (8 passed)
0m2.002s

Option to show only snippets

Small feature request:

It would be good to have a CLI option to show only the step snippets (to save them in file), e.g.

behat --snippets-only >> FeatureContext.php

In the long run, generating context skeleton classes basing on templates (like in PHPUnit) would be very powerful.
Thanks for Behat, great tool.

Other languages does not work

Hi,

I just start using behat today, and tried it with the "pt" language. For what i read in doc's i have to change the "en" keywords for the specific language i want to use, but the problem is it throws an exception:

exception

[Behat\Gherkin\Exception\ParserException]                                                                 
Expected Feature token, but got Text on line: 1 in file: /www2/behatmink/features/ls.feature 

My code:

behat.yml

default:
    formatter:
        parameters:
            language: 'pt' 

features/ls.feature

Funcionalidade: ls
    Ver a estrutura de uma directoria
    Como um utilizador UNIX
    ร‰ preciso listar o conteudo da directoria

Cenario: Listar 2 ficheiros da directoria
    Dado Eu estar na directoria "test"
    E tenho o ficheiro "foo"
    E o ficheiro "bar"
    Quando corro "ls"
    Entao devo obter:
        """
        bar
        foo
        """

Note: It translates the "passed", "example" and this stuff the only thing doesn't work is the keywords translation

--dry-run option

Introduce new --dry-run option which will just print features and scenarios without executing steps code really.

Passing a directory, file or file:line_number to behat fails

With behat 1.1.4, trying to call behat with a directory, file or file:line_number fails:

$ pear version
PEAR Version: 1.9.2
PHP Version: 5.3.5
Zend Engine Version: 2.3.0
$ behat --version
Behat version 1.1.4


$ ls features/
sales_pages.feature  steps  support  template.feature.tpl

$ behat features/
No scenarios
No steps
0m0s
$ behat features/sales_pages.feature 
No scenarios
No steps
0m0s
$ behat features/sales_pages.feature:4



 [RuntimeException]                                                
 File "features/sales_pages.feature" not exist or is not readable  



behat [--init] [--usage] [--steps] [-c|--config="..."] [-p|--profile="..."] [--name="..."] [--tags="..."] [-f|--format="..."] [--out="..."] [--colors] [--no-colors] [--no-time] [--lang="..."] [--no-multiline] [--strict] [--rerun="..."] [features]

However calling behat without any argument works as expected:

$ behat
[...]
11 scenarios (5 passed, 6 failed)
33 steps (21 passed, 6 skipped, 6 failed)
0m2.06s

Cannot combine pretty and junit formatter

php behat.phar -f=pretty,junit --out=/home/somedir

outputs :
[Behat\Behat\Exception\FormatterException]
Filename expected as "output_path" parameter of "PrettyFormatter" formatter, but got: "/home/somedir"

php behat.phar -f=pretty,junit --out=/home/somefile.txt

outputs :
[Behat\Behat\Exception\FormatterException]
Directory path expected as "output_path" parameter of Behat\Behat\Formatter\JUnitFormatter, but got: /home/somefile.txt

It would be very convenient to use both formatter for Hudson integration, as we can have Hudson success/fail with "junit", and see exactly what happens in the console with "pretty"

Better notice descriptions

When writing a context function if you have a syntax error like for instance a typo, it would be really nice to see a slightly more descriptive notice.

For example while working on a scenario context I got the following error:

Notice: Undefined variable: typ

The issue was that my variable should have been named $type, but I mistakenly set it to $typ.

Behat is smart enough to know there was an issue in the scenario, it would be ideal to be able to get a more verbose detail. I know this may not be a viable goal, but in a complex scenario syntax function it could be difficult to find a non-descriptive error.

(If you close this due to it not being possible, no problem. It is just a suggestion.)

Allow altering the execution order of hooks

Currently, as far as I can tell, there is no way to specify where in the stack a hook should be inserted, and they are fired on a first-in, first-out basis. It would be helpful to be able to rearrange the order of hooks for events from within a context.

Sample use case:

  1. A feature suite uses Mink to do headless testing on a Symfony application
  2. A beforeScenario hook does some set-up on an in-memory database
  3. The hook injects the database connection into the service container of the kernel under test (otherwise the kernel would open its own connection, which would effectively be a new database)
  4. The hook is queued to run after Mink's prepareMinkSessions hook, so that the database connection can be injected after the session is initialised. Otherwise, Mink resets the session after our database set-up hook and the service container and its database connection are lost.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.