/
IncludedCest.php
185 lines (162 loc) · 5.78 KB
/
IncludedCest.php
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
<?php
class IncludedCest
{
public function _before()
{
$logDir = codecept_root_dir('tests/data/included/_log');
\Codeception\Util\FileSystem::doEmptyDir($logDir);
}
/**
* @param CliGuy $I
*/
protected function moveToIncluded(\CliGuy $I)
{
$I->amInPath('tests/data/included');
}
/**
* @before moveToIncluded
* @param CliGuy $I
*/
public function runSuitesFromIncludedConfigs(\CliGuy $I)
{
$I->executeCommand('run');
$I->seeInShellOutput('[Jazz]');
$I->seeInShellOutput('Jazz.functional Tests');
$I->seeInShellOutput('[Jazz\Pianist]');
$I->seeInShellOutput('Jazz\Pianist.functional Tests');
$I->seeInShellOutput('[Shire]');
$I->seeInShellOutput('Shire.functional Tests');
}
/**
* @before moveToIncluded
* @param CliGuy $I
*/
public function runTestsFromIncludedConfigs(\CliGuy $I)
{
$ds = DIRECTORY_SEPARATOR;
$I->executeCommand("run jazz{$ds}tests{$ds}functional{$ds}DemoCept.php", false);
// Suite is not run
$I->dontSeeInShellOutput('[Jazz]');
// DemoCept tests are run
$I->seeInShellOutput('Jazz.functional Tests');
$I->seeInShellOutput('DemoCept');
// Other include tests are not run
$I->dontSeeInShellOutput('[Shire]');
$I->dontSeeInShellOutput('Shire.functional Tests');
$I->dontSeeInShellOutput('[Jazz\Pianist]');
$I->dontSeeInShellOutput('Jazz\Pianist.functional Tests');
}
/**
* @before moveToIncluded
* @param CliGuy $I
*/
public function runTestsFromIncludedConfigsNested(\CliGuy $I)
{
$I->executeCommand('run jazz/pianist/tests/functional/PianistCept.php', false);
// Suite is not run
$I->dontSeeInShellOutput('[Jazz\Pianist]');
// DemoCept tests are run
$I->seeInShellOutput('Jazz\Pianist.functional Tests');
$I->seeInShellOutput('PianistCept');
// Other include tests are not run
$I->dontSeeInShellOutput('[Shire]');
$I->dontSeeInShellOutput('Shire.functional Tests');
$I->dontSeeInShellOutput('[Jazz]');
$I->dontSeeInShellOutput('Jazz.functional Tests');
}
/**
* @before moveToIncluded
* @param CliGuy $I
*/
public function runTestsFromIncludedConfigsSingleTest(\CliGuy $I)
{
$ds = DIRECTORY_SEPARATOR;
$I->executeCommand("run jazz{$ds}tests{$ds}unit{$ds}SimpleTest.php:testSimple", false);
// Suite is not run
$I->dontSeeInShellOutput('[Jazz]');
// SimpleTest:testSimple is run
$I->seeInShellOutput('Jazz.unit Tests');
$I->dontSeeInShellOutput('Jazz.functional Tests');
$I->seeInShellOutput('SimpleTest');
// SimpleTest:testSimpler is not run
$I->dontSeeInShellOutput('SimplerTest');
// Other include tests are not run
$I->dontSeeInShellOutput('[Shire]');
$I->dontSeeInShellOutput('Shire.functional Tests');
$I->dontSeeInShellOutput('[Jazz\Pianist]');
$I->dontSeeInShellOutput('Jazz\Pianist.functional Tests');
}
/**
* @before moveToIncluded
* @param CliGuy $I
*/
public function runIncludedWithXmlOutput(\CliGuy $I)
{
$I->executeCommand('run --xml');
$I->amInPath('_log');
$I->seeFileFound('report.xml');
$I->seeInThisFile('<testsuite name="Jazz.functional" tests="1" assertions="1"');
$I->seeInThisFile('<testsuite name="Jazz\Pianist.functional" tests="1" assertions="1"');
$I->seeInThisFile('<testsuite name="Shire.functional" tests="1" assertions="1"');
$I->seeInThisFile('<testcase name="Hobbit"');
$I->seeInThisFile('<testcase name="Demo"');
$I->seeInThisFile('<testcase name="Pianist"');
}
/**
* @before moveToIncluded
* @param CliGuy $I
*/
public function runIncludedWithHtmlOutput(\CliGuy $I)
{
$I->executeCommand('run --html');
$I->amInPath('_log');
$I->seeFileFound('report.html');
$I->seeInThisFile('Codeception Results');
$I->seeInThisFile('Jazz.functional Tests');
$I->seeInThisFile('Check that jazz musicians can add numbers');
$I->seeInThisFile('Jazz\Pianist.functional Tests');
$I->seeInThisFile('Check that jazz pianists can add numbers');
$I->seeInThisFile('Shire.functional Tests');
}
/**
* @before moveToIncluded
* @group coverage
* @param CliGuy $I
*/
public function runIncludedWithCoverage(\CliGuy $I)
{
$I->executeCommand('run --coverage-xml');
$I->amInPath('_log');
$I->seeFileFound('coverage.xml');
//these assertions shrank over the years to be compatible with many versions of php-code-coverage library
$I->seeInThisFile('BillEvans" namespace="');
$I->seeInThisFile('Musician" namespace="');
$I->seeInThisFile('Hobbit" namespace="');
}
/**
* @before moveToIncluded
* @param CliGuy $I
*/
public function buildIncluded(\CliGuy $I)
{
$I->executeCommand('build');
$I->seeInShellOutput('generated successfully');
$I->seeInShellOutput('Jazz\\TestGuy');
$I->seeInShellOutput('Jazz\\Pianist\\TestGuy');
$I->seeInShellOutput('Shire\\TestGuy');
}
/**
* @before moveToIncluded
* @param CliGuy $I
*/
public function cleanIncluded(\CliGuy $I)
{
$ds = DIRECTORY_SEPARATOR;
$I->executeCommand('clean');
$I->seeInShellOutput("included{$ds}_log");
$I->seeInShellOutput("included{$ds}jazz{$ds}tests/_log");
$I->seeInShellOutput("included{$ds}jazz{$ds}pianist{$ds}tests/_log");
$I->seeInShellOutput("included{$ds}shire{$ds}tests/_log");
$I->seeInShellOutput('Done');
}
}