I have my own Laravel package and I want to be able to write and create tests for it.
My project is installed on the following directory within my project ROOT/CompayName/package-name
. My tests are located in ROOT/CompanyName/package-name/tests
while the code is located in ROOT/CompanyName/package-name/src
.
In the composer.json
file I autoload my tests like this
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/",
"CompayName\\ProjectName\\": "CompayName/package-name/tests/"
}
},
Additionally, I added the following to the phpunit.xml
file
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
<directory suffix="Test.php">./CompanyName/project-name/tests/</directory>
</testsuite>
Then I create the following test
<?php
namespace CompanyName\ProjectName;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;
class SomeKindOfTest extends TestCase
{
/**
* A basic test example.
*
* @return void
*/
public function ableToDoSomething()
{
dd('ableToDoSomething was called!!!!!!!!!!!');
}
}
However, when I run phpunit
from the command line, my test isn't being fired!
How can I correctly fire the tests in my package.