【发布时间】:2016-11-01 05:00:12
【问题描述】:
当我使用 PHPUnit 并且由于两个数组不相等而失败时,它一次比较数组中的每个项目。但是,当我使用 Codeception(它使用 PHPUnit 进行单元测试)时,它告诉我整个数组是不同的,这不太有用。如何让 Codeception 以与 PHPUnit 相同的方式输出数组比较? Codeception 文档中似乎没有关于此的任何内容。
PHPUnit 转储:
C:\server\Apache24\htdocs\localhost\public_html\codeception_vs_phpunit>phpunit tests\BasicTest.php
PHPUnit 4.3.4 by Sebastian Bergmann.
F
Time: 141 ms, Memory: 3.75Mb
There was 1 failure:
1) BasicTest::testFoo
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
Array (
0 => 0
1 => 1
2 => 2
3 => 3
- 4 => 4
+ 4 => 42
5 => 5
6 => 6
7 => 7
8 => 8
9 => 9
)
C:\server\Apache24\htdocs\localhost\public_html\codeception_vs_phpunit\tests\BasicTest.php:33
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
代码接收转储:
C:\server\Apache24\htdocs\localhost\public_html\codeception_vs_phpunit>codecept run
Codeception PHP Testing Framework v2.2.1
Powered by PHPUnit 4.8.26 by Sebastian Bergmann and contributors.
Acceptance Tests (0) ---------------------------------------
------------------------------------------------------------
Functional Tests (0) ---------------------------------------
------------------------------------------------------------
Unit Tests (1) ---------------------------------------------
x BasicTest: Foo
------------------------------------------------------------
Time: 1.57 seconds, Memory: 11.00MB
There was 1 failure:
---------
1) BasicTest: Foo
Test tests\unit\BasicTest.php:testFoo
Failed asserting that two arrays are equal. ( -Expected | +Actual )
- Array (
- 0 => 0
- 1 => 1
- 2 => 2
- 3 => 3
- 4 => 4
- 5 => 5
- 6 => 6
- 7 => 7
- 8 => 8
- 9 => 9
- )
+ Array (
+ 0 => 0
+ 1 => 1
+ 2 => 2
+ 3 => 3
+ 4 => 42
+ 5 => 5
+ 6 => 6
+ 7 => 7
+ 8 => 8
+ 9 => 9
+ )
#1 C:\server\Apache24\htdocs\localhost\public_html\codeception_vs_phpunit\tests\unit\BasicTest.php:34
#2 BasicTest->testFoo
#3 C:\usr\bin\codecept.phar:7
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
【问题讨论】:
标签: phpunit codeception