-
Notifications
You must be signed in to change notification settings - Fork 112
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove dependency on PHPUnit #38
Open
thewilkybarkid
wants to merge
1
commit into
Behat:master
Choose a base branch
from
thewilkybarkid:assertions
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,193 @@ | ||
Feature: Feature failures | ||
In order to resolve problems easily | ||
As a WebApi feature tester | ||
I want clear error messages | ||
|
||
Background: | ||
Given a file named "behat.yml" with: | ||
""" | ||
default: | ||
formatters: | ||
progress: ~ | ||
extensions: | ||
Behat\WebApiExtension: | ||
base_url: http://localhost:8080/ | ||
|
||
suites: | ||
default: | ||
contexts: ['Behat\WebApiExtension\Context\WebApiContext'] | ||
""" | ||
|
||
Scenario: Response code | ||
Given a file named "features/authentication.feature" with: | ||
""" | ||
Feature: Accessing an invalid url | ||
In order to known about my mistakes | ||
As an API client | ||
I should receive an error response | ||
|
||
Scenario: | ||
When I send a GET request to "/404" | ||
Then the response code should be 200 | ||
""" | ||
When I run "behat features/authentication.feature" | ||
Then it should fail with: | ||
""" | ||
.F | ||
|
||
--- Failed steps: | ||
|
||
Then the response code should be 200 # features/authentication.feature:8 | ||
The response code was 404, not 200 (Behat\WebApiExtension\Context\ExpectationException) | ||
|
||
1 scenario (1 failed) | ||
2 steps (1 passed, 1 failed) | ||
""" | ||
|
||
Scenario: Response contains | ||
Given a file named "features/headers.feature" with: | ||
""" | ||
Feature: Exercise WebApiContext Set Header | ||
In order to validate the set_header step | ||
As a context developer | ||
I need to be able to add headers in a scenario before sending a request | ||
|
||
Scenario: | ||
When I send a GET request to "echo" | ||
Then the response should contain "foo" | ||
""" | ||
When I run "behat features/headers.feature" | ||
Then it should fail with: | ||
""" | ||
.F | ||
|
||
--- Failed steps: | ||
|
||
Then the response should contain "foo" # features/headers.feature:8 | ||
Response body does not contain the specified text (Behat\WebApiExtension\Context\ExpectationException) | ||
|
||
1 scenario (1 failed) | ||
2 steps (1 passed, 1 failed) | ||
""" | ||
|
||
Scenario: Response does not contain | ||
Given a file named "features/headers.feature" with: | ||
""" | ||
Feature: Exercise WebApiContext Set Header | ||
In order to validate the set_header step | ||
As a context developer | ||
I need to be able to add headers in a scenario before sending a request | ||
|
||
Scenario: | ||
Given I set header "foo" with value "bar" | ||
When I send a GET request to "echo" | ||
Then the response should not contain "foo" | ||
""" | ||
When I run "behat features/headers.feature" | ||
Then it should fail with: | ||
""" | ||
..F | ||
|
||
--- Failed steps: | ||
|
||
Then the response should not contain "foo" # features/headers.feature:9 | ||
Response body contains the specified text (Behat\WebApiExtension\Context\ExpectationException) | ||
|
||
1 scenario (1 failed) | ||
3 steps (2 passed, 1 failed) | ||
""" | ||
|
||
Scenario: Response contains JSON (invalid JSON) | ||
Given a file named "features/headers.feature" with: | ||
""" | ||
Feature: Exercise WebApiContext Set Header | ||
In order to validate the set_header step | ||
As a context developer | ||
I need to be able to add headers in a scenario before sending a request | ||
|
||
Scenario: | ||
When I send a GET request to "echo" | ||
And the response should contain json: | ||
''' | ||
foo | ||
''' | ||
""" | ||
When I run "behat features/headers.feature" | ||
Then it should fail with: | ||
""" | ||
.F | ||
|
||
--- Failed steps: | ||
|
||
And the response should contain json: # features/headers.feature:8 | ||
Can not convert etalon to json: | ||
foo (LogicException) | ||
|
||
1 scenario (1 failed) | ||
2 steps (1 passed, 1 failed) | ||
""" | ||
|
||
Scenario: Response contains JSON (missing key) | ||
Given a file named "features/headers.feature" with: | ||
""" | ||
Feature: Exercise WebApiContext Set Header | ||
In order to validate the set_header step | ||
As a context developer | ||
I need to be able to add headers in a scenario before sending a request | ||
|
||
Scenario: | ||
When I send a GET request to "echo" | ||
And the response should contain json: | ||
''' | ||
{ | ||
"foo" : "bar" | ||
} | ||
''' | ||
""" | ||
When I run "behat features/headers.feature" | ||
Then it should fail with: | ||
""" | ||
.F | ||
|
||
--- Failed steps: | ||
|
||
And the response should contain json: # features/headers.feature:8 | ||
Does not contain the key "foo" (Behat\WebApiExtension\Context\ExpectationException) | ||
|
||
1 scenario (1 failed) | ||
2 steps (1 passed, 1 failed) | ||
""" | ||
|
||
Scenario: Response contains JSON | ||
Given a file named "features/headers.feature" with: | ||
""" | ||
Feature: Exercise WebApiContext Set Header | ||
In order to validate the set_header step | ||
As a context developer | ||
I need to be able to add headers in a scenario before sending a request | ||
|
||
Scenario: | ||
When I send a POST request to "echo" with form data: | ||
''' | ||
foo=bar | ||
''' | ||
And the response should contain json: | ||
''' | ||
{ | ||
"foo" : "baz" | ||
} | ||
''' | ||
""" | ||
When I run "behat features/headers.feature" | ||
Then it should fail with: | ||
""" | ||
.F | ||
|
||
--- Failed steps: | ||
|
||
And the response should contain json: # features/headers.feature:11 | ||
Value for the key "foo" does not match (Behat\WebApiExtension\Context\ExpectationException) | ||
|
||
1 scenario (1 failed) | ||
2 steps (1 passed, 1 failed) | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Behat WebApiExtension. | ||
* (c) Konstantin Kudryashov <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Behat\WebApiExtension\Context; | ||
|
||
class ExpectationException extends \RuntimeException | ||
{ | ||
/** | ||
* Initializes exception. | ||
* | ||
* @param string $message Message. | ||
* @param \Exception $exception Expectation exception. | ||
*/ | ||
public function __construct($message = '', \Exception $exception = null) | ||
{ | ||
parent::__construct($message, 0, $exception); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is there a dev depending on it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't removed assertions from
features/bootstrap/FeatureContext.php
, though they would be simple to replace.