Repository navigation
Add unit tests for Listener and fix the test runtime - #125
Merged
Merged
Conversation
Owner
|
Thanks, looks good! Please update the three outdated comments in this PR:
|
Contributor
Author
|
Updated all three comments, thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This adds the first unit tests to the project and fixes the test runtime so
./gradlew testworks.Test runtime fix
With the first test under
src/test/java,./gradlew testfailed before running any test:NoClassDefFoundError: org/junit/runners/model/Statement.The IntelliJ Platform test framework refers to JUnit 4 classes even with JUnit 5
(see the IntelliJ Platform Gradle Plugin FAQ,
"JUnit5 Test Framework refers to JUnit4"). I added
junit:junit:4.13.2astestRuntimeOnly,so it is only on the runtime classpath and cannot be used by test code.
Tests (
ListenerTest)fromIdreturns the matching listener for every known IDfromIdreturnsDEFAULTfor unknown IDs (parameterized)Comments I left unchanged
Two comments in
build.gradle.ktsare slightly outdated now, I did not want to change them without your opinion:testIdeUi: "adding the first test under src/test/java is all it takes" (the JUnit 4 dependency was needed as well)instrumentTestCode: "Pointless without test sources" (there are test sources now, the task stays disabledbecause of the InstrumentCodeTask crash; tests run fine with it disabled)
Tested locally on Windows with JDK 21 (
./gradlew test, 6 tests green).