it only doesn't work in workspace mode. upon opening laravel project in root laravel project. things works just fine.
Mar 15, 2022
2
Level 4
better phpunit setup for testing laravel sail/docker
I am working on a laravel 8 project. and i have to write lots of test. I am using vscode editor, and so been using caleb porzio 's better phpunit extension. extesion for vscode. i can't setup it for running written tests inside docker container although i am defining everything as it is said in the github.com documentation.
these are typical configurations/settings that laravel ships with. i have just added my own configurations. all those are working independently.
here is my settings.json file
"better-phpunit.docker.enable": true,
"better-phpunit.docker.command": "docker-compose exec laravel.test",
"better-phpunit.docker.paths": {
"/home/rex/rajesh/code/erworks/codalaya/src": "/var/www/html"
},
here is the output of terminal when running better phpunit command.
> Executing task in folder Nuxt v2: docker-compose exec laravel.test /var/www/html/vendor/bin/phpunit /var/www/html/tests/Feature/CourseFeatureTest.php --filter '^.*::this_test_runs( .*)?$' --configuration /var/www/html/phpunit.xml <
The terminal process "/bin/bash '-c', 'docker-compose exec laravel.test /var/www/html/vendor/bin/phpunit /var/www/html/tests/Feature/CourseFeatureTest.php --filter '^.*::this_test_runs( .*)?$' --configuration /var/www/html/phpunit.xml'" terminated with exit code: 1.
Terminal will be reused by tasks, press any key to close it.
test file.
<?php
namespace Tests\Feature;
use App\Models\Role;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Support\Facades\Hash;
use Str;
use Tests\TestCase;
class CourseFeatureTest extends TestCase
{
use WithFaker, RefreshDatabase;
/** @test */
public function this_test_runs(): void
{
User::factory()->create([
'email' => '[email protected]',
'password' => Hash::make('password'),
'name' => 'rajesh kumar chaurasiya',
'username' => 'rajeshtva'
]);
$this->assertDatabaseCount('users', 1);
$this->assertTrue(true);
}
}
Level 4
Please or to participate in this conversation.