O'Reilly logo

Mastering Software Testing with JUnit 5 by Boni García

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Skipping tests

The Jupiter annotation @Disabled (located in the package org.junit.jupiter.api) can be used to skip tests. It can be used at class level or method level. The following example uses the annotation @Disabled at method level and therefore it forces to skip the test:

package io.github.bonigarcia;import org.junit.jupiter.api.Disabled;import org.junit.jupiter.api.Test;class DisabledTest {    @Disabled    @Test    void skippedTest() {    }}

As shown in the following screenshot, when we execute this example, the test will be counted as skipped:

Disabled test method console output

In this other example, the annotation @Disabled is placed at the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required