bashunit icon indicating copy to clipboard operation
bashunit copied to clipboard

Enable custom categories or groups for tests

Open Chemaclass opened this issue 1 year ago • 0 comments

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 🤔

Chemaclass avatar Oct 08 '24 20:10 Chemaclass