PHPUnitManual:4.7
- 오류 출력
테스트를 실패할 때마다 PHPUnit는 문제를 파악하는데 도움이 되도록 가능한 한 많은 정보를 여러분께 제공하고자 최선을 다하고 있습니다.
예4.60. 배열 비교의 실패 시 생성되는 오류의 출력
<?php
class ArrayDiffTest extends PHPUnit_Framework_TestCase
{
public function testEquality() {
$this->assertEquals(
array(1,2,3 ,4,5,6),
array(1,2,33,4,5,6)
);
}
}
?>
PHPUnit 3.6.0 by Sebastian Bergmann.
F
Time: 0 seconds, Memory: 5.25Mb
There was 1 failure:
1) ArrayDiffTest::testEquality
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
Array (
0 => 1
1 => 2
-
2 => 3
+
2 => 33
3 => 4
4 => 5
5 => 6
)
/home/sb/ArrayDiffTest.php:7
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.phpunit ArrayDiffTest
PHPUnit 3.6.0 by Sebastian Bergmann.
F
Time: 0 seconds, Memory: 5.25Mb
There was 1 failure:
1) ArrayDiffTest::testEquality
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
Array (
0 => 1
1 => 2
-
2 => 3
+
2 => 33
3 => 4
4 => 5
5 => 6
)
/home/sb/ArrayDiffTest.php:7
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
이 예제에서는 하나의 배열 값만 차이가 있으며 그 외의 값들은 오류가 발생한 곳에 컨텍스트를 제공하도록 표시됩니다.
생성된 출력이 너무 긴 경우 PHPUnit은 출력을 나누어 차이가 있는 부분마다 여러 줄로 된 컨텍스트를 제공합니다.
예4.61. 긴 배열의 배열 비교가 실패 시 오류 출력
<?php
class LongArrayDiffTest extends PHPUnit_Framework_TestCase
{
public function testEquality() {
$this->assertEquals(
array(0,0,0,0,0,0,0,0,0,0,0,0,1,2,3 ,4,5,6),
array(0,0,0,0,0,0,0,0,0,0,0,0,1,2,33,4,5,6)
);
}
}
?>
PHPUnit 3.6.0 by Sebastian Bergmann.
F
Time: 0 seconds, Memory: 5.25Mb
There was 1 failure:
1) LongArrayDiffTest::testEquality
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
13 => 2
-
14 => 3
+
14 => 33
15 => 4
16 => 5
17 => 6
)
/home/sb/LongArrayDiffTest.php:7
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.phpunit LongArrayDiffTest
PHPUnit 3.6.0 by Sebastian Bergmann.
F
Time: 0 seconds, Memory: 5.25Mb
There was 1 failure:
1) LongArrayDiffTest::testEquality
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
13 => 2
-
14 => 3
+
14 => 33
15 => 4
16 => 5
17 => 6
)
/home/sb/LongArrayDiffTest.php:7
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.