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

《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 1
Warning: TTY mode is not supported on Windows platform.
ReflectionClass::getMethods() expects parameter 1 to be int, null given

这个是什么问题

10个月前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!