https://laravel.com/docs/5.7/testing#creating-and-running-tests
https://laravel.com/docs/5.7/http-tests
By default, your application's
tests
directory contains two directories: Feature
and Unit
. Unit tests are tests that focus on a very small, isolated portion of your code. In fact, most unit tests probably focus on a single method. Feature tests may test a larger portion of your code, including how several objects interact with each other or even a full HTTP request to a JSON endpoint.Creating & Running Tests
To create a new test case, use the
make:test
Artisan command:// Create a test in the Feature directory...
php artisan make:test UserTest
// Create a test in the Unit directory...
php artisan make:test UserTest --unit
HTTP Tests
Introduction
Laravel provides a very fluent API for making HTTP requests to your application and examining the output. For example, take a look at the test defined below:
<?php
namespace Tests\Feature;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
class ExampleTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function testBasicTest()
{
$response = $this->get('/');
$response->assertStatus(200);
}
}
No comments:
Post a Comment