add /** @test */ above the method or start the method name with test_.
Dec 29, 2020
4
Level 6
Test TDD lesson 1 No tests found in class "Tests\Feature\ProjectsTest".
I'm following this first lesson -> https://laracasts.com/series/build-a-laravel-app-with-tdd/episodes/2?autoplay=true
I wrote this test:
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
class ProjectsTest extends TestCase
{
use WithFaker, RefreshDatabase;
public function a_user_can_create_a_project()
{
$this->withoutExceptionHandling();
$attributes = [
'title' => $this->faker->sentence,
'description' => $this->faker->paragraph,
];
$this->post(['/projects', $attributes
]);
$this->assertDatabaseHas('projects',$attributes);
}
}
in the phpunit.xml file I changed so:
<php>
<server name="APP_ENV" value="testing"/>
<server name="BCRYPT_ROUNDS" value="4"/>
<server name="CACHE_DRIVER" value="array"/>
<server name="DB_CONNECTION" value="sqlite"/>
<server name="DB_DATABASE" value=":memory:"/>
<server name="MAIL_MAILER" value="array"/>
<server name="QUEUE_CONNECTION" value="sync"/>
<server name="SESSION_DRIVER" value="array"/>
<server name="TELESCOPE_ENABLED" value="false"/>
</php>
when i run the test i get this:
vendor/bin/phpunit tests/Feature/ProjectsTest.php
PHPUnit 9.5.0 by Sebastian Bergmann and contributors.
W 1 / 1 (100%)
Time: 00:00.003, Memory: 8.00 MB
There was 1 warning:
- Warning No tests found in class "Tests\Feature\ProjectsTest".
WARNINGS! Tests: 1, Assertions: 0, Warnings: 1.
I don't understand why it doesn't see the statement
Level 6
2 likes
Please or to participate in this conversation.