add context menu to testviewer for enable/disable #2744
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What it does
JUnit 5 Parameterized Test Filtering for Eclipse JDT
Overview
This feature adds new capabilities to the Eclipse JUnit view that make it easier to work with JUnit 5 parameterized tests, especially those using
@EnumSource. When a specific test case fails, you can now quickly exclude it without manually editing the source code.Features
1. Exclude a Failing Test Case
When running a parameterized test with
@EnumSource, each enum value appears as a separate test case in the JUnit view. If one of these test cases fails, you can now:testWithEnum[VALUE2])Before:
After:
The
Modeimport is automatically added to your file.2. Disable/Enable Test Methods
You can disable any test method directly from the JUnit view:
For regular JUnit tests:
testSomething)@Disabled(JUnit 5) or@Ignore(JUnit 4) annotation is addedFor parameterized tests:
testWithEnum(TestEnum))If the test is already disabled, the menu shows "Enable This Test" instead, which removes the annotation.
This works for:
@Test)@Test)@ParameterizedTest)@RepeatedTest)@TestFactory)@TestTemplate)3. Re-include Excluded Values
If you've previously excluded enum values and want to bring them back:
VALUE2) to re-include just that oneBefore:
After clicking "Re-include All":
The unused
Modeimport is automatically removed if no longer needed.4. Quick Assist in Editor
When editing a test file, place your cursor on an
@EnumSourceannotation and press Ctrl+1 (or Cmd+1 on Mac) to see Quick Assist proposals:For any JUnit test method, Quick Assist also offers:
@Disabledannotation (JUnit 5)@Ignoreannotation (JUnit 4)5. Enhanced Test Viewer Display
Parameterized tests now show additional information in the JUnit view:
This helps you quickly identify which source annotation is being used.
6. Validation of Enum Values
If you rename or delete an enum constant, but the
@EnumSourceannotation still references it, a Quick Fix is available:@EnumSourceannotationThis removes any enum names that no longer exist in the enum class.
Workflow Example
Scenario: You have a parameterized test that runs with 5 enum values, but VALUE3 causes a known issue you want to temporarily skip.
testWithEnum[VALUE3]fails in the JUnit viewScenario: A regular test is failing and you want to skip it temporarily.
testSomethingfails in the JUnit view@Disabledis added to the methodSupported Annotations
@Test(JUnit 5)@Test(JUnit 4)@ParameterizedTest@EnumSource@Disabled(JUnit 5)@Ignore(JUnit 4)Requirements
Tips
Warning dialog: If excluding a value would leave only 0 or 1 values remaining, a confirmation dialog appears suggesting you might want to disable the entire test instead.
Clean imports: The feature automatically manages imports - adding
Modewhen needed and removing it when no longer used.Works after running: You can enable a disabled parameterized test even after running the test class with
@Disabled. The context menu correctly shows "Enable This Test" for ignored/skipped tests.JUnit version detection: The feature automatically detects whether you're using JUnit 4 or JUnit 5 and uses the appropriate annotation (
@Ignorevs@Disabled).How to test
Author checklist