当我使用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.
Codeception转储:
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.
答案 0 :(得分:0)
升级到Codeception 2.2.2
https://github.com/Codeception/Codeception/blob/2.2/CHANGELOG.md#222