Use JUnit 5 in all lighty project and remove TestNG.#2598
Use JUnit 5 in all lighty project and remove TestNG.#2598Tobianas wants to merge 5 commits intoPANTHEONtech:mainfrom
Conversation
Unify all the lighty tests to depend on junit.jupiter only. JIRA: LIGHTY-409 Signed-off-by: tobias.pobocik <tobias.pobocik@pantheon.tech>
We want to use junit.jupiter transitively through lighty-parent. Remove all these redundant TestNG dependencies. JIRA: LIGHTY-409 Signed-off-by: tobias.pobocik <tobias.pobocik@pantheon.tech>
These dependencies are not needed to be specified, as we are getting them from lighty-parent transitively. JIRA: LIGHTY-409 Signed-off-by: tobias.pobocik <tobias.pobocik@pantheon.tech>
With the migration from TestNG to JUnit 5, TestNG suite XML files are no longer supported or required for test discovery. JUnit 5 automatically scans and discovers tests on the classpath. JIRA: LIGHTY-409 Signed-off-by: tobias.pobocik <tobias.pobocik@pantheon.tech>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request migrates the lighty project from TestNG to JUnit 5 for unit testing. This involves removing TestNG dependencies, adding JUnit 5 dependencies, and updating assertion and test lifecycle annotations in the test code. The goal is to modernize the testing framework and leverage the features offered by JUnit 5. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request provides a comprehensive migration from TestNG to JUnit 5 across the project. The changes are extensive and well-executed, covering dependency updates, annotation changes, and assertion migrations. I've added a few suggestions for improving test readability and correctness, such as using more specific assertions (assertFalse, assertArrayEquals) and addressing a minor logical flaw in one of the tests. Overall, this is a great step towards modernizing the test suite.
lighty-core/lighty-controller/src/test/java/io/lighty/core/controller/api/LightyModuleTest.java
Outdated
Show resolved
Hide resolved
| assertEquals(expectedResult, moduleId.equals(other)); | ||
| if (other != null) { | ||
| Assert.assertTrue(moduleId.hashCode() == other.hashCode() == expectedResult); | ||
| assertTrue(moduleId.hashCode() == other.hashCode() == expectedResult); |
There was a problem hiding this comment.
The assertion assertTrue(moduleId.hashCode() == other.hashCode() == expectedResult) is logically flawed. It incorrectly asserts that unequal objects must have different hash codes, which is not guaranteed by the hashCode() contract. A better approach would be to only assert that equal objects have equal hash codes: if (expectedResult) { assertEquals(moduleId.hashCode(), other.hashCode()); }.
There was a problem hiding this comment.
The point was to migrate tests to junit 5, not to rework the test logic.
...core/lighty-common/src/test/java/io/lighty/core/common/models/tests/YangModelUtilsTests.java
Outdated
Show resolved
Hide resolved
lighty-core/lighty-controller/src/test/java/io/lighty/core/controller/api/LightyModuleTest.java
Outdated
Show resolved
Hide resolved
...re/lighty-controller/src/test/java/io/lighty/core/controller/api/SystemReadyMonitorTest.java
Show resolved
Hide resolved
...core/lighty-controller/src/test/java/io/lighty/core/controller/config/ConfigLoadingTest.java
Outdated
Show resolved
Hide resolved
...ty-core/lighty-controller/src/test/java/io/lighty/core/controller/datainit/DataInitTest.java
Outdated
Show resolved
Hide resolved
Replace all testng and plain junit with junit.jupiter throughout the entire lighty.io project. JIRA: LIGHTY-409 Signed-off-by: tobias.pobocik <tobias.pobocik@pantheon.tech>
03bf8d0 to
093df73
Compare
No description provided.