大飞_dafei

导航

laravel -- 单元测试

<?php

namespace Tests\Feature;

use Tests\TestCase;

/**
 * Class ExampleTest
 * 调用这里所有测试方法命令
 *          ./vendor/bin/phpunit  --filter 'Tests\\Feature'
 *          ./vendor/bin/phpunit   --filter ExampleTest
 *
 * 查看方法:
 *           ./vendor/bin/phpunit  --help
 * @package Tests\Feature
 */
class ExampleTest extends TestCase
{
    /**
     * A basic test example.
     *
     * @return void
     */
    public function testBasicTest()
    {
        $response = $this->get('/');

        $response->assertStatus(200);
    }

    /**
     *
     *  执行命令 ./vendor/bin/phpunit
     *           ./vendor/bin/phpunit  --group default
     *           ./vendor/bin/phpunit  --filter createRule
     *           ./vendor/bin/phpunit --filter 'Tests\\Feature\\ExampleTest::testCreateRule'
     * @return string|\Symfony\Component\HttpFoundation\StreamedResponse
     */
    public function testCreateRule()
    {
        exit('测试这个方法01');
    }

    /**
     *  执行这个方法
     * ./vendor/bin/phpunit  --filter fei
     * ./vendor/bin/phpunit --filter 'Tests\\Feature\\ExampleTest::testFei'
     */
    public function testFei()
    {
        $this->call('GET','api/User/login'); //调用对应的路由
        exit('eeeeeeeee');
    }
}

 

posted on 2020-10-14 09:38  大飞_dafei  阅读(297)  评论(0编辑  收藏  举报