【问题标题】:Undefind withoutExceptionHandling()未定义无异常处理()
【发布时间】:2020-07-28 02:34:42
【问题描述】:

我正在尝试在 laravel 6 (windows 10) 上运行我的 UnitTest,使用著名的:

this->withoutExceptionHandling();

但我收到此错误:

错误:调用未定义的方法 Tests\Unit\ExampleTest::withoutExceptionHandling()

我没有更改任何设置,当然它是在以下位置定义的:

Illuminate\Foundation\Testing\Concerns\InteractsWithExceptionHandling

我什至尝试过:

"使用 Illuminate\Foundation\Testing\Concerns\InteractsWithExceptionHandling;"

但这仍然没有任何作用。

【问题讨论】:

    标签: laravel unit-testing exception phpunit laravel-unit-test


    【解决方案1】:

    这是一个简单的测试文件,应该可以正常工作。

    <?php
    
    namespace Tests\Unit;
    
    
    use Illuminate\Foundation\Testing\Concerns\InteractsWithExceptionHandling;
    use Tests\TestCase;
    
    class ExampleTest extends TestCase
    {
        use InteractsWithExceptionHandling;
    
        /**
         * A basic test example.
         *
         * @return void
         */
        public function testBasicTest()
        {
            $this->withoutExceptionHandling();
    
            $this->assertTrue(true);
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-11
      相关资源
      最近更新 更多