【问题标题】:PHPUnit throws "Test framework quit unexpectedly" when running a feature test运行功能测试时 PHPUnit 抛出“测试框架意外退出”
【发布时间】:2019-11-10 23:31:15
【问题描述】:

我正在运行 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
    ];
});

【问题讨论】:

    标签: php laravel phpunit phpstorm


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-03
      • 2020-03-20
      • 2014-08-25
      • 2014-11-28
      • 2016-01-29
      • 2012-03-22
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多