<p>As Drupal 11 uses PHPUnit 10, we can now use the <code>#[Test]</code> attribute instead of the <code>/** @test */</code> annotation for our test methods.</p>
<p>For example:</p>
<pre><code class="php">// Before.
/** @test */
public function it_returns_the_endpoint()
// After.
#[Test]
public function it_returns_the_endpoint()
</code></pre>
<p><a href="/daily/2024/04/04/php-attributes--coming-soon-to-a-drupal-version-near-you">Annotations have started to be replaced</a> in parts of Drupal since 10.2, so it's nice to be able to do it with tests, too.</p>
<p>Which do you prefer?</p>
format:full_html
processed:|
<p>As Drupal 11 uses PHPUnit 10, we can now use the <code>#[Test]</code> attribute instead of the <code>/** @test */</code> annotation for our test methods.</p>
<p><a href="/daily/2024/04/04/php-attributes--coming-soon-to-a-drupal-version-near-you">Annotations have started to be replaced</a> in parts of Drupal since 10.2, so it's nice to be able to do it with tests, too.</p>