[英]Laravel unit testing show complete error
我正在尝试为我的laravel 5.2
项目创建一个测试, laravel 5.2
项目将测试其余资源控制器中的注册页面。 当我用我的测试的确切输入手动测试它一切正常但是当我用phpunit
测试它时,我被重定向到错误页面使我的页面断言失败。 但是,错误会显示断言失败的错误,而不是错误页面上的错误,因此不会显示测试失败的原因。 我怎么能看到这个?
测试用例:
class registerTest extends TestCase
{
use WithoutMiddleware;
public function testRegisterCompanyCorrectly()
{
$this->actAsAdmin();
$this->visit('/Companies/create')
->type('testCompany', 'CName')
->type('www.testCompany.com', 'CUrl')
->type('testManager@gmail.com', 'Mail')
->type('John Doe', 'Name')
->type('Keith Richards', 'Password')
->type('Keith Richards', 'CPassword')
->press('Registreren')
->seePageIs('/Companies/3')
;
}
private function actAsAdmin()
{
$user = User::find(1);
$this->actingAs($user);
}
}'
phpunit 错误:
There was 1 failure:
1) registerTest::testRegisterCompanyCorrectly
Did not land on expected page [http://localhost/Companies/3].
Failed asserting that two strings are equal.
--- Expected
+++ Actual
@@ @@
-'http://localhost/Companies/3'
+'http://localhost/Companies'
C:\Users\Stefan\Documents\producten\Applicatie\vendor\laravel\framework\src\Illuminate\Foundation\Testing\Concerns\InteractsWithPages.php:170
C:\Users\Stefan\Documents\producten\Applicatie\tests\registerTest.php:34
C:\xampp\php\pear\PHPUnit\TextUI\Command.php:176
C:\xampp\php\pear\PHPUnit\TextUI\Command.php:129
FAILURES!
Tests: 5, Assertions: 14, Failures: 1.
调查错误的一种方法是在app/Exceptions/Handler.php
激活Illuminate\\Foundation\\Validation\\ValidationException
错误报告。
protected $dontReport = [
// ValidationException::class,
];
如果再次运行测试,则日志文件中应该有一个堆栈跟踪。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.