hjortur17's avatar

Risky test

Hello, I'm new to testing and I'm following Jeffry's tutorial Let's Build A Forum with Laravel and TDD and I'm getting 1 risky test.

Here is message from terminal:

There was 1 risky test:

1) Tests\Feature\CreateThreadsTest::publishThreads
This test did not perform any assertions

/Users/hjorturfreyrlarusson/websites/nemo/tests/Feature/CreateThreadsTest.php:65

/Users/hjorturfreyrlarusson/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:208
/Users/hjorturfreyrlarusson/.composer/vendor/phpunit/phpunit/src/TextUI/Command.php:164

OK, but incomplete, skipped, or risky tests!

Here is the CreateThreadsTest

<?php

namespace Tests\Feature;

use Tests\TestCase;
use Illuminate\Foundation\Testing\DatabaseMigrations;

class CreateThreadsTest extends TestCase
{
       use DatabaseMigrations;

       /** @test */
       public function guests_may_not_create_threads()
       {
              $this->withExceptionHandling();

              $this->get('/fréttir/bæta')
                     ->assertRedirect('/login');

              $this->post('/fréttir')
                     ->assertRedirect('/login');
       }

       /** @test */
       public function an_authenticated_user_can_create_new_forum_threads()
       {
              $this->signIn();

              $thread = make('App\Thread');

              $response = $this->post('/fréttir', $thread->toArray());

              $this->get($response->headers->get('Location'))
                     ->assertSee($thread->title)
                     ->assertSee($thread->body);
       }

       /** @test */
       public function a_thread_requires_a_title()
       {
              $this->publishThreads(['title' => null])
                     ->assertSessionHasErrors('title');
       }

       /** @test */
       public function a_thread_requires_a_body()
       {
              $this->publishThreads(['body' => null])
                     ->assertSessionHasErrors('body');
       }

       /** @test */
       public function a_thread_requires_a_valid_channel()
       {
              factory('App\Channel', 2)->create();

              $this->publishThreads(['channel_id' => null])
                     ->assertSessionHasErrors('channel_id');

              $this->publishThreads(['channel_id' => 999])
                     ->assertSessionHasErrors('channel_id');
       }

       /** @test */
       public function publishThreads($overrides = [])
       {
              $this->withExceptionHandling()->signIn();

              $thread = make('App\Thread', $overrides);

              return $this->post('/fréttir', $thread->toArray());
       }
}

0 likes
3 replies

Please or to participate in this conversation.