06/12/2017 - PHPUNIT
Eğer Data Provider kullandığınız PhpUnit tesleri kırıldığında etiketlenmiş vaziyette anlamlı hata mesajları görmek isterseniz, aşağıdaki ikinci test yöntemini kullanabilirsiniz. "Test sonucu" bölümünde faklılığı görebilirsiniz.
class SomethingTest extends PHPUnit_Framework_TestCase
{
/**
* @test
*
* @dataProvider getDataProvider
*/
public function it_does_something(
$param1,
$param2
) {
// ...
}
public function getDataProvider()
{
return [
['Hello', 11],
['World', 22],
];
}
}
1) SomethingTest::it_does_something with data set #0 ('Hello', 11)
Failed asserting that false matches expected true.
2) SomethingTest::it_does_something with data set #1 ('World', 22)
Failed asserting that false matches expected true.
class SomethingTest extends PHPUnit_Framework_TestCase
{
/**
* @test
*
* @dataProvider getDataProvider
*/
public function it_does_something(
$param1,
$param2
) {
// ...
}
public function getDataProvider()
{
return [
'Testing Hello message' => [
'$param1' => 'Hello',
'$param2' => 11
],
'Testing World message' => [
'$param1' => 'World',
'$param2' => 22
],
];
}
}
1) SomethingTest::it_does_something with data set "Testing Hello message" ('Hello', 11)
Failed asserting that false matches expected true.
2) SomethingTest::it_does_something with data set "Testing World message" ('World', 22)
Failed asserting that false matches expected true.