-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbehatcli.feature
129 lines (111 loc) · 4.15 KB
/
behatcli.feature
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
@behatcli
Feature: Behat CLI context
Tests for BehatCliContext functionality that is used to test Behat Steps traits
by running Behat through CLI.
- Assert that BehatCliContext context itself can be bootstrapped by Behat,
including failed runs assertions.
- Assert that DrupalContext can be autoloaded by Behat and that DrupalContext
can bootstrap Drupal site.
- Assert that DrupalSteps trait can be autoloaded by Behat
Background:
Given a file named "features/bootstrap/FeatureContext.php" with:
"""
<?php
use Drupal\DrupalExtension\Context\DrupalContext;
use DrevOps\BehatSteps\PathTrait;
class FeatureContext extends DrupalContext {
use PathTrait;
/**
* @Given I throw test exception with message :message
*/
public function throwTestException($message) {
throw new \RuntimeException($message);
}
}
"""
And a file named "behat.yml" with:
"""
default:
suites:
default:
contexts:
- FeatureContext
- Drupal\DrupalExtension\Context\MinkContext
extensions:
Drupal\MinkExtension:
browserkit_http: ~
selenium2: ~
base_url: http://nginx:8080
Drupal\DrupalExtension:
api_driver: drupal
drupal:
drupal_root: /app/build/web
"""
Scenario: Test passes
Given a file named "features/drupal_bootstrap.feature" with:
"""
Feature: Homepage
@api
Scenario: Anonymous user visits homepage
Given I go to the homepage
And I should be in the "<front>" path
"""
When I run "behat --no-colors"
Then it should pass with:
"""
Feature: Homepage
@api
Scenario: Anonymous user visits homepage # features/drupal_bootstrap.feature:3
Given I go to the homepage # Drupal\DrupalExtension\Context\MinkContext::iAmOnHomepage()
And I should be in the "<front>" path # FeatureContext::pathAssertCurrent()
1 scenario (1 passed)
2 steps (2 passed)
"""
Scenario: Test fails
Given a file named "features/drupal_bootstrap.feature" with:
"""
Feature: Homepage
@api
Scenario: Anonymous user visits homepage
Given I go to the homepage
And I should be in the "nonexisting" path
"""
When I run "behat --no-colors"
Then it should fail with:
"""
Feature: Homepage
@api
Scenario: Anonymous user visits homepage # features/drupal_bootstrap.feature:3
Given I go to the homepage # Drupal\DrupalExtension\Context\MinkContext::iAmOnHomepage()
And I should be in the "nonexisting" path # FeatureContext::pathAssertCurrent()
Current path is "<front>", but expected is "nonexisting" (Exception)
--- Failed scenarios:
features/drupal_bootstrap.feature:3
1 scenario (1 failed)
2 steps (1 passed, 1 failed)
"""
Scenario: Test fails with exception
Given a file named "features/drupal_bootstrap.feature" with:
"""
Feature: Homepage
@api
Scenario: Anonymous user visits homepage
Given I go to the homepage
Then I throw test exception with message "Intentional error"
And I should be in the "nonexisting" path
"""
When I run "behat --no-colors"
Then it should fail with:
"""
Feature: Homepage
@api
Scenario: Anonymous user visits homepage # features/drupal_bootstrap.feature:3
Given I go to the homepage # Drupal\DrupalExtension\Context\MinkContext::iAmOnHomepage()
Then I throw test exception with message "Intentional error" # FeatureContext::throwTestException()
Intentional error (RuntimeException)
And I should be in the "nonexisting" path # FeatureContext::pathAssertCurrent()
--- Failed scenarios:
features/drupal_bootstrap.feature:3
1 scenario (1 failed)
3 steps (1 passed, 1 failed, 1 skipped)
"""