0
我試着做一個真正簡單的測試與Laravel 4,但得到的錯誤會assertTrue方法錯誤。Laravel測試與簡單的測試
這是我的超級簡單測試。
class SignupTest extends TestCase {
public function testIndex()
{
$this->call('GET', '/');
$this->assertResponseOk();
}
}
錯誤堆棧跟蹤
PHP Fatal error: Call to undefined method SignupTest::assertTrue() in /home/domain/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php on line 135
PHP Stack trace:
PHP 1. {main}() /home/domain/vendor/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /home/domain/vendor/bin/phpunit:63
PHP 3. PHPUnit_TextUI_Command->run() /home/domain/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:129
PHP 4. PHPUnit_TextUI_TestRunner->doRun() /home/domain/vendor/phpunit/phpunit/PHPUnit/TextUI/Command.php:176
PHP 5. PHPUnit_Framework_TestSuite->run() /home/domain/vendor/phpunit/phpunit/PHPUnit/TextUI/TestRunner.php:349
PHP 6. PHPUnit_Framework_TestSuite->runTest() /home/domain/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:745
PHP 7. PHPUnit_Framework_TestCase->run() /home/domain/vendor/phpunit/phpunit/PHPUnit/Framework/TestSuite.php:775
PHP 8. PHPUnit_Framework_TestResult->run() /home/domain/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:783
PHP 9. PHPUnit_Framework_TestCase->runBare() /home/domain/vendor/phpunit/phpunit/PHPUnit/Framework/TestResult.php:648
PHP 10. PHPUnit_Framework_TestCase->runTest() /home/domain/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:838
PHP 11. ReflectionMethod->invokeArgs() /home/domain/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:983
PHP 12. SignupTest->testIndex() /home/domain/vendor/phpunit/phpunit/PHPUnit/Framework/TestCase.php:983
PHP 13. Illuminate\Foundation\Testing\TestCase->assertResponseOk() /home/domain/app/tests/Unit/Controllers/SignupTest.php:9
你可以看到我在延長的TestCase所以我應該有機會就給assertTrue方法。
作曲部分櫃面它help.s
"require-dev": {
"phpunit/phpunit": "3.7.*",
"way/laravel-test-helpers": "dev-master",
"fzaninotto/faker": "dev-master",
"mockery/mockery": "[email protected]"
},
我有傾倒自動加載和清零編譯。
希望你能指教。
SignupTest的第9行是什麼? –
assertTrue方法:$ this-> assertResponseOk(); – Lee
你能告訴你的'應用程序/ tests'文件夾的內容,全'SignupTest'類和'composer.json'自動加載部分? –