Do not introduce deprecated Junit 4 test methods in openmrs-core

Thanks to the great effort lead by @achilep we are making steady progress towards migrating openmrs-core tests to https://junit.org/junit5 :slight_smile:

In order for us to migrate existing tests to JUnit 5 we need to replace deprecated methods or mechanisms that will not be available anymore. @achilep is already doing that for us :slight_smile:

It would be very helpful if every contributor/reviewer can keep an eye on the new contributions they make/review so that from now on they

Thank you all for helping us transition :smile:

(The docs at https://wiki.openmrs.org/display/docs/Unit+Testing+Conventions also reflect the above)

9 Likes

Thanks @teleivo point noted

This is awesome! Thanks @teleivo and @achilep :slight_smile:

4 Likes

Hi,

I just updated the IntelliJ live templates so that devs using them are all setup to use the assertThrows when testing for exceptions :slight_smile:

For those who have not used them yet see Write Code Faster Using Live Templates | The IntelliJ IDEA Blog

Here is how you test them:

  • pull the latest changes from openmrs-core

  • create a link to this file into the IntelliJ templates folder like for example

    ln -s ~/code/openmrs/openmrs-core/tools/src/main/resources/intellij/templates.xml ~/Library/ApplicationSupport/JetBrains/IdeaIC2020.1/templates/OpenMRS.xml

Adjust the paths to your local path structure and the IntelliJ version you have installed. You might need to restart Intellij after that you should see them in the Settings β†’ Editor β†’ Live Templates under the group OpenMRS.

In a test file for example write testException and hit enter. This should insert a junit test using assertThrows.

Please let me know if it works for you and is helpful. Every feedback is welcome :smile: (Updated Eclipse templates will follow)

1 Like

Anxiously waiting for the Eclipse ones. Thanks @teleivo :slight_smile:

1 Like

this may help, Developer How-To Setup And Use IntelliJ - Documentation - OpenMRS Wiki

great work .

1 Like

but testException5 give this default import : Screenshot from 2020-07-12 02-17-46

Good catch :slight_smile: Fixed.

1 Like

The Eclipse code templates for writing up to date Junit 4 and 5 tests in the OpenMRS style are available. Pull them from the latest master :slight_smile:

Import them in the Eclipse Settings β†’ Java β†’ Editor β†’ Templates from tools/src/main/resources/eclipse/templates.xml. You might need to either Restore Defaults or remove the old ones. Otherwise you will get duplicates.

Feel free to update them to make them even better :smile: As I haven’t used Eclipse in a while and the Eclipse templating language is not as intuitive as the IntelliJ one there might be room for improvement.

1 Like

Awesome! Thanks @teleivo :slight_smile:

1 Like

:1st_place_medal:

1 Like