Thanks to the great effort lead by @achilep we are making steady progress towards migrating openmrs-core tests to https://junit.org/junit5
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
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
(The docs at https://wiki.openmrs.org/display/docs/Unit+Testing+Conventions also reflect the above)
Thanks @teleivo point noted
This is awesome! Thanks @teleivo and @achilep
I just updated the IntelliJ live templates so that devs using them are all setup to use the
assertThrows when testing for exceptions
For those who have not used them yet see https://blog.jetbrains.com/idea/2020/05/write-code-faster-using-live-templates/
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
(Updated Eclipse templates will follow)
Anxiously waiting for the Eclipse ones. Thanks @teleivo
but testException5 give this default import :
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
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 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.