NielsNumbers's avatar

How to create test coverage for modules?

I tried to create a test-coverage for my modules folder. In the past I could generate code-coverage repots without issue for ./app dir.

This is my current phpunit.xml

<?php

namespace Modules\Example\Tests;

use Illuminate\Foundation\Testing\DatabaseTransactions;
use Modules\Example\Chatbot;
use Tests\TestCase;

class ExamleTest extends TestCase
{
    use DatabaseTransactions;

    /** @test */
    public function create_course_for_qualification_prints()
    {
        $chatBot = new Chatbot();
        $this->assertEquals('Hello World!', $chatBot->sayHello());
    }
}
<?php

namespace Modules\Example;

class Chatbot
{
    public function sayHello(): string
    {
        return 'Hello World!';
    }
}

I am using Laravel 9.52.16 with PHP 8.2.23

When I run the code-coverage, it has the code files inside modules in their, but the index.php does not show a single line of code coverage.

If I change the setup to

It works, but only files inside ./app are shown.

0 likes
0 replies

Please or to participate in this conversation.