Reputation: 1274
I'm trying to run my UnitTest on laravel 6 (windows 10) with the famous:
this->withoutExceptionHandling();
But I get this error:
Error: Call to undefined method Tests\Unit\ExampleTest::withoutExceptionHandling()
I didn't change any setting and of course it's being defined in:
Illuminate\Foundation\Testing\Concerns\InteractsWithExceptionHandling
I even tried:
"use Illuminate\Foundation\Testing\Concerns\InteractsWithExceptionHandling;"
But this still does nothing.
Upvotes: 2
Views: 1162
Reputation: 1848
I know it is really old to answer, but just in case someone need it. It will return an error because you're using it inside the Unit Test instead of the feature test. You can use the $this->withoutExceptionHandling();
in feature tests but not in unit test.
Upvotes: 0
Reputation: 1105
This is a simple testing file, and it should work fine.
<?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);
}
}
Upvotes: 5