Created
June 16, 2014 07:08
-
-
Save hidenorigoto/40c92edb63aae027e739 to your computer and use it in GitHub Desktop.
PHPUnitでデータプロバイダを使ったテストのデータごとにメッセージを付ける
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
<?php | |
class ATest extends \PHPUnit_Framework_TestCase | |
{ | |
/** | |
* @test | |
* @dataProvider provider | |
*/ | |
public function テスト($a, $b) | |
{ | |
$this->assertThat($a == $b, $this->equalTo(true)); | |
} | |
public function provider() | |
{ | |
return [ | |
'aとbの値が異なるとき' => ['a', 'b'], | |
'aとbの値が同じとき' => ['a', 'a'], | |
]; | |
} | |
} | |
/* | |
There was 1 failure: | |
1) ATest::テスト with data set #0 ('a', 'b') | |
Failed asserting that false matches expected true. | |
*/ | |
/* | |
There was 1 failure: | |
1) ATest::テスト with data set "aとbの値が異なるとき" ('a', 'b') | |
Failed asserting that false matches expected true. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment