forked from Codeception/Codeception
/
ExtensionsCest.php
140 lines (124 loc) · 5.59 KB
/
ExtensionsCest.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
<?php
class ExtensionsCest
{
// tests
public function useAlternativeFormatter(CliGuy $I)
{
$I->wantTo('use alternative formatter delivered through extensions');
$I->amInPath('tests/data/sandbox');
$I->executeCommand('run tests/dummy/FileExistsCept.php -c codeception_extended.yml');
$I->dontSeeInShellOutput("Check config");
$I->seeInShellOutput('[+] FileExistsCept');
$I->seeInShellOutput('Modules used: Filesystem, DumbHelper');
}
public function loadExtensionByOverride(CliGuy $I)
{
$I->amInPath('tests/data/sandbox');
$I->executeCommand('run tests/dummy/FileExistsCept.php -o "extensions: enabled: [\Codeception\Extension\SimpleReporter]"');
$I->dontSeeInShellOutput("Check config");
$I->seeInShellOutput('[+] FileExistsCept');
}
public function dynamicallyEnablingExtensions(CliGuy $I)
{
$I->amInPath('tests/data/sandbox');
$I->executeCommand('run dummy --ext DotReporter');
$I->seeInShellOutput('......');
$I->dontSeeInShellOutput('Optimistic');
$I->dontSeeInShellOutput('AnotherCest');
}
public function reRunFailedTests(CliGuy $I)
{
$ds = DIRECTORY_SEPARATOR;
$I->amInPath('tests/data/sandbox');
$I->executeCommand('run unit FailingTest.php -c codeception_extended.yml --no-exit');
$I->seeInShellOutput('FAILURES');
$I->seeFileFound('failed', 'tests/_output');
$I->seeFileContentsEqual("tests{$ds}unit{$ds}FailingTest.php:testMe");
$I->executeCommand('run -g failed -c codeception_extended.yml --no-exit');
$I->seeInShellOutput('Tests: 1, Assertions: 1, Failures: 1');
$failGroup = "some-failed";
$I->executeCommand("run unit FailingTest.php -c codeception_extended.yml --no-exit --override \"extensions: config: Codeception\\Extension\\RunFailed: fail-group: {$failGroup}\"");
$I->seeInShellOutput('FAILURES');
$I->seeFileFound($failGroup, 'tests/_output');
$I->seeFileContentsEqual("tests{$ds}unit{$ds}FailingTest.php:testMe");
$I->executeCommand("run -g {$failGroup} -c codeception_extended.yml --no-exit --override \"extensions: config: Codeception\\Extension\\RunFailed: fail-group: {$failGroup}\"");
$I->seeInShellOutput('Tests: 1, Assertions: 1, Failures: 1');
}
public function checkIfExtensionsReceiveCorrectOptions(CliGuy $I)
{
$I->wantTo('check if extensions receive correct options');
$I->amInPath('tests/data/sandbox');
$I->executeCommand('run tests/dummy/AnotherCest.php:optimistic -c codeception_extended.yml');
$I->seeInShellOutput('Low verbosity');
$I->executeCommand('run tests/dummy/AnotherCest.php:optimistic -c codeception_extended.yml -v');
$I->seeInShellOutput('Medium verbosity');
$I->executeCommand('run tests/dummy/AnotherCest.php:optimistic -c codeception_extended.yml -vv');
$I->seeInShellOutput('High verbosity');
$I->executeCommand('run tests/dummy/AnotherCest.php:optimistic -c codeception_extended.yml -vvv');
$I->seeInShellOutput('Extreme verbosity');
}
public function runPerSuiteExtensions(CliGuy $I)
{
$I->amInPath('tests/data/sandbox');
$I->executeCommand('run extended,scenario', false);
$I->seeInShellOutput('Suite setup for extended');
$I->seeInShellOutput('Test setup for Hello');
$I->seeInShellOutput('Test teardown for Hello');
$I->seeInShellOutput('Suite teardown for extended');
$I->dontSeeInShellOutput('Suite setup for scenario');
$I->seeInShellOutput('Config1: value1');
$I->seeInShellOutput('Config2: value2');
}
public function runPerSuiteExtensionsInEnvironment(CliGuy $I)
{
$I->amInPath('tests/data/sandbox');
$I->executeCommand('run extended --env black', false);
$I->seeInShellOutput('Suite setup for extended');
$I->seeInShellOutput('Test setup for Hello');
$I->seeInShellOutput('Config1: black_value');
$I->seeInShellOutput('Config2: value2');
}
/**
* @param CliGuy $I
*/
public function runtimeExtensionsWorkWithIncludedSuitesPresentInTheConfigAndRunningARootSuite(CliGuy $I)
{
$I->amInPath('tests/data/included');
// unit is a root suite.
$I->executeCommand('run unit --ext DotReporter');
$I->seeInShellOutput('.');
$I->dontSeeInShellOutput('RootApplicationUnitTest:');
}
/**
* @param CliGuy $I
*/
public function runtimeExtensionsWorkWhenRunningWildCardSuites(CliGuy $I)
{
$I->amInPath('tests/data/included');
$I->executeCommand('run *::unit --ext DotReporter');
$I->seeInShellOutput('..');
$I->dontSeeInShellOutput('SimpleTest: Simple:');
}
/**
* @param CliGuy $I
*/
public function runtimeExtensionsWorkWhenRunningWildCardSuitesAndRoot(CliGuy $I)
{
$I->amInPath('tests/data/included');
$I->executeCommand('run unit,*::unit --ext DotReporter');
$I->seeInShellOutput('..');
$I->dontSeeInShellOutput('SimpleTest: Simple:');
$I->dontSeeInShellOutput('RootApplicationUnitTest:');
}
/**
* @param CliGuy $I
*/
public function runtimeExtensionsWorkWhenRunningTestsFromAnIncludedConfig(CliGuy $I)
{
$I->amInPath('tests/data/included');
$ds = DIRECTORY_SEPARATOR;
$I->executeCommand("run jazz{$ds}tests{$ds}functional{$ds}DemoCept.php --ext DotReporter", false);
$I->seeInShellOutput('.');
$I->dontSeeInShellOutput('DemoCept:');
}
}