Skip to main content

Docblocks or attributes?

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

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?

Was this interesting?

Subscribe to my daily newsletter for software professionals on software development and delivery, Drupal, DevOps, community, and open-source.

About me

Picture of Oliver

I'm a certified Drupal Triple Expert and former Drupal Association staff member with 18 years of experience, a Drupal core contributor, public speaker, live streamer, and host of the Beyond Blocks podcast.