If you don't really care about what's being written in the log file and only what to check if something was logged you could do this.
/** @test */
public function when_some_action_fails_the_system_will_log_the_errors()
{
// make sure the laravel log is empty
file_put_contents(storage_path('logs/laravel.log'), "");
// execute the action that will write in the log
//assert that the laravel.log is not empty
$this->assertTrue(
!empty(file_get_contents(storage_path('/logs/laravel.log')))
);
}
Be careful. Errors will be logged when other tests are failing - the above test clears out the log file.
@yshang77 I have a feeling this format is now outdated 3 years later. This answer seems more current, although I couldn't get it working for my use case: