uuf6429 / behat-breakpoint
✋ Provides various ways to break/block scenarios.
v1.0.0
2018-10-28 01:03 UTC
Requires
- php: ^5.6 || ^7.0
- ext-json: *
- behat/behat: ^3.0
Requires (Dev)
- behat/mink-extension: ^2
- behat/mink-selenium2-driver: ^1.3
- crodas/phpunit-compat: ^1
- dg/bypass-finals: ^1.1
- phpdocumentor/reflection-docblock: ^3 || ^4
- phpunit/phpunit: ^5 || ^6 || ^7
- symfony/process: ^3.4
Suggests
- ext-xdebug: Required for Xdebug breakpoints.
This package is auto-updated.
Last update: 2024-11-29 05:03:55 UTC
README
✋ Provides various ways to break/block scenarios in Behat.
Installation
- Install with Composer in your Behat project:
composer require uuf6429/behat-breakpoint
- (Optionally) install the context (in your
behat.yml
) so you can use it in your tests:default: extensions: Behat\MinkExtension: # ... suites: default: paths: features: "%paths.base%/features/" contexts: - Behat\MinkExtension\Context\MinkContext # ... - uuf6429\BehatBreakpoint\Context # <-- just add this line # ...
Requirements
You can look at composer.json for the specifics, but PHP 5.6+ and Behat 3.0+ are always required. Additionally, each type of breakpoint has specific requirements:
AlertBreakpoint
: Requires instaclick/php-webdriver (which is a part of behat/mink-selenium2-driver).ConsoleBreakpoint
: None.PopupBreakpoint
: Requires behat/mink (which is a part of behat/mink-extension).XdebugBreakpoint
: Requires ext-xdebug to be installed and enabled.
None of the above packages are installed automatically; since someone may want to use the Xdebug extension without needing Mink (and vice-versa).
Usage
In Code
Construct the desired breakpoint from the ones listed below and trigger()
it.
- AlertBreakpoint - Shows a javascript alert in the specified browser session and waits until it is closed.
new \uuf6429\BehatBreakpoint\Breakpoint\AlertBreakpoint( \Session $session, // The WebDriver session to work with. string $message = NULL // (Optional) A message to show to the operator. )
- ConsoleBreakpoint - Displays a message in the current terminal and waits until [enter] is pressed.
new \uuf6429\BehatBreakpoint\Breakpoint\ConsoleBreakpoint( string $message = NULL, // (Optional) A message to show to the operator. null|resource $output = NULL, // (Optional) Output handle (defaults to PHP's STDOUT) null|resource $input = NULL // (Optional) Input handle (defaults to PHP's STDIN) )
- PopupBreakpoint - Displays a new window with some HTML and waits until it is closed by the user.
new \uuf6429\BehatBreakpoint\Breakpoint\PopupBreakpoint( \Session $session, // The Mink session to work with. It must support javascript. string $popupHtml, // The HTML of the popup page *body*. int $popupWidth = 500, // (Optional) The popup's default width. int $popupHeight = 300, // (Optional) The popup's default height. bool $popupIsScrollable = false, // (Optional) Enables scrollbars (and scrolling) within the popup. bool $popupIsResizeable = false // (Optional) Allows the popup to be resizeable. )
- XdebugBreakpoint - Pauses execution until a connected xdebug client resumes execution.
new \uuf6429\BehatBreakpoint\Breakpoint\XdebugBreakpoint()
In Gherkin
First add the context to your behat project config (behat.yml
) and then use any of the following steps in your feature files:
- Shows a javascript alert in the currently open page and pauses execution until it is closed.. Definition(s):
Given an alert breakpoint is triggered(?: with message "(?P<message>[^"]*)")? Then an alert breakpoint is triggered(?: with message "(?P<message>[^"]*)")? When an alert breakpoint is triggered(?: with message "(?P<message>[^"]*)")?
Example(s):Then a console breakpoint is triggered with message "Breakpoint reached! Press [OK] to continue..."
- Shows a message in the Behat console and waits for the user to press "enter" before continuing execution.. Definition(s):
Given a console breakpoint is triggered(?: with message "(?P<message>[^"]*)")? Then a console breakpoint is triggered(?: with message "(?P<message>[^"]*)")? When a console breakpoint is triggered(?: with message "(?P<message>[^"]*)")?
Example(s):Then a console breakpoint is triggered with message "Breakpoint reached! Press [Enter] to continue..."
- Shows a browser popup with some HTML and pauses execution until it is closed.. Definition(s):
Given a(?: (?P<width>\d+)x(?P<height>\d+))? popup breakpoint is triggered with the following content: Then a(?: (?P<width>\d+)x(?P<height>\d+))? popup breakpoint is triggered with the following content: When a(?: (?P<width>\d+)x(?P<height>\d+))? popup breakpoint is triggered with the following content:
Example(s):Then a 300x200 popup breakpoint is triggered with the following content: """ <h1>Hello world</h1> """
- Causes any connected xdebug session to break into a debugging session, pausing execution.. Definition(s):
Given an xdebug breakpoint is triggered Then an xdebug breakpoint is triggered When an xdebug breakpoint is triggered
Example(s):Then an xdebug breakpoint is triggered