小编Ima*_*osi的帖子

从laravel中的测试套件中仅运行一个单元测试

使用phpunit命令Laravel将在我们的项目中运行所有单元测试.如何运行一个或特定的单元测试Laravel 5.1

我只想testFindToken从我的测试套件中运行.

<?php

use Mockery as m;
use App\Models\AccessToken;
use Illuminate\Foundation\Testing\WithoutMiddleware;

class AccessTokenRepositoryTest extends TestCase
{
    use WithoutMiddleware;

    public function setUp()
    {
        parent::setUp();

        $this->accessToken = factory(AccessToken::class);
        $this->repo_AccessToken = app()->make('App\Repositories\AccessTokenRepository');
    }

    public function testFindToken()
    {
        $model = $this->accessToken->make();
        $model->save();
        $model_accessToken = $this->repo_AccessToken->findToken($model->id);
        $this->assertInstanceOf(Illuminate\Database\Eloquent\Model::class, $model);
        $this->assertNotNull(true, $model_accessToken);
    }    
}
Run Code Online (Sandbox Code Playgroud)

php testing phpunit laravel

15
推荐指数
3
解决办法
1万
查看次数

标签 统计

laravel ×1

php ×1

phpunit ×1

testing ×1