Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only unit tests are supported Status U is printed in standard output
- Loading branch information
1 parent
c502768
commit b22c4af
Showing
11 changed files
with
202 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<?php | ||
|
||
class RunUselessTestsCest | ||
{ | ||
public function checkOutput(CliGuy $I): void | ||
{ | ||
$I->amInPath('tests/data/useless'); | ||
$I->executeCommand('run'); | ||
// $I->seeInShellOutput('U UselessCept: Make no assertions'); | ||
// $I->seeInShellOutput('U UselessCest: Make no assertions'); | ||
$I->seeInShellOutput('U UselessTest: Make no assertions'); | ||
$I->seeInShellOutput('U UselessTest: Make unexpected assertion'); | ||
$I->seeInShellOutput('OK, but incomplete, skipped, or risky tests!'); | ||
$I->seeInShellOutput('There were 2 risky tests:'); | ||
|
||
if (DIRECTORY_SEPARATOR === '/') { | ||
// $I->seeInShellOutput( | ||
// '1) UselessCept: Make no assertions | ||
// Test tests/unit/UselessCept.php | ||
//This test did not perform any assertions' | ||
// ); | ||
// $I->seeInShellOutput( | ||
// ' | ||
//2) UselessCest: Make no assertions | ||
// Test tests/unit/UselessCest.php:makeNoAssertions | ||
//This test did not perform any assertions | ||
// | ||
//Scenario Steps: | ||
// | ||
// 1. // make no assertions' | ||
// ); | ||
$I->seeInShellOutput( | ||
' | ||
1) UselessTest: Make no assertions | ||
Test tests/unit/UselessTest.php:testMakeNoAssertions | ||
This test did not perform any assertions' | ||
); | ||
$I->seeInShellOutput( | ||
' | ||
2) UselessTest: Make unexpected assertion | ||
Test tests/unit/UselessTest.php:testMakeUnexpectedAssertion | ||
This test is annotated with "@doesNotPerformAssertions" but performed 1 assertions' | ||
); | ||
|
||
return; | ||
} | ||
|
||
// $I->seeInShellOutput( | ||
// '1) UselessCept: Make no assertions | ||
// Test tests\unit\UselessCept.php | ||
//This test did not perform any assertions' | ||
// ); | ||
// $I->seeInShellOutput( | ||
// ' | ||
//2) UselessCest: Make no assertions | ||
// Test tests\unit\UselessCest.php:makeNoAssertions | ||
//This test did not perform any assertions | ||
// | ||
//Scenario Steps: | ||
// | ||
// 1. // make no assertions' | ||
// ); | ||
$I->seeInShellOutput( | ||
' | ||
1) UselessTest: Make no assertions | ||
Test tests\unit\UselessTest.php:testMakeNoAssertions | ||
This test did not perform any assertions' | ||
); | ||
$I->seeInShellOutput( | ||
' | ||
2) UselessTest: Make unexpected assertion | ||
Test tests\unit\UselessTest.php:testMakeUnexpectedAssertion | ||
This test is annotated with "@doesNotPerformAssertions" but performed 1 assertions' | ||
); | ||
} | ||
|
||
public function checkReports(CliGuy $I): void | ||
{ | ||
$I->amInPath('tests/data/useless'); | ||
$I->executeCommand('run --report --xml --phpunit-xml --html'); | ||
$I->seeInShellOutput('Useless: 2'); | ||
// $I->seeInShellOutput('UselessCept: Make no assertions............................................Useless'); | ||
// $I->seeInShellOutput('UselessCest: Make no assertions............................................Useless'); | ||
$I->seeInShellOutput('UselessTest: Make no assertions............................................Useless'); | ||
$I->seeInShellOutput('UselessTest: Make unexpected assertion.....................................Useless'); | ||
|
||
$I->seeFileFound('report.xml', 'tests/_output'); | ||
$I->seeInThisFile( | ||
'<testsuite name="unit" tests="4" assertions="1" errors="2" failures="0" skipped="0" time="' | ||
); | ||
// $I->seeInThisFile('<testcase name="Useless"'); | ||
// $I->seeInThisFile('<testcase name="makeNoAssertions" class="UselessCest"'); | ||
$I->seeInThisFile('<testcase name="testMakeNoAssertions" class="UselessTest" file="'); | ||
$I->seeInThisFile('<testcase name="testMakeUnexpectedAssertion" class="UselessTest" file="'); | ||
$I->seeInThisFile('Risky Test'); | ||
|
||
$I->seeFileFound('phpunit-report.xml', 'tests/_output'); | ||
$I->seeInThisFile( | ||
'<testsuite name="unit" tests="4" assertions="1" errors="2" failures="0" skipped="0" time="' | ||
); | ||
// $I->seeInThisFile('<testcase name="Useless"'); | ||
// $I->seeInThisFile('<testcase name="makeNoAssertions" class="UselessCest"'); | ||
$I->seeInThisFile('<testcase name="testMakeNoAssertions" class="UselessTest" file="'); | ||
$I->seeInThisFile('<testcase name="testMakeUnexpectedAssertion" class="UselessTest" file="'); | ||
$I->seeInThisFile('Risky Test'); | ||
|
||
$I->seeFileFound('report.html', 'tests/_output'); | ||
$I->seeInThisFile('<td class="scenarioUseless">Useless scenarios:</td>'); | ||
$I->seeInThisFile('<td class="scenarioUselessValue"><strong>2</strong></td>'); | ||
$I->seeInThisFile('UselessCest'); | ||
$I->seeInThisFile('UselessTest'); | ||
$I->seeInThisFile('UselessCept'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
paths: | ||
tests: tests | ||
output: tests/_output | ||
data: tests/_data | ||
support: tests/_support | ||
envs: tests/_envs | ||
actor_suffix: Tester | ||
settings: | ||
log_incomplete_skipped: true | ||
report_useless_tests: true | ||
colors: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
|
||
/** | ||
* Inherited Methods | ||
* @method void wantToTest($text) | ||
* @method void wantTo($text) | ||
* @method void execute($callable) | ||
* @method void expectTo($prediction) | ||
* @method void expect($prediction) | ||
* @method void amGoingTo($argumentation) | ||
* @method void am($role) | ||
* @method void lookForwardTo($achieveValue) | ||
* @method void comment($description) | ||
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL) | ||
* | ||
* @SuppressWarnings(PHPMD) | ||
*/ | ||
class UnitTester extends \Codeception\Actor | ||
{ | ||
use _generated\UnitTesterActions; | ||
|
||
/** | ||
* Define custom actions here | ||
*/ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* | ||
!.gitignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
actor: UnitTester |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<?php | ||
$I = new UnitTester($scenario); | ||
$I->wantTo('make no assertions'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
class UselessCest | ||
{ | ||
public function makeNoAssertions(UnitTester $I) | ||
{ | ||
$I->comment('make no assertions'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
class UselessTest extends \Codeception\Test\Unit | ||
{ | ||
/** | ||
* @var \UnitTester | ||
*/ | ||
protected $tester; | ||
|
||
public function testMakeNoAssertions() | ||
{ | ||
|
||
} | ||
|
||
public function testMakeUnexpectedAssertion() | ||
{ | ||
$this->expectNotToPerformAssertions(); | ||
$this->assertTrue(true); | ||
} | ||
} |