运行功能测试时,PHPUnit抛出“测试框架意外退出”

时间:2019-06-29 09:41:10

标签: php laravel phpunit phpstorm

我正在运行PHP 7.2(WAMP 3.1),PHPUnit 8.2.3,PhpStorm 2019.1,但我认为这不是配置问题,因为我以前对同一个文件的测试似乎可以正常工作,并且所有测试通过。这是“失败”和附带代码的功能测试。

测试:

/**@test*/
    public function a_user_can_view_a_project(){
        $this->withoutExceptionHandling();
        $project = factory('App\Project')->create();
        $this->get('/projects/'.$project->id)
             ->assertSee('title')
             ->assertSee('description');
    }

路线:

Route::get('/projects/{project}', 'ProjectsController@show');

控制器功能:

public function show(Project $project){
        return view('projects.show', compact('project'));
    }

迁移:

class CreateProjectsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('projects', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('title');
            $table->text('description');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('projects');
    }
}

工厂:

$factory->define(Project::class, function (Faker $faker) {
    return [
        'title' => $faker->sentence,
        'description' => $faker->paragraph
    ];
});

1 个答案:

答案 0 :(得分:0)

通过在测试前将/**@test*/更改为/** @test */(添加空格)来解决此问题。