Skip to content

Instantly share code, notes, and snippets.

@hidenorigoto
Created June 16, 2014 07:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hidenorigoto/40c92edb63aae027e739 to your computer and use it in GitHub Desktop.
Save hidenorigoto/40c92edb63aae027e739 to your computer and use it in GitHub Desktop.
PHPUnitでデータプロバイダを使ったテストのデータごとにメッセージを付ける
<?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