Ortzinator's avatar

This test did not perform any assertions

I'm following along with the Let's Build a Forum series, while adapting it to Laravel 8. I know it's a old series so maybe there's something new I'm missing with how testing works. Here's my testing class

<?php

namespace Tests\Feature;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
use App\Models\Thread;

class ThreadsTest extends TestCase
{
    use RefreshDatabase;
    
    public function test_user_can_view_threads()
    {
        
        $thread = Thread::make();
        $response = $this->get('/threads');

        // $response->assertOk();
        $response->assertSee($thread->title);
    }
}

I'm getting this warning

 WARN  Tests\Feature\ThreadsTest
  ! user can view threads → This test did not perform any assertions  /var/www/html/tests/Feature/ThreadsTest.php:14

I'm not sure how assertSee is not an assertion? If I do $response->assertSee('somenonsense'); it fails as expected.

0 likes
3 replies
sr57's avatar
sr57
Best Answer
Level 39

What's the value of $thread->title? (blanc or null?)

1 like
Ortzinator's avatar

Ah it's null. That makes sense! I was using the factory incorrectly. Thank you!

1 like

Please or to participate in this conversation.