Repository navigation
Expand file tree
/
Copy pathRunCest.php
More file actions
311 lines (281 loc) · 9.44 KB
/
Copy pathRunCest.php
File metadata and controls
311 lines (281 loc) · 9.44 KB
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
<?php
class RunCest
{
public function _before(\CliGuy $I)
{
$I->amInPath('tests/data/sandbox');
}
public function runOneFile(\CliGuy $I)
{
$I->wantTo('execute one test');
$I->executeCommand('run tests/dummy/FileExistsCept.php');
$I->seeInShellOutput("OK (");
}
/**
* @group reports
* @group core
*
* @param CliGuy $I
*/
public function runHtml(\CliGuy $I)
{
$I->wantTo('execute tests with html output');
$I->executeCommand('run dummy --html');
$I->seeFileFound('report.html', 'tests/_output');
}
/**
* @group reports
*
* @param CliGuy $I
*/
public function runJsonReport(\CliGuy $I)
{
$I->wantTo('check json reports');
$I->executeCommand('run dummy --json');
$I->seeFileFound('report.json', 'tests/_output');
$I->seeInThisFile('"suite":');
$I->seeInThisFile('"dummy"');
}
/**
* @group reports
*
* @param CliGuy $I
*/
public function runTapReport(\CliGuy $I)
{
$I->wantTo('check tap reports');
$I->executeCommand('run dummy --tap');
$I->seeFileFound('report.tap.log', 'tests/_output');
}
/**
* @group reports
*
* @param CliGuy $I
*/
public function runXmlReport(\CliGuy $I)
{
$I->wantTo('check xml reports');
$I->executeCommand('run dummy --xml');
$I->seeFileFound('report.xml', 'tests/_output');
$I->seeInThisFile('<?xml');
$I->seeInThisFile('<testsuite name="dummy"');
$I->seeInThisFile('<testcase name="FileExists"');
$I->seeInThisFile('feature="');
}
/**
* @group reports
* @param CliGuy $I
*/
public function runXmlReportsInStrictMode(\CliGuy $I)
{
$I->wantTo('check xml in strict mode');
$I->executeCommand('run dummy --xml -c codeception_strict_xml.yml');
$I->seeFileFound('report.xml', 'tests/_output');
$I->seeInThisFile('<?xml');
$I->seeInThisFile('<testsuite name="dummy"');
$I->seeInThisFile('<testcase name="FileExists"');
$I->dontSeeInThisFile('feature="');
}
/**
* @group reports
*
* @param CliGuy $I
*/
public function runReportMode(\CliGuy $I)
{
$I->wantTo('try the reporting mode');
$I->executeCommand('run dummy --report');
$I->seeInShellOutput('FileExistsCept');
$I->seeInShellOutput('........Ok');
}
/**
* @group reports
*
* @param CliGuy $I
*/
public function runCustomReport(\CliGuy $I)
{
$I->wantTo('try the reporting mode');
$I->executeCommand('run dummy --report -c codeception_custom_report.yml');
$I->seeInShellOutput('✔ check config exists (FileExistsCept)');
$I->dontSeeInShellOutput('Ok');
}
public function runOneGroup(\CliGuy $I)
{
$I->executeCommand('run skipped -g notorun');
$I->seeInShellOutput("IncompleteMeCept");
$I->dontSeeInShellOutput("SkipMeCept");
}
public function skipRunOneGroup(\CliGuy $I)
{
$I->executeCommand('run skipped --skip-group notorun');
$I->seeInShellOutput("SkipMeCept");
$I->dontSeeInShellOutput("IncompleteMeCept");
}
public function skipGroupOfCest(\CliGuy $I)
{
$I->executeCommand('run dummy');
$I->seeInShellOutput('optimistic');
$I->executeCommand('run dummy --skip-group ok');
$I->seeInShellOutput('pessimistic');
$I->dontSeeInShellOutput('optimistic');
}
public function runTwoSuites(\CliGuy $I)
{
$I->executeCommand('run skipped,dummy --no-exit');
$I->seeInShellOutput("Skipped Tests");
$I->seeInShellOutput("Dummy Tests");
$I->dontSeeInShellOutput("Remote Tests");
}
public function skipSuites(\CliGuy $I)
{
$I->executeCommand(
'run dummy --skip skipped --skip remote --skip remote_server --skip order --skip unit --skip powers --skip math --skip messages'
);
$I->seeInShellOutput("Dummy Tests");
$I->dontSeeInShellOutput("Remote Tests");
$I->dontSeeInShellOutput("Remote_server Tests");
$I->dontSeeInShellOutput("Order Tests");
}
public function runOneTestFromUnit(\CliGuy $I)
{
$I->executeCommand('run tests/dummy/AnotherTest.php:testFirst');
$I->seeShellOutputMatches("~AnotherTest:testFirst\s*?Ok~");
$I->dontSeeInShellOutput('AnotherTest:testSecond');
}
public function runOneTestFromCest(\CliGuy $I)
{
$I->executeCommand('run tests/dummy/AnotherCest.php:optimistic');
$I->seeShellOutputMatches("~\(AnotherCest:optimistic\)\s*?Ok~");
$I->dontSeeInShellOutput('AnotherCest:pessimistic');
}
public function runTestWithDataProviders(\CliGuy $I)
{
$I->executeCommand('run tests/unit/DataProvidersTest.php');
$I->seeInShellOutput(
'Test is triangle | "real triangle" (DataProvidersTest:testIsTriangle)'
);
$I->seeInShellOutput('Test is triangle | #0 (DataProvidersTest:testIsTriangle)');
$I->seeInShellOutput('Test is triangle | #1 (DataProvidersTest:testIsTriangle)');
$I->seeInShellOutput("OK");
}
public function runTestWithFailFast(\CliGuy $I)
{
$I->executeCommand('run unit --skip-group error --no-exit');
$I->seeInShellOutput('FailingTest:testMe');
$I->seeInShellOutput("PassingTest:testMe");
$I->executeCommand('run unit --fail-fast --skip-group error --no-exit');
$I->seeInShellOutput('There was 1 failure');
$I->dontSeeInShellOutput("PassingTest:testMe");
}
public function runWithCustomOuptutPath(\CliGuy $I)
{
$I->executeCommand('run dummy --xml myverycustom.xml --html myownhtmlreport.html');
$I->seeFileFound('myverycustom.xml', 'tests/_output');
$I->seeInThisFile('<?xml');
$I->seeInThisFile('<testsuite name="dummy"');
$I->seeInThisFile('<testcase name="FileExists"');
$I->seeFileFound('myownhtmlreport.html', 'tests/_output');
$I->dontSeeFileFound('report.xml','tests/_output');
$I->dontSeeFileFound('report.html','tests/_output');
}
public function runTestsWithDependencyInjections(\CliGuy $I)
{
$I->executeCommand('run math');
$I->seeInShellOutput('Test addition (MathCest:testAddition)');
$I->seeInShellOutput('Test subtraction (MathCest:testSubtraction)');
$I->seeInShellOutput('Test square (MathCest:testSquare)');
$I->seeInShellOutput('Test all (MathTest:testAll)');
$I->seeInShellOutput('OK (');
$I->dontSeeInShellOutput('fail');
$I->dontSeeInShellOutput('error');
}
public function runErrorTest(\CliGuy $I)
{
$I->executeCommand('run unit ErrorTest --no-exit');
$I->seeInShellOutput('There was 1 error');
$I->seeInShellOutput('Array to string conversion');
$I->seeInShellOutput('ErrorTest.php:9');
}
public function runTestWithException(\CliGuy $I)
{
$I->executeCommand('run unit ExceptionTest --no-exit -v');
$I->seeInShellOutput('There was 1 error');
$I->seeInShellOutput('Helllo!');
$I->expect('Exceptions are not wrapped into ExceptionWrapper');
$I->dontSeeInShellOutput('PHPUnit_Framework_ExceptionWrapper');
$I->seeInShellOutput('RuntimeException');
}
public function runTestsWithSteps(\CliGuy $I)
{
$I->executeCommand('run scenario SuccessCept --steps');
$I->seeInShellOutput(<<<EOF
Scenario:
* I am in path "."
* I see file found "scenario.suite.yml"
PASSED
EOF
);
}
/**
* @param CliGuy $I
*/
public function runTestWithFailedScenario(\CliGuy $I, $scenario)
{
if (!extension_loaded('xdebug') && !defined('HHVM_VERSION')) {
$scenario->skip("Xdebug not loaded");
}
$I->executeCommand('run scenario FailedCept --steps --no-exit');
$I->seeInShellOutput(<<<EOF
Fail when file is not found (FailedCept)
Scenario:
* I am in path "."
* I see file found "games.zip"
FAIL
EOF
);
$I->expect('to see scenario trace');
$I->seeInShellOutput(<<<EOF
Scenario Steps:
2. \$I->seeFileFound("games.zip") at tests/scenario/FailedCept.php:5
1. \$I->amInPath(".") at tests/scenario/FailedCept.php:4
EOF
);
}
/**
* @param CliGuy $I
*/
public function runTestWithSubSteps(\CliGuy $I, $scenario)
{
if (!extension_loaded('xdebug') && !defined('HHVM_VERSION')) {
$scenario->skip("Xdebug not loaded");
}
$file = "codeception".DIRECTORY_SEPARATOR."c3";
$I->executeCommand('run scenario SubStepsCept --steps');
$I->seeInShellOutput(<<<EOF
Scenario:
* I am in path "."
* I see code coverage files are present
EOF
);
// I split this assertion into two, because extra space is printed after "present" on HHVM
$I->seeInShellOutput(<<<EOF
I see file found "c3.php"
I see file found "composer.json"
I see in this file "$file"
EOF
);
}
public function runDependentCest(CliGuy $I)
{
$I->executeCommand('run order DependentCest --no-exit');
$I->seeInShellOutput('Skipped: 1');
}
public function runDependentTest(CliGuy $I)
{
$I->executeCommand('run unit DependsTest --no-exit');
$I->seeInShellOutput('Skipped: 1');
$I->executeCommand('run unit --no-exit');
$I->seeInShellOutput('Skipped: 2');
}
}