Uploaded image for project: 'Apache Ozone'
  1. Apache Ozone
  2. HDDS-6729

Migrate tests to JUnit5

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Implemented
    • None
    • 2.0.0
    • test
    • None

    Description

      Use the following command to find all tests that are still using JUnit4.

      grep -rlE "org.junit.[A-Z]" . --include '*.java'

      Use the following command to find all tests that are still using JUnit3 components.

      grep -rl "junit.framework" . --include '*.java'

      Script for the class substitution:

      sed -i $1 \
      	-e 's/org.junit.After;/org.junit.jupiter.api.AfterEach;/' \
      	-e 's/@After$/@AfterEach/' \
      	-e 's/org.junit.AfterClass;/org.junit.jupiter.api.AfterAll;/' \
      	-e 's/@AfterClass$/@AfterAll/' \
      	-e 's/org.junit.Before;/org.junit.jupiter.api.BeforeEach;/' \
      	-e 's/@Before$/@BeforeEach/' \
      	-e 's/org.junit.BeforeClass;/org.junit.jupiter.api.BeforeAll;/' \
      	-e 's/@BeforeClass$/@BeforeAll/' \
      	-e 's/org.junit.Test/org.junit.jupiter.api.Test/' \
      	-e 's/org.junit.Assert/org.junit.jupiter.api.Assertions/' \
      	-e 's/junit.framework.TestCase/org.junit.jupiter.api.Assertions/' \
      	-e 's/Assert\./Assertions./'
      

      Notes for converting assertions:

      • The order of parameters for assertions with message changed, old: assertEquals(message, expected, actual), new: assertEquals(expected, actual, message). This may result in compile errors that need to be fixed. Also, assertEquals(String, String, String) would successfully compile, but fail during test.
      • The name Assertions is a bit longer and conversion might result in lines over 80 chars, causing checkstyle failure.

      See also: https://junit.org/junit5/docs/current/user-guide/#migrating-from-junit4

      Subtasks that remove the last JUnit4 usage in the submodule should add <allow.junit4>false</allow.junit4> to pom.xml, to prevent new JUnit4 tests being added in the future.

      Attachments

        Issue Links

          1.
          Upgrade to JUnit 5.8.2 Sub-task Resolved Kaijie Chen
          2.
          Migrate tests in hdds-tools to JUnit5 Sub-task Resolved Kaijie Chen
          3.
          Migrate tests in hdds-client to JUnit5 Sub-task Resolved Kaijie Chen
          4.
          Migrate simple tests in hdds-server-framework to JUnit5 Sub-task Resolved Kaijie Chen
          5.
          Migrate parameterized tests in hdds-server-framework to JUnit5 Sub-task Resolved Kaijie Chen
          6.
          Migrate tests with rules in hdds-server-framework to JUnit5 Sub-task Resolved Kaijie Chen
          7.
          Migrate simple tests in hdds-server-scm to JUnit5 Sub-task Resolved Kaijie Chen
          8.
          Migrate parameterized tests in hdds-server-scm to JUnit5 Sub-task Resolved Kaijie Chen
          9.
          Migrate tests with rules in hdds-server-scm to JUnit5 Sub-task Resolved Kaijie Chen
          10.
          Migrate simple tests in hdds-common to JUnit5 Sub-task Resolved Kaijie Chen
          11.
          Migrate parameterized tests in hdds-common to JUnit5 Sub-task Resolved Kaijie Chen
          12.
          Migrate test with rules in hdds-common to JUnit5 Sub-task Resolved Kaijie Chen
          13.
          Migrate simple tests in ozone-recon to JUnit5 Sub-task Resolved Kaijie Chen
          14.
          Migrate SCM integration tests to JUnit 5 Sub-task Resolved Kaijie Chen
          15.
          Migrate simple tests in hdds-container-service to JUnit5 Sub-task Resolved Kaijie Chen
          16.
          Migrate TestKeyManagerImpl to JUnit5 Sub-task Resolved Kaijie Chen
          17.
          Migrate tests in hdds-erasurecode to JUnit5 Sub-task Resolved Kaijie Chen
          18.
          Migrate TestSecureOzoneCluster to JUnit5 Sub-task Resolved Attila Doroszlai
          19.
          Migrate TestOzoneAtRestEncryption to JUnit5 Sub-task Resolved Attila Doroszlai
          20.
          Ban import of JUnit4 classes in modules already migrated to JUnit5 Sub-task Resolved Attila Doroszlai
          21.
          Migrate tests in ozone-common to JUnit5 Sub-task Resolved Varsha Ravi
          22.
          Migrate simple tests in ozone-client to JUnit5 Sub-task Resolved Raju Balpande
          23.
          Migrate tests in hdds to JUnit5 Sub-task Resolved Hemant Kumar
          24.
          Migrate simple tests in hdds-container-service to JUnit5 Sub-task Resolved Szabolcs Gál
          25.
          Migrate TestCreatePipelineCommandHandler to JUnit5 Sub-task Resolved Szabolcs Gál
          26.
          Migrate simple tests in ozone-manager to JUnit5 Sub-task Resolved Varsha Ravi
          27.
          Migrate tests with TemporaryFolder in ozone-recon to JUnit5 Sub-task Resolved Raju Balpande
          28.
          Migrate remaining tests in ozone-recon to JUnit5 Sub-task Resolved Raju Balpande
          29.
          Migrate tests in ozone-s3gateway to JUnit5 Sub-task Resolved Raju Balpande
          30.
          Migrate tests in ozone-tools to JUnit5 Sub-task Resolved Raju Balpande
          31.
          Migrate parameterized unit tests in hadoop-ozone to JUnit5 Sub-task Resolved Varsha Ravi
          32.
          Migrate misc. tests in hadoop-ozone to JUnit5 Sub-task Resolved Raju Balpande
          33.
          Migrate tests in ozonefs-common to JUnit5 Sub-task Resolved Varsha Ravi
          34.
          Migrate integration tests with TemporaryFolder to JUnit5 Sub-task Resolved Hemant Kumar
          35.
          Migrate some parameterized integration tests to JUnit5 Sub-task Resolved Attila Doroszlai
          36.
          Migrate TestOmSnapshot to JUnit5 Sub-task Resolved Hemant Kumar
          37.
          Migrate parameterized tests in hdds-container-service to JUnit5 Sub-task Resolved Szabolcs Gál
          38.
          Migrate assertions in unit tests to JUnit5 Sub-task Resolved Raju Balpande
          39.
          Bump junit5 to 5.10.1 Sub-task Resolved Attila Doroszlai
          40.
          Remove leftover JUnit4 imports from modules already migrated Sub-task Resolved Attila Doroszlai
          41.
          Migrate simple client integration tests to JUnit5 Sub-task Resolved Varsha Ravi
          42.
          Migrate simple datanode integration tests to JUnit5 Sub-task Resolved naveenshettigar
          43.
          Migrate simple filesystem integration tests to JUnit5 Sub-task Resolved Raju Balpande
          44.
          Migrate simple freon integration tests to JUnit5 Sub-task Resolved Sai Vinoj
          45.
          Migrate simple OM integration tests to JUnit5 Sub-task Resolved Raju Balpande
          46.
          Migrate simple recon integration tests to JUnit5 Sub-task Resolved Will Xiao
          47.
          Migrate simple shell integration tests to JUnit5 Sub-task Resolved Raju Balpande
          48.
          Migrate simple misc. integration tests to JUnit5 Sub-task Resolved David
          49.
          Add static import for assertions in parameterized FS integration tests Sub-task Resolved Attila Doroszlai
          50.
          Migrate TestOzoneFileSystem to JUnit5 Sub-task Resolved Attila Doroszlai
          51.
          Migrate TestRootedOzoneFileSystem to JUnit5 Sub-task Resolved Attila Doroszlai
          52.
          Migrate TestOzoneFileInterfaces to JUnit5 Sub-task Resolved Attila Doroszlai
          53.
          Migrate assertions in integration tests to JUnit5 Sub-task Resolved Raju Balpande
          54.
          Migrate TimedOutTestsListener to JUnit5 Sub-task Resolved Attila Doroszlai
          55.
          Migrate remaining tests to JUnit5 Sub-task Resolved Attila Doroszlai
          56.
          Extract FS contract tests into separate submodule Sub-task Resolved Attila Doroszlai
          57.
          Delete JUnit4 categories Sub-task Resolved Attila Doroszlai
          58.
          Copy and migrate Hadoop base test classes to JUnit5 Sub-task Resolved Attila Doroszlai
          59.
          Migrate MetricsAsserts to AssertJ Sub-task Resolved Attila Doroszlai
          60.
          Migrate FS contract tests to JUnit5 Sub-task Resolved Attila Doroszlai
          61.
          Remove JUnit4 dependency Sub-task Resolved Attila Doroszlai

          Activity

            People

              ckj Kaijie Chen
              ckj Kaijie Chen
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: