Uploaded image for project: 'OpenMRS Core'
  1. OpenMRS Core
  2. TRUNK-5811

Update Junit from 4 to 5

    XMLWordPrintable

Details

    • Task
    • Status: Closed
    • TBD
    • Resolution: Fixed
    • None
    • Core 2.4.0
    • None
    • Medium

    Description

      Context

      Junit the testing library that we rely on in openmrs-core has seen a major release some time ago which is Junit 5.

      If you want to understand its architecture and what dependencies we need read
      https://junit.org/junit5/docs/current/user-guide/#overview-what-is-junit-5

      Information on the biggest changes and what needs to be done to migrate from Junit 4.
      https://junit.org/junit5/docs/current/user-guide/#migrating-from-junit4

      Why should we migrate?

      Junit 4 is still supported but will eventually have an end of life. New developers with some Java experience coming to openmrs from other projects will very likely have written tests in Junit 5 since that is the current version. Junit 5 offers a lot of interesting new feature that openmrs could leverage.

      • conditional test execution (based on environment variables, JDK version, ...). This would allow us for example to run integration tests against mysql or postgresql in an environment where they are actually deployed
      • tags could be used for tagging tests as integration tests regardless of what their name is. maven-surefire could then use them to filter unit vs integration tests
      • parametrized tests can be written next to standard tests
      • the new extension model allows us to potentially write our own extensions that can be used alongside spring/mockito extensions (extensions replacing the runners (in Junit 4 only 1 runner per class is allowd) and rules)
      • ...

      Migration Tools

      IntelliJ enables developers to migrate singe files and even entire projects from Junit 4 to Junit 5.
      This video explains how this can be done
      https://www.youtube.com/watch?v=F8UTTTDtbH0

      This is not only very useful to achieve the migration of openmrs-core but it will also help module developers.

      Gliffy Diagrams

        Attachments

          Issue Links

            Activity

              People

                achilep Pahonsi Bebeto Achile
                achilep Pahonsi Bebeto Achile
                Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: