TRUNK-5816 Move helpers into org.openmrs.test.jupiter
Junit 5 allows us to easily migrate to it also because classes,
annotations replacing the ones in Junit 4 have the same name but are
simply in another package called org.junit.jupiter. This is why the
IntelliJ migration tool only needs to change imports for example for the
@Test
We can follow the same approach end provide BaseContext... classes in a
new package called jupiter. When api tests or module tests migrate they
just need to update the import and everything else should work as before
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 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
TRUNK-5816 Use MockitoExtension
Extensions are the Junit 5 way of extending its capabilities.
MockitoExtension is setup strict by default which is very useful in that
it shows us unnecessary stubs like
org.mockito.exceptions.misusing.UnnecessaryStubbingException:
Unnecessary stubbings detected.
Clean & maintainable test code requires zero unnecessary code.
Following stubbings are unnecessary (click to navigate to relevant line of code):
1. -> at org.openmrs.api.impl.PatientServiceImplTest.checkPatientIdentifiers_shouldThrowDuplicateIdentifierGivenDuplicateIdentifiers(PatientServiceImplTest.java:165)
Please remove unnecessary stubbings or use 'lenient' strictness. More info: javadoc for UnnecessaryStubbingException class.
this helps us clean up our tests that have had mocks added over time but
not removed once not needed anymore.
MockitoExtension also allows us to inject mocks in constructor/test
methods
Note that we did setup the mocked
userContext.getAuthenticatedUser() in the ContextHelper as lenient so
that this mock that all