You can temporarily exclude tests: TestNG uses @Test(enabled = false); JUnit 4 uses @Ignore and JUnit 5 uses @Disabled (optionally with a reason). Disabled tests are reported as skipped, not run.
Disabling is for tests that are broken, flaky, or gated on unfinished features — better than deleting or commenting out, because the test remains visible and reported as skipped with (ideally) a reason. TestNG: @Test(enabled = false). JUnit 5: @Disabled("reason") on a method or class; JUnit 5 also has conditional disabling (@EnabledOnOs, @EnabledIf, @DisabledIfEnvironmentVariable) to skip based on environment. Always add a reason and a tracking ticket so disabled tests don't rot. A suite full of silently disabled tests is a red flag — track and re-enable them.
A test for an unreleased feature is @Disabled("JIRA-123: pending payment API") so it stays in the report as skipped with context, and is re-enabled when the API ships — rather than deleted and forgotten.
A colleague comments out a flaky test to make the build green. Why is @Disabled/@Test(enabled=false) with a reason better?