forked from Codeception/Codeception
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRunCest.php
More file actions
149 lines (135 loc) · 4.46 KB
/
Copy pathRunCest.php
File metadata and controls
149 lines (135 loc) · 4.46 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
<?php
use Codeception\Event\TestEvent;
class RunCest
{
public function _before(TestEvent $t)
{
if (floatval(phpversion()) == '5.3') {
$t->getTest()->getScenario()->skip();
}
}
public function runOneFile(\CliGuy $I)
{
$I->wantTo('execute one test');
$I->amInPath('tests/data/sandbox');
$I->executeCommand('run tests/dummy/FileExistsCept.php');
$I->seeInShellOutput("OK (");
}
/**
* @group reports
*
* @param CliGuy $I
*/
public function runHtml(\CliGuy $I)
{
$I->wantTo('execute tests with html output');
$I->amInPath('tests/data/sandbox');
$I->executeCommand('run dummy --html');
$I->seeFileFound('report.html', 'tests/_log');
}
/**
* @group reports
*
* @param CliGuy $I
*/
public function runJsonReport(\CliGuy $I)
{
$I->wantTo('check json reports');
$I->amInPath('tests/data/sandbox');
$I->executeCommand('run dummy --json');
$I->seeFileFound('report.json', 'tests/_log');
$I->seeInThisFile('"suite":');
$I->seeInThisFile('"dummy"');
}
/**
* @group reports
*
* @param CliGuy $I
*/
public function runTapReport(\CliGuy $I)
{
$I->wantTo('check tap reports');
$I->amInPath('tests/data/sandbox');
$I->executeCommand('run dummy --tap');
$I->seeFileFound('report.tap.log', 'tests/_log');
}
/**
* @group reports
*
* @param CliGuy $I
*/
public function runXmlReport(\CliGuy $I)
{
$I->wantTo('check xml reports');
$I->amInPath('tests/data/sandbox');
$I->executeCommand('run dummy --xml');
$I->seeFileFound('report.xml', 'tests/_log');
$I->seeInThisFile('<?xml');
$I->seeInThisFile('<testsuite name="dummy"');
$I->seeInThisFile('<testcase file="FileExistsCept.php"');
}
/**
* @group reports
*
* @param CliGuy $I
*/
public function runReportMode(\CliGuy $I)
{
$I->wantTo('try the reporting mode');
$I->amInPath('tests/data/sandbox');
$I->executeCommand('run dummy --report');
$I->seeInShellOutput('FileExistsCept.php');
$I->seeInShellOutput('........Ok');
}
public function runOneGroup(\CliGuy $I)
{
$I->amInPath('tests/data/sandbox');
$I->executeCommand('run skipped -g notorun');
$I->seeInShellOutput("IncompleteMeCept.php");
$I->dontSeeInShellOutput("SkipMeCept.php");
}
public function runTwoSuites(\CliGuy $I)
{
$I->amInPath('tests/data/sandbox');
$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->amInPath('tests/data/sandbox');
$I->executeCommand(
'run --skip skipped --skip remote --skip remote_server --skip order --skip unit --skip powers'
);
$I->seeInShellOutput("Dummy Tests");
$I->dontSeeInShellOutput("Remote Tests");
$I->dontSeeInShellOutput("Remote_server Tests");
$I->dontSeeInShellOutput("Order Tests");
}
public function runOneTestFromUnit(\CliGuy $I)
{
$I->amInPath('tests/data/sandbox');
$I->executeCommand('run tests/dummy/AnotherTest.php:testFirst');
$I->seeShellOutputMatches("~Running AnotherTest::testFirst\s*?Ok~");
$I->dontSeeInShellOutput('AnotherTest::testSecond');
}
public function runOneTestFromCest(\CliGuy $I)
{
$I->amInPath('tests/data/sandbox');
$I->executeCommand('run tests/dummy/AnotherCest.php:optimistic');
$I->seeShellOutputMatches("~\(AnotherCest.optimistic\)\s*?Ok~");
$I->dontSeeInShellOutput('AnotherCest.pessimistic');
}
public function runTestWithDataProviders(\CliGuy $I)
{
$I->amInPath('tests/data/sandbox');
$I->executeCommand('run tests/unit/DataProvidersTest.php');
$I->seeInShellOutput(
'Trying to test is triangle with data set "real triangle" (DataProvidersTest::testIsTriangle)'
);
$I->seeInShellOutput('Trying to test is triangle with data set #0 (DataProvidersTest::testIsTriangle)');
$I->seeInShellOutput('Trying to test is triangle with data set #1 (DataProvidersTest::testIsTriangle)');
$I->seeInShellOutput("OK");
}
}