do you get a response if you hit that url with postman or load it in your browser?
Sep 3, 2021
11
Level 2
Laravel Unit Tests not working
I am trying to make tests, but they aren't working at all :(
Steps I followed:
- php artisan make:test ExampleTest
- php artisan config:clear
- php artisan test
Example test was created successfully:
namespace Tests\Feature;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Tests\TestCase;
class ExampleTest extends TestCase
{
/**
* A basic feature test example.
*
* @return void
*/
public function test_example()
{
$response = $this->get('/');
$response->assertStatus(200);
}
}
Running the test doesn't result in a proper result
# php artisan test
Warning: TTY mode is not supported on Windows platform.
FAIL Tests\Feature\ExampleTest
⨯ example
---
• Tests\Feature\ExampleTest > example
Error
Call to a member function getStatusCode() on bool
at C:\wamp64\www\jvz-api\tests\Feature\ExampleTest.php:20
16▕ public function test_example()
17▕ {
18▕ $response = $this->get('/');
19▕
➜ 20▕ $response->assertStatus(200);
21▕ }
22▕ }
23▕
1 C:\wamp64\www\jvz-api\vendor\phpunit\phpunit\phpunit:92
PHPUnit\TextUI\Command::main()
Tests: 1 failed
Time: 0.28s
I have read a lot of tutorials and it should work out of the box but I can't figure out why it is not working. I am trying to connect an API server.
Please or to participate in this conversation.