RunCest.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604
  1. <?php
  2. class RunCest
  3. {
  4. public function _before(\CliGuy $I)
  5. {
  6. $I->amInPath('tests/data/sandbox');
  7. }
  8. public function runOneFile(\CliGuy $I)
  9. {
  10. $I->wantTo('execute one test');
  11. $I->executeCommand('run tests/dummy/FileExistsCept.php');
  12. $I->seeInShellOutput("OK (");
  13. }
  14. public function runOneFileWithColors(\CliGuy $I)
  15. {
  16. $I->wantTo('execute one test');
  17. $I->executeCommand('run --colors tests/dummy/FileExistsCept.php');
  18. $I->seeInShellOutput("OK (");
  19. $I->seeInShellOutput("\033[35;1mFileExistsCept:\033[39;22m Check config exists");
  20. }
  21. /**
  22. * @group reports
  23. * @group core
  24. *
  25. * @param CliGuy $I
  26. */
  27. public function runHtml(\CliGuy $I)
  28. {
  29. $I->wantTo('execute tests with html output');
  30. $I->executeCommand('run dummy --html');
  31. $I->seeFileFound('report.html', 'tests/_output');
  32. }
  33. /**
  34. * @group reports
  35. *
  36. * @param CliGuy $I
  37. */
  38. public function runJsonReport(\CliGuy $I)
  39. {
  40. $I->wantTo('check json reports');
  41. $I->executeCommand('run dummy --json');
  42. $I->seeFileFound('report.json', 'tests/_output');
  43. $I->seeInThisFile('"suite":');
  44. $I->seeInThisFile('"dummy"');
  45. $I->assertNotNull(json_decode(file_get_contents('tests/_output/report.json')));
  46. }
  47. /**
  48. * @group reports
  49. *
  50. * @param CliGuy $I
  51. */
  52. public function runTapReport(\CliGuy $I)
  53. {
  54. $I->wantTo('check tap reports');
  55. $I->executeCommand('run dummy --tap');
  56. $I->seeFileFound('report.tap.log', 'tests/_output');
  57. }
  58. /**
  59. * @group reports
  60. *
  61. * @param CliGuy $I
  62. */
  63. public function runXmlReport(\CliGuy $I)
  64. {
  65. $I->wantTo('check xml reports');
  66. $I->executeCommand('run dummy --xml');
  67. $I->seeFileFound('report.xml', 'tests/_output');
  68. $I->seeInThisFile('<?xml');
  69. $I->seeInThisFile('<testsuite name="dummy"');
  70. $I->seeInThisFile('<testcase name="FileExists"');
  71. $I->seeInThisFile('feature="');
  72. }
  73. /**
  74. * @group reports
  75. * @param CliGuy $I
  76. */
  77. public function runXmlReportsInStrictMode(\CliGuy $I)
  78. {
  79. $I->wantTo('check xml in strict mode');
  80. $I->executeCommand('run dummy --xml -c codeception_strict_xml.yml');
  81. $I->seeFileFound('report.xml', 'tests/_output');
  82. $I->seeInThisFile('<?xml');
  83. $I->seeInThisFile('<testsuite name="dummy"');
  84. $I->seeInThisFile('<testcase name="FileExists"');
  85. $I->dontSeeInThisFile('feature="');
  86. }
  87. /**
  88. * @group reports
  89. *
  90. * @param CliGuy $I
  91. */
  92. public function runPhpUnitXmlReport(\CliGuy $I)
  93. {
  94. $I->wantTo('check phpunit xml reports');
  95. $I->executeCommand('run dummy --phpunit-xml');
  96. $I->seeInShellOutput('PHPUNIT-XML report generated in');
  97. $I->seeFileFound('phpunit-report.xml', 'tests/_output');
  98. $I->seeInThisFile('<?xml');
  99. if (\PHPUnit\Runner\Version::series() < 6) {
  100. $I->seeInThisFile('<testsuite name="dummy" tests="6" assertions="3" failures="0" errors="0" time=');
  101. } else {
  102. $I->seeInThisFile('<testsuite name="dummy" tests="6" assertions="3" errors="0" failures="0" skipped="0" time=');
  103. }
  104. $I->seeThisFileMatches('/<testsuite name="AnotherCest" file=".*?AnotherCest.php"/');
  105. $I->seeThisFileMatches('/<testsuite name="AnotherTest" file=".*?AnotherTest.php"/');
  106. if (\PHPUnit\Runner\Version::series() < 6) {
  107. $I->seeThisFileMatches('/<testsuite name="AnotherTest" file=".*?AnotherTest.php" tests="2" assertions="2" failures="0" errors="0" time=/');
  108. } else {
  109. $I->seeThisFileMatches('/<testsuite name="AnotherTest" file=".*?AnotherTest.php" tests="2" assertions="2" errors="0" failures="0" skipped="0" time=/');
  110. }
  111. //FileExistsCept file
  112. $I->seeInThisFile('<testsuite name="FileExists"');
  113. $I->seeInThisFile('<testcase name="FileExists"');
  114. $I->seeInThisFile('feature="');
  115. }
  116. /**
  117. * @group reports
  118. * @param CliGuy $I
  119. */
  120. public function runPhpUnitXmlReportsInStrictMode(\CliGuy $I)
  121. {
  122. $I->wantTo('check phpunit xml in strict mode');
  123. $I->executeCommand('run dummy --phpunit-xml -c codeception_strict_xml.yml');
  124. $I->seeInShellOutput('PHPUNIT-XML report generated in');
  125. $I->seeFileFound('phpunit-report.xml', 'tests/_output');
  126. $I->seeInThisFile('<?xml');
  127. if (\PHPUnit\Runner\Version::series() < 6) {
  128. $I->seeInThisFile('<testsuite name="dummy" tests="6" assertions="3" failures="0" errors="0" time=');
  129. } else {
  130. $I->seeInThisFile('<testsuite name="dummy" tests="6" assertions="3" errors="0" failures="0" skipped="0" time=');
  131. }
  132. $I->seeThisFileMatches('/<testsuite name="AnotherCest" file=".*?AnotherCest.php"/');
  133. $I->seeThisFileMatches('/<testsuite name="AnotherTest" file=".*?AnotherTest.php"/');
  134. if (\PHPUnit\Runner\Version::series() < 6) {
  135. $I->seeThisFileMatches('/<testsuite name="AnotherTest" file=".*?AnotherTest.php" tests="2" assertions="2" failures="0" errors="0" time=/');
  136. } else {
  137. $I->seeThisFileMatches('/<testsuite name="AnotherTest" file=".*?AnotherTest.php" tests="2" assertions="2" errors="0" failures="0" skipped="0" time=/');
  138. }
  139. //FileExistsCept file
  140. $I->seeInThisFile('<testsuite name="FileExists"');
  141. $I->seeInThisFile('<testcase name="FileExists"');
  142. $I->dontSeeInThisFile('feature="');
  143. }
  144. /**
  145. * @group reports
  146. *
  147. * @param CliGuy $I
  148. */
  149. public function runCustomReport(\CliGuy $I)
  150. {
  151. if (\PHPUnit\Runner\Version::series() >= 7) {
  152. throw new \Codeception\Exception\Skip('Not for PHPUnit 7');
  153. }
  154. $I->executeCommand('run dummy --report -c codeception_custom_report.yml');
  155. $I->seeInShellOutput('FileExistsCept: Check config exists');
  156. $I->dontSeeInShellOutput('Ok');
  157. }
  158. public function runOneGroup(\CliGuy $I)
  159. {
  160. $I->executeCommand('run skipped -g notorun');
  161. $I->seeInShellOutput('Skipped Tests (1)');
  162. $I->seeInShellOutput("IncompleteMeCept");
  163. $I->dontSeeInShellOutput("SkipMeCept");
  164. }
  165. public function skipRunOneGroup(\CliGuy $I)
  166. {
  167. $I->executeCommand('run skipped --skip-group notorun');
  168. $I->seeInShellOutput('Skipped Tests (2)');
  169. $I->seeInShellOutput("SkipMeCept");
  170. $I->dontSeeInShellOutput("IncompleteMeCept");
  171. }
  172. public function skipGroupOfCest(\CliGuy $I)
  173. {
  174. $I->executeCommand('run dummy');
  175. $I->seeInShellOutput('Optimistic');
  176. $I->seeInShellOutput('Dummy Tests (6)');
  177. $I->executeCommand('run dummy --skip-group ok');
  178. $I->seeInShellOutput('Pessimistic');
  179. $I->seeInShellOutput('Dummy Tests (5)');
  180. $I->dontSeeInShellOutput('Optimistic');
  181. }
  182. public function runTwoSuites(\CliGuy $I)
  183. {
  184. $I->executeCommand('run skipped,dummy --no-exit');
  185. $I->seeInShellOutput("Skipped Tests (3)");
  186. $I->seeInShellOutput("Dummy Tests (6)");
  187. $I->dontSeeInShellOutput("Remote Tests");
  188. }
  189. public function skipSuites(\CliGuy $I)
  190. {
  191. $I->executeCommand(
  192. 'run dummy --skip skipped --skip remote --skip remote_server --skip order --skip unit '
  193. . '--skip powers --skip math --skip messages'
  194. );
  195. $I->seeInShellOutput("Dummy Tests");
  196. $I->dontSeeInShellOutput("Remote Tests");
  197. $I->dontSeeInShellOutput("Remote_server Tests");
  198. $I->dontSeeInShellOutput("Order Tests");
  199. }
  200. public function runOneTestFromUnit(\CliGuy $I)
  201. {
  202. $I->executeCommand('run tests/dummy/AnotherTest.php:testFirst');
  203. $I->seeInShellOutput("AnotherTest: First");
  204. $I->seeInShellOutput('OK');
  205. $I->dontSeeInShellOutput('AnotherTest: Second');
  206. }
  207. public function runOneTestFromCest(\CliGuy $I)
  208. {
  209. $I->executeCommand('run tests/dummy/AnotherCest.php:optimistic');
  210. $I->seeInShellOutput("Optimistic");
  211. $I->dontSeeInShellOutput('Pessimistic');
  212. }
  213. public function runTestWithDataProviders(\CliGuy $I)
  214. {
  215. $I->executeCommand('run tests/unit/DataProvidersTest.php');
  216. $I->seeInShellOutput('Is triangle | "real triangle"');
  217. $I->seeInShellOutput('Is triangle | #0');
  218. $I->seeInShellOutput('Is triangle | #1');
  219. $I->seeInShellOutput('DataProvidersTest');
  220. $I->seeInShellOutput("OK");
  221. }
  222. public function runOneGroupWithDataProviders(\CliGuy $I)
  223. {
  224. $I->executeCommand('run unit -g data-providers');
  225. $I->seeInShellOutput('Is triangle | "real triangle"');
  226. $I->seeInShellOutput('Is triangle | #0');
  227. $I->seeInShellOutput('Is triangle | #1');
  228. $I->seeInShellOutput('DataProvidersTest');
  229. $I->seeInShellOutput("OK");
  230. }
  231. public function runTestWithFailFast(\CliGuy $I)
  232. {
  233. $I->executeCommand('run unit --skip-group error --no-exit');
  234. $I->seeInShellOutput('FailingTest: Me');
  235. $I->seeInShellOutput("PassingTest: Me");
  236. $I->executeCommand('run unit --fail-fast --skip-group error --no-exit');
  237. $I->seeInShellOutput('There was 1 failure');
  238. $I->dontSeeInShellOutput("PassingTest: Me");
  239. }
  240. public function runWithCustomOutputPath(\CliGuy $I)
  241. {
  242. $I->executeCommand('run dummy --xml myverycustom.xml --html myownhtmlreport.html');
  243. $I->seeFileFound('myverycustom.xml', 'tests/_output');
  244. $I->seeInThisFile('<?xml');
  245. $I->seeInThisFile('<testsuite name="dummy"');
  246. $I->seeInThisFile('<testcase name="FileExists"');
  247. $I->seeFileFound('myownhtmlreport.html', 'tests/_output');
  248. $I->dontSeeFileFound('report.xml', 'tests/_output');
  249. $I->dontSeeFileFound('report.html', 'tests/_output');
  250. }
  251. public function runTestsWithDependencyInjections(\CliGuy $I)
  252. {
  253. $I->executeCommand('run math');
  254. $I->seeInShellOutput('MathCest: Test addition');
  255. $I->seeInShellOutput('MathCest: Test subtraction');
  256. $I->seeInShellOutput('MathCest: Test square');
  257. $I->seeInShellOutput('MathTest: All');
  258. $I->seeInShellOutput('OK (');
  259. $I->dontSeeInShellOutput('fail');
  260. $I->dontSeeInShellOutput('error');
  261. }
  262. public function runErrorTest(\CliGuy $I)
  263. {
  264. $I->executeCommand('run unit ErrorTest --no-exit');
  265. $I->seeInShellOutput('There was 1 error');
  266. $I->seeInShellOutput('Array to string conversion');
  267. $I->seeInShellOutput('ErrorTest.php');
  268. }
  269. public function runTestWithException(\CliGuy $I)
  270. {
  271. $I->executeCommand('run unit ExceptionTest --no-exit -v');
  272. $I->seeInShellOutput('There was 1 error');
  273. $I->seeInShellOutput('Helllo!');
  274. $I->expect('Exceptions are not wrapped into ExceptionWrapper');
  275. $I->dontSeeInShellOutput('PHPUnit_Framework_ExceptionWrapper');
  276. $I->seeInShellOutput('RuntimeException');
  277. }
  278. public function runTestsWithSteps(\CliGuy $I)
  279. {
  280. $I->executeCommand('run scenario SuccessCept --steps');
  281. $I->seeInShellOutput(<<<EOF
  282. Scenario --
  283. I am in path "."
  284. I see file found "scenario.suite.yml"
  285. PASSED
  286. EOF
  287. );
  288. }
  289. /**
  290. * @param CliGuy $I
  291. */
  292. public function runTestWithFailedScenario(\CliGuy $I, $scenario)
  293. {
  294. if (!extension_loaded('xdebug') && !defined('HHVM_VERSION')) {
  295. $scenario->skip("Xdebug not loaded");
  296. }
  297. $I->executeCommand('run scenario FailedCept --steps --no-exit');
  298. $I->seeInShellOutput(<<<EOF
  299. FailedCept: Fail when file is not found
  300. Signature: FailedCept
  301. Test: tests/scenario/FailedCept.php
  302. Scenario --
  303. I am in path "."
  304. I see file found "games.zip"
  305. FAIL
  306. EOF
  307. );
  308. $I->expect('to see scenario trace');
  309. $I->seeInShellOutput(<<<EOF
  310. Scenario Steps:
  311. 2. \$I->seeFileFound("games.zip") at tests/scenario/FailedCept.php:5
  312. 1. \$I->amInPath(".") at tests/scenario/FailedCept.php:4
  313. EOF
  314. );
  315. }
  316. /**
  317. * @param CliGuy $I
  318. */
  319. public function runTestWithSubSteps(\CliGuy $I, $scenario)
  320. {
  321. if (!extension_loaded('xdebug') && !defined('HHVM_VERSION')) {
  322. $scenario->skip("Xdebug not loaded");
  323. }
  324. $file = "codeception" . DIRECTORY_SEPARATOR . "c3";
  325. $I->executeCommand('run scenario SubStepsCept --steps');
  326. $I->seeInShellOutput(<<<EOF
  327. Scenario --
  328. I am in path "."
  329. I see code coverage files are present
  330. EOF
  331. );
  332. // I split this assertion into two, because extra space is printed after "present" on HHVM
  333. $I->seeInShellOutput(<<<EOF
  334. I see file found "c3.php"
  335. I see file found "composer.json"
  336. I see in this file "$file"
  337. EOF
  338. );
  339. }
  340. public function runDependentCest(CliGuy $I)
  341. {
  342. $I->executeCommand('run order DependentCest --no-exit');
  343. $I->seeInShellOutput('Skipped: 1');
  344. }
  345. public function runDependentTest(CliGuy $I)
  346. {
  347. $I->executeCommand('run unit DependsTest --no-exit');
  348. $I->seeInShellOutput('Skipped: 1');
  349. $I->executeCommand('run unit --no-exit');
  350. if (version_compare(\PHPUnit\Runner\Version::id(), '7.5.5', '<')) {
  351. $I->seeInShellOutput('Skipped: 2');
  352. } else {
  353. //one test fails with Warning instead of Skipped with PHPUnit >= 7.5.5
  354. $I->seeInShellOutput('Skipped: 1');
  355. }
  356. }
  357. public function runGherkinTest(CliGuy $I)
  358. {
  359. $I->executeCommand('run scenario File.feature --steps');
  360. $I->seeInShellOutput(<<<EOF
  361. In order to test a feature
  362. As a user
  363. I need to be able to see output
  364. EOF
  365. );
  366. $I->seeInShellOutput('Given i have terminal opened');
  367. $I->seeInShellOutput('When i am in current directory');
  368. $I->seeInShellOutput('Then there is a file "scenario.suite.yml"');
  369. $I->seeInShellOutput('And there are keywords in "scenario.suite.yml"');
  370. $I->seeInShellOutput(<<<EOF
  371. | class_name | ScenarioGuy |
  372. | enabled | Filesystem |
  373. EOF
  374. );
  375. $I->seeInShellOutput('PASSED');
  376. }
  377. public function reportsCorrectFailedStep(CliGuy $I)
  378. {
  379. $I->executeCommand('run scenario File.feature -v');
  380. $I->seeInShellOutput('OK, but incomplete');
  381. $I->seeInShellOutput('Step definition for `I have only idea of what\'s going on here` not found in contexts');
  382. }
  383. public function runFailingGherkinTest(CliGuy $I)
  384. {
  385. $I->executeCommand('run scenario Fail.feature -v --no-exit');
  386. $I->seeInShellOutput('Step I see file "games.zip"');
  387. $I->seeInShellOutput('Step I see file "tools.zip"');
  388. }
  389. public function runGherkinScenarioWithMultipleStepDefinitions(CliGuy $I)
  390. {
  391. $I->executeCommand('run scenario "File.feature:Check file once more" --steps');
  392. $I->seeInShellOutput('When there is a file "scenario.suite.yml"');
  393. $I->seeInShellOutput('Then i see file "scenario.suite.yml"');
  394. $I->dontSeeInShellOutput('Step definition for `I see file "scenario.suite.yml"` not found in contexts');
  395. $I->seeInShellOutput('PASSED');
  396. }
  397. public function runGherkinScenarioOutline(CliGuy $I)
  398. {
  399. $I->executeCommand('run scenario FileExamples.feature -v');
  400. $I->seeInShellOutput('OK (3 tests');
  401. }
  402. /**
  403. * @param CliGuy $I
  404. * @after checkExampleFiles
  405. */
  406. public function runTestWithAnnotationExamples(CliGuy $I)
  407. {
  408. $I->executeCommand('run scenario ExamplesCest:filesExistsAnnotation --steps');
  409. }
  410. /**
  411. * @param CliGuy $I
  412. * @after checkExampleFiles
  413. */
  414. public function runTestWithJsonExamples(CliGuy $I)
  415. {
  416. $I->executeCommand('run scenario ExamplesCest:filesExistsByJson --steps');
  417. }
  418. /**
  419. * @param CliGuy $I
  420. * @after checkExampleFiles
  421. */
  422. public function runTestWithArrayExamples(CliGuy $I)
  423. {
  424. $I->executeCommand('run scenario ExamplesCest:filesExistsByArray --steps');
  425. }
  426. protected function checkExampleFiles(CliGuy $I)
  427. {
  428. $I->seeInShellOutput('OK (3 tests');
  429. $I->seeInShellOutput('I see file found "scenario.suite.yml"');
  430. $I->seeInShellOutput('I see file found "dummy.suite.yml"');
  431. $I->seeInShellOutput('I see file found "unit.suite.yml"');
  432. }
  433. public function runTestWithComplexExample(CliGuy $I)
  434. {
  435. $I->executeCommand('run scenario ExamplesCest:filesExistsComplexJson --debug');
  436. $I->seeInShellOutput('Files exists complex json | {"path":"."');
  437. $I->seeInShellOutput('OK (1 test');
  438. $I->seeInShellOutput('I see file found "scenario.suite.yml"');
  439. $I->seeInShellOutput('I see file found "dummy.suite.yml"');
  440. $I->seeInShellOutput('I see file found "unit.suite.yml"');
  441. }
  442. public function overrideConfigOptionsToChangeReporter(CliGuy $I)
  443. {
  444. if (!class_exists('PHPUnit_Util_Log_TeamCity')) {
  445. throw new \Codeception\Exception\Skip('Reporter does not exist for this PHPUnit version');
  446. }
  447. $I->executeCommand('run scenario --report -o "reporters: report: PHPUnit_Util_Log_TeamCity" --no-exit');
  448. $I->seeInShellOutput('##teamcity[testStarted');
  449. $I->dontSeeInShellOutput('............Ok');
  450. }
  451. public function overrideModuleOptions(CliGuy $I)
  452. {
  453. $I->executeCommand('run powers PowerIsRisingCept --no-exit');
  454. $I->seeInShellOutput('FAILURES');
  455. $I->executeCommand('run powers PowerIsRisingCept -o "modules: config: PowerHelper: has_power: true" --no-exit');
  456. $I->dontSeeInShellOutput('FAILURES');
  457. }
  458. public function runTestWithAnnotationExamplesFromGroupFileTest(CliGuy $I)
  459. {
  460. $I->executeCommand('run scenario -g groupFileTest1 --steps');
  461. $I->seeInShellOutput('OK (3 tests');
  462. }
  463. public function testsWithConditionalFails(CliGuy $I)
  464. {
  465. $I->executeCommand('run scenario ConditionalCept --no-exit');
  466. $I->seeInShellOutput('There were 3 failures');
  467. $I->seeInShellOutput('Fail File "not-a-file" not found');
  468. $I->seeInShellOutput('Fail File "not-a-dir" not found');
  469. $I->seeInShellOutput('Fail File "nothing" not found');
  470. }
  471. public function runTestWithAnnotationDataprovider(CliGuy $I)
  472. {
  473. $I->executeCommand('run scenario -g dataprovider --steps');
  474. $I->seeInShellOutput('OK (15 tests');
  475. }
  476. public function runFailedTestAndCheckOutput(CliGuy $I)
  477. {
  478. $I->executeCommand('run scenario FailedCept', false);
  479. $testPath = implode(DIRECTORY_SEPARATOR, ['tests', 'scenario', 'FailedCept.php']);
  480. $I->seeInShellOutput('1) FailedCept: Fail when file is not found');
  481. $I->seeInShellOutput('Test ' . $testPath);
  482. $I->seeInShellOutput('Step See file found "games.zip"');
  483. $I->seeInShellOutput('Fail File "games.zip" not found at ""');
  484. }
  485. public function runTestWithCustomSetupMethod(CliGuy $I)
  486. {
  487. $I->executeCommand('run powers PowerUpCest');
  488. $I->dontSeeInShellOutput('FAILURES');
  489. }
  490. public function runCestWithTwoFailedTest(CliGuy $I)
  491. {
  492. $I->executeCommand('run scenario PartialFailedCest', false);
  493. $I->seeInShellOutput('See file found "testcasetwo.txt"');
  494. $I->seeInShellOutput('See file found "testcasethree.txt"');
  495. $I->seeInShellOutput('Tests: 3,');
  496. $I->seeInShellOutput('Failures: 2.');
  497. }
  498. public function runWarningTests(CliGuy $I)
  499. {
  500. $I->executeCommand('run unit WarningTest.php', false);
  501. $I->seeInShellOutput('There was 1 warning');
  502. $I->seeInShellOutput('WarningTest::testWarningInvalidDataProvider');
  503. $I->seeInShellOutput('Tests: 1,');
  504. $I->seeInShellOutput('Warnings: 1.');
  505. }
  506. /**
  507. * @group shuffle
  508. * @param CliGuy $I
  509. */
  510. public function showSeedNumberOnShuffle(CliGuy $I)
  511. {
  512. $I->executeCommand('run unit -o "settings: shuffle: true"', false);
  513. $I->seeInShellOutput('Seed');
  514. $I->executeCommand('run unit', false);
  515. $I->dontSeeInShellOutput('Seed');
  516. }
  517. /**
  518. * @group shuffle
  519. * @param CliGuy $I
  520. */
  521. public function showSameOrderOfFilesOnSeed(CliGuy $I, \Codeception\Scenario $s)
  522. {
  523. if (DIRECTORY_SEPARATOR === '\\') {
  524. $s->skip('Failing on Windows. Need to investigate');
  525. }
  526. $I->executeCommand('run unit -o "settings: shuffle: true"', false);
  527. $I->seeInShellOutput('Seed');
  528. $output = $I->grabFromOutput('/---\n((.|\n)*?)---/m');
  529. $output = preg_replace('~\(\d\.\d+s\)~m', '', $output);
  530. $seed = $I->grabFromOutput('~\[Seed\] (.*)~');
  531. $I->executeCommand('run unit -o "settings: shuffle: true" --seed ' . $seed, false);
  532. $newOutput = $I->grabFromOutput('/---\n((.|\n)*?)---/m');
  533. $newOutput = preg_replace('~\(\d\.\d+s\)~m', '', $newOutput);
  534. $I->assertEquals($output, $newOutput, 'order of tests is the same');
  535. $I->executeCommand('run unit -o "settings: shuffle: true"', false);
  536. $newOutput = $I->grabFromOutput('/---\n((.|\n)*?)---/m');
  537. $newOutput = preg_replace('~\(\d\.\d+s\)~m', '', $newOutput);
  538. $I->assertNotEquals($output, $newOutput, 'order of tests is the same');
  539. }
  540. }