Skip to content

Use JUnit 5 in all lighty project and remove TestNG.#2598

Open
Tobianas wants to merge 5 commits intoPANTHEONtech:mainfrom
Tobianas:replace_testng
Open

Use JUnit 5 in all lighty project and remove TestNG.#2598
Tobianas wants to merge 5 commits intoPANTHEONtech:mainfrom
Tobianas:replace_testng

Conversation

@Tobianas
Copy link
Contributor

No description provided.

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>
@gemini-code-assist
Copy link

Summary of Changes

Hello, 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

  • JUnit 5 Migration: Migrated all projects to use JUnit 5 for testing, replacing TestNG.
  • Dependency Updates: Removed TestNG dependencies and corresponding JUnit 5 dependencies from POM files.
  • Assertion Updates: Updated assertion statements in test files to use JUnit 5's org.junit.jupiter.api.Assertions instead of TestNG's assertion methods.
  • Test Annotation Updates: Updated test annotations from TestNG's @Test to JUnit 5's @org.junit.jupiter.api.Test.
  • Lifecycle Annotation Updates: Updated lifecycle annotations from TestNG's @BeforeClass, @AfterClass, @BeforeMethod, and @AfterMethod to JUnit 5's @BeforeAll, @AfterAll, @BeforeEach, and @AfterEach respectively.
  • Data Provider Updates: Updated data providers from TestNG's @DataProvider to JUnit 5's @MethodSource.

🧠 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
  • lighty-applications/lighty-app-modules-config/pom.xml
    • Removed JUnit 5 dependency.
  • lighty-applications/lighty-app-modules-config/src/test/java/io/lighty/applications/util/ModulesConfigTest.java
    • Replaced TestNG assertions with JUnit 5 assertions.
  • lighty-applications/lighty-rcgnmi-app-aggregator/lighty-rcgnmi-app-module/pom.xml
    • Removed JUnit 5 dependency.
  • lighty-applications/lighty-rcgnmi-app-aggregator/lighty-rcgnmi-app-module/src/test/java/io/lighty/applications/rcgnmi/module/RcGnmiAppModuleConfigUtilsTest.java
    • Replaced TestNG assertions with JUnit 5 assertions.
    • Removed JUnit 5 Assertions import.
    • Replaced TestNG annotations with JUnit 5 annotations.
  • lighty-applications/lighty-rcgnmi-app-aggregator/lighty-rcgnmi-app/pom.xml
    • Removed JUnit 5 dependency.
  • lighty-applications/lighty-rnc-app-aggregator/lighty-rnc-app/src/test/java/io/lighty/applications/rnc/app/MainTest.java
    • Replaced TestNG annotations with JUnit 5 annotations.
  • lighty-applications/lighty-rnc-app-aggregator/lighty-rnc-module/src/test/java/io/lighty/applications/rnc/module/OpenApiTest.java
    • Replaced TestNG assertions with JUnit 5 assertions.
    • Replaced TestNG annotations with JUnit 5 annotations.
    • Updated data provider to use JUnit 5's @MethodSource.
  • lighty-applications/lighty-rnc-app-aggregator/lighty-rnc-module/src/test/java/io/lighty/applications/rnc/module/RncLightyModuleSmokeTest.java
    • Replaced TestNG assertions with JUnit 5 assertions.
    • Replaced TestNG annotations with JUnit 5 annotations.
  • lighty-applications/lighty-rnc-app-aggregator/lighty-rnc-module/src/test/java/io/lighty/applications/rnc/module/config/RncLightyModuleConfigUtilsTest.java
    • Replaced TestNG assertions with JUnit 5 assertions.
    • Replaced TestNG annotations with JUnit 5 annotations.
  • lighty-core/lighty-codecs-util/pom.xml
    • Removed JUnit 5 dependency.
  • lighty-core/lighty-common/pom.xml
    • Removed TestNG dependency.
  • lighty-core/lighty-common/src/test/java/io/lighty/core/common/SocketAnalyzerTest.java
    • Replaced TestNG assertions with JUnit 5 assertions.
    • Replaced TestNG annotations with JUnit 5 annotations.
  • lighty-core/lighty-common/src/test/java/io/lighty/core/common/models/tests/YangModelUtilsTests.java
    • Replaced TestNG assertions with JUnit 5 assertions.
    • Replaced TestNG annotations with JUnit 5 annotations.
    • Updated data provider to use JUnit 5's @MethodSource.
  • lighty-core/lighty-controller-guice-di/src/test/java/io/lighty/core/controller/guice/tests/GuiceDITest.java
    • Replaced TestNG assertions with JUnit 5 assertions.
    • Replaced TestNG annotations with JUnit 5 annotations.
  • lighty-core/lighty-controller/pom.xml
    • Removed TestNG dependency.
  • lighty-core/lighty-controller/src/test/java/io/lighty/core/controller/api/LightyModuleTest.java
    • Replaced TestNG assertions with JUnit 5 assertions.
    • Replaced TestNG annotations with JUnit 5 annotations.
  • lighty-core/lighty-controller/src/test/java/io/lighty/core/controller/api/SystemReadyMonitorTest.java
    • Replaced TestNG assertions with JUnit 5 assertions.
    • Replaced TestNG annotations with JUnit 5 annotations.
  • lighty-core/lighty-controller/src/test/java/io/lighty/core/controller/config/ConfigLoadingTest.java
    • Replaced TestNG assertions with JUnit 5 assertions.
    • Replaced TestNG annotations with JUnit 5 annotations.
  • lighty-core/lighty-controller/src/test/java/io/lighty/core/controller/datainit/DataInitTest.java
    • Replaced TestNG assertions with JUnit 5 assertions.
    • Replaced TestNG annotations with JUnit 5 annotations.
  • lighty-core/lighty-controller/src/test/java/io/lighty/core/controller/impl/tests/LightyControllerDataBrokerTest.java
    • Replaced TestNG assertions with JUnit 5 assertions.
    • Replaced TestNG annotations with JUnit 5 annotations.
  • lighty-core/lighty-controller/src/test/java/io/lighty/core/controller/impl/tests/LightyControllerMountPointTest.java
    • Replaced TestNG assertions with JUnit 5 assertions.
    • Replaced TestNG annotations with JUnit 5 annotations.
  • lighty-core/lighty-controller/src/test/java/io/lighty/core/controller/impl/tests/LightyControllerNotificationTest.java
    • Replaced TestNG assertions with JUnit 5 assertions.
    • Replaced TestNG annotations with JUnit 5 annotations.
  • lighty-core/lighty-controller/src/test/java/io/lighty/core/controller/impl/tests/LightyControllerTest.java
    • Replaced TestNG annotations with JUnit 5 annotations.
    • Replaced TestNG assertions with JUnit 5 assertions.
  • lighty-core/lighty-controller/src/test/java/io/lighty/core/controller/impl/tests/LightyControllerTestBase.java
    • Replaced TestNG annotations with JUnit 5 annotations.
  • lighty-core/lighty-controller/src/test/java/io/lighty/core/controller/services/LightyDiagStatusServiceImplTest.java
    • Replaced TestNG annotations with JUnit 5 annotations.
    • Replaced TestNG assertions with JUnit 5 assertions.
  • lighty-core/lighty-controller/src/test/java/io/lighty/core/controller/util/FileToDatastoreUtilsTest.java
    • Replaced TestNG annotations with JUnit 5 annotations.
    • Replaced TestNG assertions with JUnit 5 assertions.
  • lighty-core/lighty-parent/pom.xml
    • Replaced TestNG dependency with JUnit 5 dependency.
  • lighty-examples/lighty-bgp-community-restconf-app/pom.xml
    • Removed JUnit 5 dependency.
  • lighty-examples/lighty-community-aaa-restconf-app/pom.xml
    • Removed JUnit 5 dependency.
  • lighty-examples/lighty-community-netty-restconf-app/src/test/java/io/lighty/controllers/nettyrestconfapp/tests/RestconfAppTest.java
    • Replaced TestNG annotations with JUnit 5 annotations.
    • Replaced TestNG assertions with JUnit 5 assertions.
  • lighty-examples/lighty-community-restconf-actions-app/src/test/java/io/lighty/examples/controller/actions/RestconfActionsAppTest.java
    • Replaced TestNG annotations with JUnit 5 annotations.
    • Replaced TestNG assertions with JUnit 5 assertions.
  • lighty-examples/lighty-community-restconf-netconf-app/src/test/java/io/lighty/examples/controllers/restconfapp/tests/RestconfAppTest.java
    • Replaced TestNG annotations with JUnit 5 annotations.
    • Replaced TestNG assertions with JUnit 5 assertions.
  • lighty-examples/lighty-guice-app/pom.xml
    • Removed JUnit 5 dependency.
  • lighty-modules/integration-tests-aaa/pom.xml
    • Removed maven-surefire-plugin configuration.
  • lighty-modules/integration-tests-aaa/src/test/java/io/lighty/kit/examples/community/tests/AAATestIT.java
    • Replaced TestNG assertions with JUnit 5 assertions.
  • lighty-modules/integration-tests/pom.xml
    • Removed maven-surefire-plugin configuration.
  • lighty-modules/integration-tests/src/test/java/io/lighty/modules/southbound/netconf/tests/CallhomePluginTest.java
    • Replaced TestNG annotations with JUnit 5 annotations.
  • lighty-modules/integration-tests/src/test/java/io/lighty/modules/southbound/netconf/tests/TopologyPluginsTest.java
    • Replaced TestNG annotations with JUnit 5 annotations.
  • lighty-modules/lighty-aaa-aggregator/lighty-aaa/pom.xml
    • Removed TestNG dependency.
  • lighty-modules/lighty-aaa-aggregator/lighty-aaa/src/test/java/io/lighty/aaa/ShiroInitializationTest.java
    • Replaced TestNG annotations with JUnit 5 annotations.
    • Replaced TestNG assertions with JUnit 5 assertions.
  • lighty-modules/lighty-aaa-aggregator/lighty-aaa/src/test/java/io/lighty/aaa/config/AAAConfigUtilsTest.java
    • Replaced TestNG annotations with JUnit 5 annotations.
    • Replaced TestNG assertions with JUnit 5 assertions.
  • lighty-modules/lighty-aaa-aggregator/lighty-aaa/src/test/java/io/lighty/aaa/config/CertificateManagerConfigTest.java
    • Replaced TestNG annotations with JUnit 5 annotations.
    • Replaced TestNG assertions with JUnit 5 assertions.
  • lighty-modules/lighty-aaa-aggregator/lighty-aaa/src/test/java/io/lighty/aaa/config/DatastoreConfigurationConfigTest.java
    • Replaced TestNG annotations with JUnit 5 annotations.
    • Replaced TestNG assertions with JUnit 5 assertions.
  • lighty-modules/lighty-aaa-aggregator/lighty-aaa/src/test/java/io/lighty/aaa/config/ShiroConfigurationConfigTest.java
    • Replaced TestNG annotations with JUnit 5 annotations.
    • Replaced TestNG assertions with JUnit 5 assertions.
  • lighty-modules/lighty-bgp/pom.xml
    • Removed JUnit 5 dependency.
  • lighty-modules/lighty-gnmi/lighty-gnmi-commons/pom.xml
    • Removed JUnit 5 dependency.
  • lighty-modules/lighty-gnmi/lighty-gnmi-connector/pom.xml
    • Removed JUnit 5 dependency.
  • lighty-modules/lighty-gnmi/lighty-gnmi-connector/src/test/java/io/lighty/modules/gnmi/connector/tests/gnmi/GnmiTest.java
    • Replaced TestNG annotations with JUnit 5 annotations.
    • Replaced TestNG assertions with JUnit 5 assertions.
  • lighty-modules/lighty-gnmi/lighty-gnmi-device-simulator/pom.xml
    • Removed JUnit 5 dependency.
  • lighty-modules/lighty-gnmi/lighty-gnmi-sb/pom.xml
    • Removed JUnit 5 dependency.
  • lighty-modules/lighty-gnmi/lighty-gnmi-sb/src/test/java/io/lighty/modules/gnmi/southbound/mountpoint/codecs/YangInstanceNormToGnmiUpdateCodecTest.java
    • Replaced TestNG annotations with JUnit 5 annotations.
    • Replaced TestNG assertions with JUnit 5 assertions.
  • lighty-modules/lighty-gnmi/lighty-gnmi-sb/src/test/java/io/lighty/modules/gnmi/southbound/mountpoint/transactions/WriteTransactionTest.java
    • Replaced TestNG annotations with JUnit 5 annotations.
    • Replaced TestNG assertions with JUnit 5 assertions.
  • lighty-modules/lighty-gnmi/lighty-gnmi-test/pom.xml
    • Removed JUnit 5 dependency.
  • lighty-modules/lighty-jetty-server/pom.xml
    • Removed TestNG dependency.
  • lighty-modules/lighty-jetty-server/src/test/java/io/lighty/server/LightyJettyServerProviderTest.java
    • Replaced TestNG annotations with JUnit 5 annotations.
    • Replaced TestNG assertions with JUnit 5 assertions.
  • lighty-modules/lighty-netconf-sb/pom.xml
    • Removed TestNG dependency.
  • lighty-modules/lighty-netconf-sb/src/test/java/io/lighty/modules/southbound/netconf/tests/AAAEncryptionServiceTest.java
    • Replaced TestNG annotations with JUnit 5 annotations.
    • Replaced TestNG assertions with JUnit 5 assertions.
  • lighty-modules/lighty-netconf-sb/src/test/java/io/lighty/modules/southbound/netconf/tests/NetconfBaseServiceBaseTest.java
    • Replaced TestNG annotations with JUnit 5 annotations.
  • lighty-modules/lighty-netconf-sb/src/test/java/io/lighty/modules/southbound/netconf/tests/NetconfBaseServiceTest.java
    • Replaced TestNG annotations with JUnit 5 annotations.
    • Replaced TestNG assertions with JUnit 5 assertions.
  • lighty-modules/lighty-netconf-sb/src/test/java/io/lighty/modules/southbound/netconf/tests/NetconfNmdaBaseServiceTest.java
    • Replaced TestNG annotations with JUnit 5 annotations.
    • Replaced TestNG assertions with JUnit 5 assertions.
  • lighty-modules/lighty-netconf-sb/src/test/java/io/lighty/modules/southbound/netconf/tests/SampleConfigTest.java
    • Replaced TestNG annotations with JUnit 5 annotations.
    • Replaced TestNG assertions with JUnit 5 assertions.
  • lighty-modules/lighty-openapi/src/test/java/io/lighty/openapi/OpenApiLightyRFC8040Test.java
    • Replaced TestNG annotations with JUnit 5 annotations.
  • lighty-modules/lighty-openapi/src/test/java/io/lighty/openapi/OpenApiLightyTest.java
    • Replaced TestNG annotations with JUnit 5 annotations.
    • Replaced TestNG assertions with JUnit 5 assertions.
Activity
  • The pull request involves migrating the testing framework from TestNG to JUnit 5.
  • Dependencies were updated to reflect the change in testing framework.
  • Test annotations and assertion statements were updated to be compatible with JUnit 5.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

assertEquals(expectedResult, moduleId.equals(other));
if (other != null) {
Assert.assertTrue(moduleId.hashCode() == other.hashCode() == expectedResult);
assertTrue(moduleId.hashCode() == other.hashCode() == expectedResult);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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()); }.

Copy link
Contributor Author

@Tobianas Tobianas Mar 13, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The point was to migrate tests to junit 5, not to rework the test logic.

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant