Skip to content

Enable custom categories or groups for tests #357

@Chemaclass

Description

@Chemaclass

Right now you can group tests only by folders or name. This task is to research best practices in other testing libraries and how could we achieve categorising tests as "slow" or something different.


Examples using different testing libraries:

PHPUnit

/** @group slow */
public function test_something_slow(): void
{
    // slow test code here
}
# Run only the slow tests
phpunit --group slow

# Exclude slow tests
phpunit --exclude-group slow

Pest

it('is a slow test')->group('slow', function () {
    // slow test code here
});
# Run only slow tests
./vendor/bin/pest --group=slow

# Exclude slow tests
./vendor/bin/pest --exclude-group=slow

Jest

// Mark the test with "slow" in the name
test('slow: this is a slow test', () => {
  // slow test code here
});

You can then filter tests based on the test name when running Jest using --testNamePattern:

# Run only slow tests
jest --testNamePattern="slow"

# Exclude slow tests (by excluding the "slow" pattern)
jest --testNamePattern="^((?!slow).)*$"

I think the best approach for bashunit is going into something similar like jest 🤔

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions