Laravel 5.1-phpunit-ErrorException:未定义的属性:ExampleTest::$baseUrl

Laravel 5.1-phpunit-ErrorException:未定义的属性:ExampleTest::$baseUrl,phpunit,laravel-5.1,Phpunit,Laravel 5.1,我有默认设置。My composer.json具有以下特性: "require-dev": { "fzaninotto/faker": "~1.4", "mockery/mockery": "0.9.*", "phpunit/phpunit": "~4.0", "phpspec/phpspec": "~2.1" }, 当我运行phpunit时,我得到以下错误:我不知道为什么 PHPUnit 4.8.6由塞巴斯蒂安·伯格曼和贡献者撰写 E Time: 272 ms, Memor

我有默认设置。My composer.json具有以下特性:

"require-dev": {
  "fzaninotto/faker": "~1.4",
  "mockery/mockery": "0.9.*",
  "phpunit/phpunit": "~4.0",
  "phpspec/phpspec": "~2.1"
},
当我运行phpunit时,我得到以下错误:我不知道为什么

PHPUnit 4.8.6由塞巴斯蒂安·伯格曼和贡献者撰写

E

Time: 272 ms, Memory: 13.25Mb

There was 1 error:

1) ExampleTest::testBasicExample
ErrorException: Undefined property: ExampleTest::$baseUrl
php包含以下代码

<?php

class ExampleTest extends TestCase {

    /**
     * A basic functional test example.
     *
     * @return void
     */
    public function testBasicExample()
    {
        $response = $this->call('GET', '/');

        $this->assertEquals(200, $response->getStatusCode());
    }

}

我对测试很陌生。谢谢你的帮助。

从@tk获得了信息。您所要做的就是在父类TestCase中添加一个受保护的属性

它解决了这个问题

protected $baseUrl = 'http://yoursite.dev';