-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Open
Labels
feature/testdoxThe TextDox printer/formatterThe TextDox printer/formattertype/enhancementA new idea that should be implementedA new idea that should be implemented
Description
Context
I use DataProvider
and TestDox
:
#[DataProvider('userPaginationDataProvider')]
#[TestDox('Test user $_dataName with query $query and there are $expectedUsersCount users and the title must contain $expectedTitleStart')]
Here is the output when running the test suite with --testdox
:
Badges Controller (App\Tests\Controller\BadgesController)
✔ Test badge no·page with query empty and there are 50 badges and the title must contain Badges·(page·1)·::
✔ Test badge page·1 with query ?page=1 and there are 50 badges and the title must contain Badges·(page·1)·::
✔ Test badge page·2 with query ?page=2 and there are 50 badges and the title must contain Badges·(page·2)·::
✔ Test badge page·3 with query ?page=3 and there are 5 badges and the title must contain Badges·(page·3)·::
Screenshot to see it with colors:
As you can see, this looks good. But the misalignment make it not easy to read (especially when the input data have more different lengths than in this example). This gave me an idea:
Proposal
What if there was a way to display this data as a table?
It may look like this:
+---------+---------+----------------------+-------------------+
| Name | Query | Expected users count | Title contain |
+---------+---------+----------------------+-------------------+
| no·page | empty | 50 | Badges(page·1)·:: |
| page·1 | ?page=1 | 50 | Badges(page·1)·:: |
| page·2 | ?page=2 | 50 | Badges(page·2)·:: |
| page·3 | ?page=3 | 5 | Badges(page·3)·:: |
+---------+---------+----------------------+-------------------+
This example was generated with Symfony’s Table Helper that may be used to format the output.
Challenge
It would be nice to be able to configure the name of each header but it may be complicated to implement.
With something like this?
#[TestDoxTable('Name $_dataName, query $query, Expected users count $expectedUsersCount, Title contain $expectedTitleStart')]
note: code used to generate this table
<?php
declare(strict_types=1);
namespace App\Command;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\Table;
use Symfony\Component\Console\Output\OutputInterface;
#[AsCommand(name: 'app:my-command')]
class MyCommand
{
public function __invoke(OutputInterface $output): int
{
$table = new Table($output);
$table
->setHeaders(['Name', 'Query', 'Expected users count', 'Title contain'])
->setRows([
['no·page', 'empty', '50', 'Badges(page·1)·::'],
['page·1', '?page=1', '50', 'Badges(page·1)·::'],
['page·2', '?page=2', '50', 'Badges(page·2)·::'],
['page·3', '?page=3', '5', 'Badges(page·3)·::'],
]);
$table->render();
return Command::SUCCESS;
}
}
Metadata
Metadata
Assignees
Labels
feature/testdoxThe TextDox printer/formatterThe TextDox printer/formattertype/enhancementA new idea that should be implementedA new idea that should be implemented