oliverdavies.uk/source/_daily_emails/2024-08-15.md
2024-08-17 21:34:18 +01:00

758 B

title date permalink tags cta snippet
Docblocks or annotations? 2024-08-15 daily/2024/08/15/docblocks-or-annotations
software-development
php
automated-testing
~ Docblocks or annotations. Which do you prefer?

As #Drupal 11 uses #PHPUnit 10, we can now use the #[Test] attribute instead of the /** @test */ annotation.

For example:

// Before.

/** @test */
public function it_returns_the_endpoint()

// After.

#[Test]
public function it_returns_the_endpoint()

Annotations have started to be replaced in parts of Drupal since 10.2, so it's nice to be able to do it with tests, too.

Which do you prefer?