In JUnit 4, put @Ignore on a @Test method to skip that test, or on a test class to disable its contained tests. Add a short reason so the skip is visible and understandable in test reports. For new JUnit Jupiter tests, use @Disabled instead.
Skip a single test in JUnit 4
Import org.junit.Ignore and annotate the test method. The method also needs JUnit 4’s @Test annotation.
As an Amazon Associate I earn from qualifying purchases.
import org.junit.Ignore;
import org.junit.Test;
public class ExampleTest {
@Ignore("Disabled until issue #123 is fixed")
@Test
public void testSomething() {
// test body
}
}
The string is an optional explanation; it defaults to an empty string. JUnit 4’s API documents that a method annotated with both @Test and @Ignore will not execute as a test: JUnit 4.13.2 @Ignore API.
Skip every test in a JUnit 4 class
Place @Ignore on the test class to disable its contained tests. The annotation applies to types and methods.
#1 Best Overall
import org.junit.Ignore;
import org.junit.Test;
@Ignore("Waiting for the test environment to be repaired")
public class DatabaseIntegrationTest {
@Test
public void savesRecord() {
// test body
}
@Test
public void loadsRecord() {
// test body
}
}
Use a class-level reason that describes why the whole group is disabled and, where practical, what must change before it can be enabled again.
Why use @Ignore instead of commenting out a test?
Commenting out a method or removing @Test stops it from running, but the runner no longer reports it as an ignored test. The JUnit team’s guidance is to use @Ignore when a temporary skip should remain visible: native JUnit 4 runners report ignored tests alongside tests run and failures. See the JUnit team’s Ignoring tests guide.
Keep skips temporary and specific. A reason such as “Disabled until issue #123 is fixed” gives maintainers a concrete lead; an empty reason leaves them to infer intent.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #2
Use @Disabled for JUnit Jupiter
JUnit Jupiter, the JUnit 5 programming model, has its own native annotation: org.junit.jupiter.api.Disabled. It can disable a test method or a class, and the JUnit guide recommends including a reason.
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
class ExampleJupiterTest {
@Disabled("Waiting for the service test environment")
@Test
void testSomething() {
// test body
}
}
Do not use the JUnit 4 import by mistake: org.junit.Ignore is not Jupiter’s native disable annotation. The current JUnit 5.13.4 guide documents @Disabled for Jupiter tests: JUnit 5 User Guide, version 5.13.4.
Keep legacy @Ignore behavior during a Jupiter migration
If Jupiter-based tests still need to honor JUnit 4’s @Ignore, configure JUnit’s migration-support module; the annotation alone is not Jupiter’s native mechanism.
Rank #3
-
Add the
junit-jupiter-migrationsupportdependency using the version aligned with the JUnit Jupiter version in your project.PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteSpecial offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
Register
IgnoreConditiondirectly with@ExtendWith, or use@EnableJUnit4MigrationSupport, which registers the condition. -
Retain
org.junit.Ignoreonly where compatibility with legacy tests is needed. For new Jupiter tests, use@Disabled.Rank #4
This migration path is described in the JUnit 5.13.4 User Guide. A versioned JUnit 5.7.0-M1 guide also explicitly identifies @Disabled as the replacement for the no-longer-native @Ignore: JUnit 5.7.0-M1 User Guide.
Choose the annotation that matches the test engine
| Test code and runner | Annotation | Additional setup |
|---|---|---|
| JUnit 4 test | org.junit.Ignore |
Use alongside @Test for a method; class-level use disables contained tests. |
| JUnit Jupiter test | org.junit.jupiter.api.Disabled |
No JUnit 4 migration support is needed for the native annotation. |
Jupiter test retaining JUnit 4 @Ignore |
org.junit.Ignore with migration support |
Add junit-jupiter-migrationsupport and register IgnoreCondition or @EnableJUnit4MigrationSupport. |
Troubleshooting ignored tests
-
The test still runs. Check that it is a JUnit 4 test using the JUnit 4 runner and that the method has both
@Testand@Ignore. For Jupiter, use@Disabled, or configure the migration-support condition if retaining JUnit 4’s annotation.Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy. -
The annotation does not compile. Check the import. JUnit 4 uses
org.junit.Ignore; Jupiter usesorg.junit.jupiter.api.Disabled.Best Value
-
The test disappears from the report rather than appearing as ignored. If it was commented out or its
@Testannotation was removed, the runner has no test to count as ignored. Restore the test and mark it with the appropriate disable annotation. -
The ignored-test count is not shown. JUnit’s ignored-test reporting guidance concerns native JUnit 4 runners. Report presentation may depend on the runner or build tooling; confirm that the tests are being discovered and run by the expected JUnit integration.
Or skip the browser setup
For a website screenshot, ScreenshotNeo can return an image or PDF from one GET request; it is separate from JUnit and does not change how test annotations work. For example, save a screenshot of a page with cURL:
Free tools Windows power users keep installed
One-click scans. No signup required.
Quick Recap
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
See the ScreenshotNeo API documentation. ScreenshotNeo removes cookie banners, newsletter popups and chat widgets before capture; bot checks, blank pages and failed loads are not billed. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for ScreenshotNeo.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




