最新服务器上的版本,以后用这个
wangzhenxin
2023-11-19 bc164b8bdbfbdf1d8229a5ced6b08d7cb8db7361
commit | author | age
2207d6 1 # Official Extensions
W 2
3 ## DotReporter
4
5 [See Source](https://github.com/Codeception/Codeception/blob/2.5/ext/DotReporter.php)
6
7 DotReporter provides less verbose output for test execution.
8 Like PHPUnit printer it prints dots "." for successful testes and "F" for failures.
9
10 ![](https://cloud.githubusercontent.com/assets/220264/26132800/4d23f336-3aab-11e7-81ba-2896a4c623d2.png)
11
12 ```bash
13  ..........
14  ..........
15  ..........
16  ..........
17  ..........
18  ..........
19  ..........
20  ..........
21
22 Time: 2.07 seconds, Memory: 20.00MB
23
24 OK (80 tests, 124 assertions)
25 ```
26
27
28 Enable this reporter with `--ext option`
29
30 ```
31 codecept run --ext DotReporter
32 ```
33
34 Failures and Errors are printed by a standard Codeception reporter.
35 Use this extension as an example for building custom reporters.
36
37
38
39 ## Logger
40
41 [See Source](https://github.com/Codeception/Codeception/blob/2.5/ext/Logger.php)
42
43 Log suites/tests/steps using Monolog library.
44 Monolog should be installed additionally by Composer.
45
46 ```
47 composer require monolog/monolog
48 ```
49
50 Steps are logged into `tests/_output/codeception.log`
51
52 To enable this module add to your `codeception.yml`:
53
54 ``` yaml
55 extensions:
56     enabled: [Codeception\Extension\Logger]
57 ```
58
59 #### Config
60
61 * `max_files` (default: 3) - how many log files to keep
62
63
64
65
66 ## Recorder
67
68 [See Source](https://github.com/Codeception/Codeception/blob/2.5/ext/Recorder.php)
69
70 Saves a screenshot of each step in acceptance tests and shows them as a slideshow on one HTML page (here's an [example](http://codeception.com/images/recorder.gif))
71 Activated only for suites with WebDriver module enabled.
72
73 The screenshots are saved to `tests/_output/record_*` directories, open `index.html` to see them as a slideshow.
74
75 #### Installation
76
77 Add this to the list of enabled extensions in `codeception.yml` or `acceptance.suite.yml`:
78
79 ``` yaml
80 extensions:
81     enabled:
82         - Codeception\Extension\Recorder
83 ```
84
85 #### Configuration
86
87 * `delete_successful` (default: true) - delete screenshots for successfully passed tests  (i.e. log only failed and errored tests).
88 * `module` (default: WebDriver) - which module for screenshots to use. Set `AngularJS` if you want to use it with AngularJS module. Generally, the module should implement `Codeception\Lib\Interfaces\ScreenshotSaver` interface.
89 * `ignore_steps` (default: []) - array of step names that should not be recorded (given the step passed), * wildcards supported.
90 * `success_color` (default: success) - bootstrap values to be used for color representation for passed tests
91 * `failure_color` (default: danger) - bootstrap values to be used for color representation for failed tests
92 * `error_color` (default: dark) - bootstrap values to be used for color representation for scenarios where there's an issue occurred while generating a recording
93 * `delete_orphaned` (default: false) - delete recording folders created via previous runs
94
95 #### Examples:
96
97 ``` yaml
98 extensions:
99     enabled:
100         - Codeception\Extension\Recorder:
101             module: AngularJS # enable for Angular
102             delete_successful: false # keep screenshots of successful tests
103             ignore_steps: [have, grab*]
104 ```
105
106
107
108
109 ## RunBefore
110
111 [See Source](https://github.com/Codeception/Codeception/blob/2.5/ext/RunBefore.php)
112
113 Extension for execution of some processes before running tests.
114
115 Processes can be independent and dependent.
116 Independent processes run independently of each other.
117 Dependent processes run sequentially one by one.
118
119 Can be configured in suite config:
120
121 ```yaml
122 # acceptance.suite.yml
123 extensions:
124     enabled:
125         - Codeception\Extension\RunBefore:
126             - independent_process_1
127             -
128                 - dependent_process_1_1
129                 - dependent_process_1_2
130             - independent_process_2
131             -
132                 - dependent_process_2_1
133                 - dependent_process_2_2
134 ```
135
136 HINT: you can use different configurations per environment.
137
138
139
140 ## RunFailed
141
142 [See Source](https://github.com/Codeception/Codeception/blob/2.5/ext/RunFailed.php)
143
144 Saves failed tests into tests/log/failed in order to rerun failed tests.
145
146 To rerun failed tests just run the `failed` group:
147
148 ```
149 php codecept run -g failed
150 ```
151
152 To change failed group name add:
153 ```
154 --override "extensions: config: Codeception\Extension\RunFailed: fail-group: another_group1"
155 ```
156 Remember: if you run tests and they generated custom-named fail group, to run this group, you should add override too
157
158 Starting from Codeception 2.1 **this extension is enabled by default**.
159
160 ``` yaml
161 extensions:
162     enabled: [Codeception\Extension\RunFailed]
163 ```
164
165 On each execution failed tests are logged and saved into `tests/_output/failed` file.
166
167
168
169 ## RunProcess
170
171 [See Source](https://github.com/Codeception/Codeception/blob/2.5/ext/RunProcess.php)
172
173 Extension to start and stop processes per suite.
174 Can be used to start/stop selenium server, chromedriver, phantomjs, mailcatcher, etc.
175
176 Can be configured in suite config:
177
178 ```yaml
179 # acceptance.suite.yml
180 extensions:
181     enabled:
182         - Codeception\Extension\RunProcess:
183             - chromedriver
184 ```
185
186 Multiple parameters can be passed as array:
187
188 ```yaml
189 # acceptance.suite.yml
190
191 extensions:
192     enabled:
193         - Codeception\Extension\RunProcess:
194             - php -S 127.0.0.1:8000 -t tests/data/app
195             - java -jar ~/selenium-server.jar
196 ```
197
198 In the end of a suite all launched processes will be stopped.
199
200 To wait for the process to be launched use `sleep` option.
201 In this case you need configuration to be specified as object:
202
203 ```yaml
204 extensions:
205     enabled:
206         - Codeception\Extension\RunProcess:
207             0: java -jar ~/selenium-server.jar
208             1: mailcatcher
209             sleep: 5 # wait 5 seconds for processes to boot
210 ```
211
212 HINT: you can use different configurations per environment.
213
214
215
216 ## SimpleReporter
217
218 [See Source](https://github.com/Codeception/Codeception/blob/2.5/ext/SimpleReporter.php)
219
220 This extension demonstrates how you can implement console output of your own.
221 Recommended to be used for development purposes only.
222
223
224