Use this tag for question about Laravel testing
Laravel is built with unit testing in mind. In fact, support for testing with PHPUnit is included out of the box, and a phpunit.xml
file is already setup for your application. An example test file is provided in the tests
directory.
Defining & Running Tests
To create a test case, simply create a new test file in the tests/Unit
or tests/Feature
directory. The test class should extend TestCase
. You may then define test methods as you normally would when using PHPUnit.
An Example Test Class
class FooTest extends TestCase {
public function testSomethingIsTrue()
{
$this->assertTrue(true);
}
}
You may run all of the tests for your application by executing the php artisan test
(or phpunit
) command from your terminal.
Note: If you define your own
setUp
method, be sure to callparent::setUp
.