Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/run-ui-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
# the old runIdeForUiTests setup there is no separate "start the IDE and wait for the robot server"
# dance - the task is all that has to run.
#
# Note: there are no UI tests in the project yet, so the task currently runs an empty suite. The
# workflow exists so that adding the first test under src/test is enough to get it covered here.
# Tests are under src/test and require the JUnit 4 runtime dependency.
#
# Please check https://plugins.jetbrains.com/docs/intellij/testing-plugins.html for information
# about testing plugins.
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,19 @@
# InlineProblems Changelog

## [Unreleased]

### Added

- Unit tests for the different problem detection strategies, making sure there are no duplicate IDs and that every ID maps back to its listener

### Changed

- The GitHub release draft is created when a release is merged into the release branch, no longer on every push to main, so it cannot be published before the code is on the release branch

### Fixed

- JUnit 4 class could not be found when running tests due to a missing dependency in build.gradle.kts, JUnit 5 refers to JUnit 4 in IntelliJ

## [0.6.1] - 2026-10-13

### Fixed
Expand Down
10 changes: 6 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ dependencies {
testImplementation(platform("org.junit:junit-bom:${properties("junitVersion").get()}"))
testImplementation("org.junit.jupiter:junit-jupiter")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
// JUnit 5 Test Framework refers to JUnit 4 - see IntelliJ Platform Gradle Plugin FAQ
// https://plugins.jetbrains.com/docs/intellij/tools-intellij-platform-gradle-plugin-faq.html
testRuntimeOnly("junit:junit:4.13.2")
}

// Configure the IntelliJ Platform Gradle Plugin
Expand Down Expand Up @@ -148,8 +151,7 @@ qodana {
* Replaces the runIdeForUiTests task of the old gradle-intellij-plugin, which drove the IDE
* through the robot-server plugin - the 2.x plugin uses the IntelliJ Starter framework.
*
* There are no UI tests yet, so the task currently runs an empty suite. The plumbing is here so
* that adding the first test under src/test/java is all it takes. */
* Tests are under src/test and require the JUnit 4 runtime dependency. */
intellijPlatformTesting.testIdeUi.register("testIdeUi") {
task {
useJUnitPlatform()
Expand All @@ -164,8 +166,8 @@ tasks {
useJUnitPlatform()
}

// Pointless without test sources, and running both instrumentation tasks in one build
// crashes InstrumentCodeTask ("1 >= 1"). instrumentCode still covers the shipped code.
// Running both instrumentation tasks in one build crashes InstrumentCodeTask ("1 >= 1").
// instrumentCode still covers the shipped code.
named("instrumentTestCode") {
enabled = false
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.overengineer.inlineproblems.entities.enums;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

import java.util.*;

import static org.junit.jupiter.api.Assertions.*;

class ListenerTest {
@Test
void idsAreUnique() {
Set<Integer> knownIds = new HashSet<>();
List<Integer> duplicateIds = new ArrayList<>();

for (Listener listener : Listener.values()) {
if (!knownIds.add(listener.getId())) {
duplicateIds.add(listener.getId());
}
}

assertEquals(List.of(), duplicateIds);
}

@Test
void fromIdReturnsCorrectListener() {
List<Listener> mismatchedListeners = new ArrayList<>();

for (Listener listener : Listener.values()) {
if (listener != Listener.fromId(listener.getId())) {
mismatchedListeners.add(listener);
}
}

assertEquals(List.of(), mismatchedListeners);
}

@ParameterizedTest
@ValueSource(ints = {Integer.MIN_VALUE, -1, 99, Integer.MAX_VALUE})
void fromIdReturnsDefaultForUnknownId(int unknownId) {
assertEquals(Listener.DEFAULT, Listener.fromId(unknownId));
}
}
Loading