laravel运行单元测试
<?php
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
class LoginTest extends TestCase
{
/**
* A basic feature test example.
*
* @return void
*/
public function testExample()
{
$response = $this->get('/');
$response->assertStatus(200);
}
/**
* php artisan test --group admin/login 基于group的测试
* php artisan test --filter LoginTest 基于类名的测试
* @group admin/login
*/
public function testLogin()
{
$response = $this->post('/admin/login', ['name' => 'admin', 'password' => '123456abc']);
$response->assertStatus(200)
->assertJson(['code' => 0]);
}
}
我觉得文档给的测试说明有问题,所以给了一个示例
1、基于group注释的测试
在注释里加上 * @group admin/login
,那么可这么运行类里面的这个类方法测试用例,基于group的测试php artisan test --group admin/login
2、基于类名的测试
运行类里面所有的测试用例php artisan test --filter LoginTes
这个是什么问题